2022-03-07 17:39:57 +01:00
|
|
|
import test, { expect } from '@playwright/test'
|
|
|
|
import path from 'path'
|
|
|
|
import { typebotViewer } from '../../services/selectorUtils'
|
|
|
|
import { importTypebotInDatabase } from '../../services/database'
|
2022-03-18 12:30:42 +01:00
|
|
|
import cuid from 'cuid'
|
2022-03-07 17:39:57 +01:00
|
|
|
|
2022-03-18 12:30:42 +01:00
|
|
|
const typebotId = cuid()
|
2022-03-07 17:39:57 +01:00
|
|
|
|
|
|
|
test.describe('Code step', () => {
|
|
|
|
test('code should trigger', async ({ page }) => {
|
|
|
|
await importTypebotInDatabase(
|
|
|
|
path.join(__dirname, '../../fixtures/typebots/logic/code.json'),
|
|
|
|
{
|
|
|
|
id: typebotId,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
await page.goto(`/typebots/${typebotId}/edit`)
|
|
|
|
await page.click('text=Configure...')
|
|
|
|
await page.fill(
|
|
|
|
'div[role="textbox"]',
|
|
|
|
'window.location.href = "https://www.google.com"'
|
|
|
|
)
|
|
|
|
|
|
|
|
await page.click('text=Preview')
|
|
|
|
await typebotViewer(page).locator('text=Trigger code').click()
|
|
|
|
await expect(page).toHaveURL('https://www.google.com')
|
|
|
|
})
|
|
|
|
})
|