perf(e2e): ⚡️ Migrate to Playwright
This commit is contained in:
73
apps/builder/playwright/tests/logic/condition.spec.ts
Normal file
73
apps/builder/playwright/tests/logic/condition.spec.ts
Normal file
@ -0,0 +1,73 @@
|
||||
import test, { expect, Page } from '@playwright/test'
|
||||
import path from 'path'
|
||||
import { typebotViewer } from '../../services/selectorUtils'
|
||||
import { importTypebotInDatabase } from '../../services/database'
|
||||
|
||||
const typebotId = 'condition-step'
|
||||
|
||||
test.describe('Condition step', () => {
|
||||
test('its configuration should work', async ({ page }) => {
|
||||
await importTypebotInDatabase(
|
||||
path.join(__dirname, '../../fixtures/typebots/logic/condition.json'),
|
||||
{
|
||||
id: typebotId,
|
||||
}
|
||||
)
|
||||
|
||||
await page.goto(`/typebots/${typebotId}/edit`)
|
||||
await page.click('text=Configure...')
|
||||
await page.fill('input[placeholder="Search for a variable"]', 'Age')
|
||||
await page.click('button:has-text("Age")')
|
||||
await page.click('button:has-text("Select an operator")')
|
||||
await page.click('button:has-text("Greater than")', { force: true })
|
||||
await page.fill('input[placeholder="Type a value..."]', '80')
|
||||
|
||||
await page.click('button:has-text("Add a comparison")')
|
||||
|
||||
await page.fill(
|
||||
':nth-match(input[placeholder="Search for a variable"], 2)',
|
||||
'Age'
|
||||
)
|
||||
await page.click('button:has-text("Age")')
|
||||
await page.click('button:has-text("Select an operator")')
|
||||
await page.click('button:has-text("Less than")', { force: true })
|
||||
await page.fill(
|
||||
':nth-match(input[placeholder="Type a value..."], 2)',
|
||||
'100'
|
||||
)
|
||||
|
||||
await page.click('text=Configure...')
|
||||
await page.fill('input[placeholder="Search for a variable"]', 'Age')
|
||||
await page.click('button:has-text("Age")')
|
||||
await page.click('button:has-text("Select an operator")')
|
||||
await page.click('button:has-text("Greater than")', { force: true })
|
||||
await page.fill('input[placeholder="Type a value..."]', '20')
|
||||
|
||||
await page.click('text=Preview')
|
||||
await typebotViewer(page)
|
||||
.locator('input[placeholder="Type your answer..."]')
|
||||
.fill('15')
|
||||
await typebotViewer(page).locator('text=Send').click()
|
||||
await expect(
|
||||
typebotViewer(page).locator('text=You are younger than 20')
|
||||
).toBeVisible()
|
||||
|
||||
await page.click('text=Restart')
|
||||
await typebotViewer(page)
|
||||
.locator('input[placeholder="Type your answer..."]')
|
||||
.fill('45')
|
||||
await typebotViewer(page).locator('text=Send').click()
|
||||
await expect(
|
||||
typebotViewer(page).locator('text=You are older than 20')
|
||||
).toBeVisible()
|
||||
|
||||
await page.click('text=Restart')
|
||||
await typebotViewer(page)
|
||||
.locator('input[placeholder="Type your answer..."]')
|
||||
.fill('90')
|
||||
await typebotViewer(page).locator('text=Send').click()
|
||||
await expect(
|
||||
typebotViewer(page).locator('text=You are older than 80')
|
||||
).toBeVisible()
|
||||
})
|
||||
})
|
37
apps/builder/playwright/tests/logic/redirect.spec.ts
Normal file
37
apps/builder/playwright/tests/logic/redirect.spec.ts
Normal file
@ -0,0 +1,37 @@
|
||||
import test, { expect } from '@playwright/test'
|
||||
import path from 'path'
|
||||
import { typebotViewer } from '../../services/selectorUtils'
|
||||
import { importTypebotInDatabase } from '../../services/database'
|
||||
|
||||
const typebotId = 'redirect-step'
|
||||
|
||||
test.describe('Redirect step', () => {
|
||||
test('its configuration should work', async ({ page, context }) => {
|
||||
await importTypebotInDatabase(
|
||||
path.join(__dirname, '../../fixtures/typebots/logic/redirect.json'),
|
||||
{
|
||||
id: typebotId,
|
||||
}
|
||||
)
|
||||
|
||||
await page.goto(`/typebots/${typebotId}/edit`)
|
||||
await page.click('text=Configure...')
|
||||
await page.fill('input[placeholder="Type a URL..."]', 'google.com')
|
||||
|
||||
await page.click('text=Preview')
|
||||
await typebotViewer(page).locator('text=Go to URL').click()
|
||||
await expect(page).toHaveURL('https://www.google.com')
|
||||
await page.goBack()
|
||||
|
||||
await page.click('text=Redirect to google.com')
|
||||
await page.click('text=Open in new tab')
|
||||
|
||||
await page.click('text=Preview')
|
||||
const [newPage] = await Promise.all([
|
||||
context.waitForEvent('page'),
|
||||
typebotViewer(page).locator('text=Go to URL').click(),
|
||||
])
|
||||
await newPage.waitForLoadState()
|
||||
await expect(newPage).toHaveURL('https://www.google.com')
|
||||
})
|
||||
})
|
44
apps/builder/playwright/tests/logic/setVariable.spec.ts
Normal file
44
apps/builder/playwright/tests/logic/setVariable.spec.ts
Normal file
@ -0,0 +1,44 @@
|
||||
import test, { expect } from '@playwright/test'
|
||||
import path from 'path'
|
||||
import { typebotViewer } from '../../services/selectorUtils'
|
||||
import { importTypebotInDatabase } from '../../services/database'
|
||||
|
||||
const typebotId = 'set-variable-step'
|
||||
|
||||
test.describe('Set variable step', () => {
|
||||
test('its configuration should work', async ({ page, context }) => {
|
||||
await importTypebotInDatabase(
|
||||
path.join(__dirname, '../../fixtures/typebots/logic/setVariable.json'),
|
||||
{
|
||||
id: typebotId,
|
||||
}
|
||||
)
|
||||
|
||||
await page.goto(`/typebots/${typebotId}/edit`)
|
||||
await page.click('text=Type a number...')
|
||||
await page.fill('input[placeholder="Select a variable"]', 'Num')
|
||||
await page.click('text=Create "Num"')
|
||||
|
||||
await page.click('text=Click to edit... >> nth = 0')
|
||||
await page.fill('input[placeholder="Select a variable"]', 'Total')
|
||||
await page.click('text=Create "Total"')
|
||||
await page.fill('textarea', '1000 * {{Num}}')
|
||||
|
||||
await page.click('text=Click to edit...')
|
||||
await page.fill('input[placeholder="Select a variable"]', 'Custom var')
|
||||
await page.click('text=Create "Custom var"')
|
||||
await page.fill('textarea', 'Custom value')
|
||||
|
||||
await page.click('text=Preview')
|
||||
await typebotViewer(page)
|
||||
.locator('input[placeholder="Type a number..."]')
|
||||
.fill('365')
|
||||
await typebotViewer(page).locator('text=Send').click()
|
||||
await expect(
|
||||
typebotViewer(page).locator('text=Total: 365000')
|
||||
).toBeVisible()
|
||||
await expect(
|
||||
typebotViewer(page).locator('text=Custom var: Custom value')
|
||||
).toBeVisible()
|
||||
})
|
||||
})
|
Reference in New Issue
Block a user