Introduce bot v2 in builder (#328)

Also, the new engine is the default for updated typebots for viewer

Closes #211
This commit is contained in:
Baptiste Arnaud
2023-02-21 15:25:14 +01:00
committed by GitHub
parent 527dc8a5b1
commit debdac12ff
208 changed files with 4462 additions and 5236 deletions

View File

@@ -1,5 +1,4 @@
import test, { expect } from '@playwright/test'
import { typebotViewer } from 'utils/playwright/testHelpers'
import { importTypebotInDatabase } from 'utils/playwright/databaseActions'
import { createId } from '@paralleldrive/cuid2'
import { getTestAsset } from '@/test/utils/playwright'
@@ -51,30 +50,33 @@ test.describe('Condition block', () => {
await page.fill('input[placeholder="Type a value..."]', '20')
await page.click('text=Preview')
await typebotViewer(page)
await page
.locator('typebot-standard')
.locator('input[placeholder="Type a number..."]')
.fill('15')
await typebotViewer(page).locator('text=Send').click()
await page.locator('typebot-standard').locator('text=Send').click()
await expect(
typebotViewer(page).locator('text=You are younger than 20')
page.locator('typebot-standard').getByText('You are younger than 20')
).toBeVisible()
await page.click('text=Restart')
await typebotViewer(page)
await page
.locator('typebot-standard')
.locator('input[placeholder="Type a number..."]')
.fill('45')
await typebotViewer(page).locator('text=Send').click()
await page.locator('typebot-standard').locator('text=Send').click()
await expect(
typebotViewer(page).locator('text=You are older than 20')
page.locator('typebot-standard').getByText('You are older than 20')
).toBeVisible()
await page.click('text=Restart')
await typebotViewer(page)
await page
.locator('typebot-standard')
.locator('input[placeholder="Type a number..."]')
.fill('90')
await typebotViewer(page).locator('text=Send').click()
await page.locator('typebot-standard').locator('text=Send').click()
await expect(
typebotViewer(page).locator('text=You are older than 80')
page.locator('typebot-standard').getByText('You are older than 80')
).toBeVisible()
})
})

View File

@@ -1,5 +1,4 @@
import test, { expect } from '@playwright/test'
import { typebotViewer } from 'utils/playwright/testHelpers'
import { importTypebotInDatabase } from 'utils/playwright/databaseActions'
import { createId } from '@paralleldrive/cuid2'
import { getTestAsset } from '@/test/utils/playwright'
@@ -20,7 +19,7 @@ test.describe('Redirect block', () => {
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 page.locator('typebot-standard').locator('text=Go to URL').click()
await expect(page).toHaveURL('https://www.google.com')
await page.goBack()
@@ -30,7 +29,7 @@ test.describe('Redirect block', () => {
await page.click('text=Preview')
const [newPage] = await Promise.all([
context.waitForEvent('page'),
typebotViewer(page).locator('text=Go to URL').click(),
page.locator('typebot-standard').locator('text=Go to URL').click(),
])
await newPage.waitForLoadState()
await expect(newPage).toHaveURL('https://www.google.com')

View File

@@ -41,8 +41,8 @@ export const ScriptSettings = ({ options, onOptionsChange }: Props) => {
<Stack>
<Text>Code:</Text>
<CodeEditor
value={options.content ?? ''}
lang="js"
defaultValue={options.content ?? ''}
lang="javascript"
onChange={handleCodeChange}
/>
</Stack>

View File

@@ -1,5 +1,4 @@
import test, { expect } from '@playwright/test'
import { typebotViewer } from 'utils/playwright/testHelpers'
import { importTypebotInDatabase } from 'utils/playwright/databaseActions'
import { createId } from '@paralleldrive/cuid2'
import { getTestAsset } from '@/test/utils/playwright'
@@ -20,7 +19,7 @@ test.describe('Script block', () => {
)
await page.click('text=Preview')
await typebotViewer(page).locator('text=Trigger code').click()
await page.getByRole('button', { name: 'Trigger code' }).click()
await expect(page).toHaveURL('https://www.google.com')
})
})

View File

@@ -51,9 +51,9 @@ export const SetVariableSettings = ({ options, onOptionsChange }: Props) => {
{options.isCode ?? false ? (
<CodeEditor
value={options.expressionToEvaluate ?? ''}
defaultValue={options.expressionToEvaluate ?? ''}
onChange={handleExpressionChange}
lang="js"
lang="javascript"
/>
) : (
<Textarea

View File

@@ -1,5 +1,4 @@
import test, { expect } from '@playwright/test'
import { typebotViewer } from 'utils/playwright/testHelpers'
import { importTypebotInDatabase } from 'utils/playwright/databaseActions'
import { createId } from '@paralleldrive/cuid2'
import { getTestAsset } from '@/test/utils/playwright'
@@ -42,18 +41,19 @@ test.describe('Set variable block', () => {
await page.fill('textarea', '1000 + {{Total}}')
await page.click('text=Preview')
await typebotViewer(page)
await page
.locator('typebot-standard')
.locator('input[placeholder="Type a number..."]')
.fill('365')
await typebotViewer(page).locator('text=Send').click()
await page.locator('typebot-standard').locator('text=Send').click()
await expect(
typebotViewer(page).locator('text=Multiplication: 365000')
page.locator('typebot-standard').locator('text=Multiplication: 365000')
).toBeVisible()
await expect(
typebotViewer(page).locator('text=Custom var: Custom value')
page.locator('typebot-standard').locator('text=Custom var: Custom value')
).toBeVisible()
await expect(
typebotViewer(page).locator('text=Addition: 366000')
page.locator('typebot-standard').locator('text=Addition: 366000')
).toBeVisible()
})
})

View File

@@ -1,5 +1,4 @@
import test, { expect } from '@playwright/test'
import { typebotViewer } from 'utils/playwright/testHelpers'
import { importTypebotInDatabase } from 'utils/playwright/databaseActions'
import { createId } from '@paralleldrive/cuid2'
import { getTestAsset } from '@/test/utils/playwright'
@@ -35,7 +34,9 @@ test('should be configurable', async ({ page }) => {
await page.click('text=Group #2')
await page.click('text=Preview')
await expect(typebotViewer(page).locator('text=Second block')).toBeVisible()
await expect(
page.locator('typebot-standard').locator('text=Second block')
).toBeVisible()
await page.click('[aria-label="Close"]')
await page.click('text=Jump to Group #2 in My link typebot 2')
@@ -44,9 +45,11 @@ test('should be configurable', async ({ page }) => {
await page.click('button >> text=Start')
await page.click('text=Preview')
await typebotViewer(page).locator('input').fill('Hello there!')
await typebotViewer(page).locator('input').press('Enter')
await expect(typebotViewer(page).locator('text=Hello there!')).toBeVisible()
await page.locator('typebot-standard').locator('input').fill('Hello there!')
await page.locator('typebot-standard').locator('input').press('Enter')
await expect(
page.locator('typebot-standard').locator('text=Hello there!')
).toBeVisible()
await page.click('[aria-label="Close"]')
await page.click('text=Jump to Start in My link typebot 2')
@@ -61,5 +64,7 @@ test('should be configurable', async ({ page }) => {
await page.click('button >> text=Hello')
await page.click('text=Preview')
await expect(typebotViewer(page).locator('text=Hello world')).toBeVisible()
await expect(
page.locator('typebot-standard').locator('text=Hello world')
).toBeVisible()
})

View File

@@ -1,5 +1,4 @@
import test, { expect } from '@playwright/test'
import { typebotViewer } from 'utils/playwright/testHelpers'
import { importTypebotInDatabase } from 'utils/playwright/databaseActions'
import { createId } from '@paralleldrive/cuid2'
import { getTestAsset } from '@/test/utils/playwright'
@@ -17,10 +16,14 @@ test.describe('Wait block', () => {
await page.getByRole('textbox', { name: 'Seconds to wait for:' }).fill('3')
await page.click('text=Preview')
await typebotViewer(page).locator('text=Wait now').click()
await page.getByRole('button', { name: 'Wait now' }).click()
await page.waitForTimeout(1000)
await expect(typebotViewer(page).locator('text="Hi there!"')).toBeHidden()
await expect(
page.locator('typebot-standard').locator('text="Hi there!"')
).toBeHidden()
await page.waitForTimeout(3000)
await expect(typebotViewer(page).locator('text="Hi there!"')).toBeVisible()
await expect(
page.locator('typebot-standard').locator('text="Hi there!"')
).toBeVisible()
})
})