2
0

perf(e2e): ️ Migrate to Playwright

This commit is contained in:
Baptiste Arnaud
2022-01-28 09:42:31 +01:00
parent c5aaa323d1
commit 73f277fce7
145 changed files with 3104 additions and 2346 deletions

View File

@ -0,0 +1,34 @@
import test from '@playwright/test'
import {
createTypebots,
parseDefaultBlockWithStep,
} from '../../services/database'
import { defaultGoogleAnalyticsOptions, IntegrationStepType } from 'models'
const typebotId = 'google-analytics-step'
test.describe('Google Analytics step', () => {
test('its configuration should work', async ({ page }) => {
await createTypebots([
{
id: typebotId,
...parseDefaultBlockWithStep({
type: IntegrationStepType.GOOGLE_ANALYTICS,
options: defaultGoogleAnalyticsOptions,
}),
},
])
await page.goto(`/typebots/${typebotId}/edit`)
await page.click('text=Configure...')
await page.fill('input[placeholder="G-123456..."]', 'G-VWX9WG1TNS')
await page.fill('input[placeholder="Example: Typebot"]', 'Typebot')
await page.fill(
'input[placeholder="Example: Submit email"]',
'Submit email'
)
await page.click('text=Advanced')
await page.fill('input[placeholder="Example: Campaign Z"]', 'Campaign Z')
await page.fill('input[placeholder="Example: 0"]', '0')
})
})

View File

@ -0,0 +1,163 @@
import test, { expect, Page } from '@playwright/test'
import { importTypebotInDatabase } from '../../services/database'
import path from 'path'
import { typebotViewer } from '../../services/selectorUtils'
test.describe.parallel('Google sheets integration', () => {
test('Insert row should work', async ({ page }) => {
const typebotId = 'google-sheets-insert'
await importTypebotInDatabase(
path.join(
__dirname,
'../../fixtures/typebots/integrations/googleSheets.json'
),
{
id: typebotId,
}
)
await page.goto(`/typebots/${typebotId}/edit`)
await fillInSpreadsheetInfo(page)
await page.click('text=Select an operation')
await page.click('text=Insert a row')
await page.click('text=Select a column')
await page.click('text="Email" >> nth = 1')
await page.click('[aria-label="Insert a variable"]')
await page.click('text="Email" >> nth = 2')
await page.click('text=Add a value')
await page.click('text=Select a column')
await page.click('text=First name')
await page.fill(
'input[placeholder="Type a value..."] >> nth = 1',
'Georges'
)
await page.click('text=Preview')
await typebotViewer(page)
.locator('input[placeholder="Type your email..."]')
.fill('georges@gmail.com')
await typebotViewer(page)
.locator('input[placeholder="Type your email..."]')
.press('Enter')
await page.waitForResponse(
(resp) =>
resp
.request()
.url()
.includes(
'/api/integrations/google-sheets/spreadsheets/1k_pIDw3YHl9tlZusbBVSBRY0PeRPd2H6t4Nj7rwnOtM/sheets/0'
) &&
resp.status() === 200 &&
resp.request().method() === 'POST'
)
})
test('Update row should work', async ({ page }) => {
const typebotId = 'google-sheets-update'
await importTypebotInDatabase(
path.join(
__dirname,
'../../fixtures/typebots/integrations/googleSheets.json'
),
{
id: typebotId,
}
)
await page.goto(`/typebots/${typebotId}/edit`)
await fillInSpreadsheetInfo(page)
await page.click('text=Select an operation')
await page.click('text=Update a row')
await page.click('text=Select a column')
await page.click('text="Email" >> nth = 1')
await page.click('[aria-label="Insert a variable"]')
await page.click('text="Email" >> nth = 2')
await page.click('text=Select a column')
await page.click('text=Last name')
await page.fill(
'input[placeholder="Type a value..."] >> nth = 1',
'Last name'
)
await page.click('text=Preview')
await typebotViewer(page)
.locator('input[placeholder="Type your email..."]')
.fill('test@test.com')
await typebotViewer(page)
.locator('input[placeholder="Type your email..."]')
.press('Enter')
await page.waitForResponse(
(resp) =>
resp
.request()
.url()
.includes(
'/api/integrations/google-sheets/spreadsheets/1k_pIDw3YHl9tlZusbBVSBRY0PeRPd2H6t4Nj7rwnOtM/sheets/0'
) &&
resp.status() === 200 &&
resp.request().method() === 'PATCH'
)
})
test('Get row should work', async ({ page }) => {
const typebotId = 'google-sheets-get'
await importTypebotInDatabase(
path.join(
__dirname,
'../../fixtures/typebots/integrations/googleSheetsGet.json'
),
{
id: typebotId,
}
)
await page.goto(`/typebots/${typebotId}/edit`)
await fillInSpreadsheetInfo(page)
await page.click('text=Select an operation')
await page.click('text=Get data from sheet')
await page.click('text=Select a column')
await page.click('text="Email" >> nth = 1')
await page.click('[aria-label="Insert a variable"]')
await page.click('text="Email" >> nth = 2')
await page.click('text=Select a column')
await page.click('text="First name"')
await createNewVar(page, 'First name')
await page.click('text=Add a value')
await page.click('text=Select a column')
await page.click('text="Last name"')
await createNewVar(page, 'Last name')
await page.click('text=Preview')
await typebotViewer(page)
.locator('input[placeholder="Type your email..."]')
.fill('test2@test.com')
await typebotViewer(page)
.locator('input[placeholder="Type your email..."]')
.press('Enter')
await expect(
typebotViewer(page).locator('text=Your name is: John Smith')
).toBeVisible()
})
})
const fillInSpreadsheetInfo = async (page: Page) => {
await page.click('text=Configure...')
await page.click('text=Select an account')
await page.click('text=test2@gmail.com')
await page.fill('input[placeholder="Search for spreadsheet"]', 'CR')
await page.click('text=CRM')
await page.fill('input[placeholder="Select the sheet"]', 'Sh')
await page.click('text=Sheet1')
}
const createNewVar = async (page: Page, name: string) => {
await page.fill('input[placeholder="Select a variable"] >> nth=-1', name)
await page.click(`text=Create "${name}"`)
}

View File

@ -0,0 +1,70 @@
import test, { expect, Page } from '@playwright/test'
import { importTypebotInDatabase } from '../../services/database'
import path from 'path'
const typebotId = 'webhook-step'
test.describe('Webhook step', () => {
test('its configuration should work', async ({ page }) => {
await importTypebotInDatabase(
path.join(__dirname, '../../fixtures/typebots/integrations/webhook.json'),
{
id: typebotId,
}
)
await page.goto(`/typebots/${typebotId}/edit`)
await page.click('text=Configure...')
await page.click('text=GET')
await page.click('text=POST')
await page.fill(
'input[placeholder="Your Webhook URL..."]',
`${process.env.NEXTAUTH_URL}/api/mock/webhook`
)
await page.click('text=Query params')
await page.fill('input[placeholder="e.g. email"]', 'firstParam')
await page.fill('input[placeholder="e.g. {{Email}}"]', '{{secret 1}}')
await page.click('text=Add a param')
await page.fill('input[placeholder="e.g. email"] >> nth=1', 'secondParam')
await page.fill(
'input[placeholder="e.g. {{Email}}"] >> nth=1',
'{{secret 2}}'
)
await page.click('text=Headers')
await page.fill('input[placeholder="e.g. Content-Type"]', 'Custom-Typebot')
await page.fill(
'input[placeholder="e.g. application/json"]',
'{{secret 3}}'
)
await page.click('text=Body')
await page.fill('div[role="textbox"]', '{ "customField": "{{secret 4}}" }')
await page.click('text=Variable values for test')
await addTestVariable(page, 'secret 1', 'secret1')
await page.click('text=Add an entry')
await addTestVariable(page, 'secret 2', 'secret2')
await page.click('text=Add an entry')
await addTestVariable(page, 'secret 3', 'secret3')
await page.click('text=Add an entry')
await addTestVariable(page, 'secret 4', 'secret4')
await page.click('text=Test the request')
await expect(page.locator('div[role="textbox"] >> nth=-1')).toContainText(
'"statusCode": 200'
)
await page.click('text=Save in variables')
await page.click('input[placeholder="Select the data"]')
await page.click('text=data[0].name')
})
})
const addTestVariable = async (page: Page, name: string, value: string) => {
await page.click('[data-testid="variables-input"] >> nth=-1')
await page.click(`text="${name}"`)
await page.fill('input >> nth=-1', value)
}