Files
bot/apps/builder/src/features/blocks/logic/setVariable/setVariable.spec.ts

60 lines
2.1 KiB
TypeScript
Raw Normal View History

import test, { expect } from '@playwright/test'
import { importTypebotInDatabase } from '@typebot.io/lib/playwright/databaseActions'
2023-02-10 15:06:02 +01:00
import { createId } from '@paralleldrive/cuid2'
import { getTestAsset } from '@/test/utils/playwright'
2023-02-10 15:06:02 +01:00
const typebotId = createId()
2022-06-11 07:27:38 +02:00
test.describe('Set variable block', () => {
2022-01-28 17:57:14 +01:00
test('its configuration should work', async ({ page }) => {
await importTypebotInDatabase(
getTestAsset('typebots/logic/setVariable.json'),
{
id: typebotId,
}
)
await page.goto(`/typebots/${typebotId}/edit`)
await page.click('text=Type a number...')
2022-01-28 17:57:14 +01:00
await page.fill('input[placeholder="Select a variable"] >> nth=-1', 'Num')
await page.getByRole('menuitem', { name: 'Create Num' }).click()
await page.click('text=Click to edit... >> nth = 0')
2022-01-28 17:57:14 +01:00
await page.fill('input[placeholder="Select a variable"] >> nth=-1', 'Total')
await page.getByRole('menuitem', { name: 'Create Total' }).click()
await page.fill('textarea', '1000 * {{Num}}')
await page.click('text=Click to edit...', { force: true })
2022-01-28 17:57:14 +01:00
await page.fill(
'input[placeholder="Select a variable"] >> nth=-1',
'Custom var'
)
await page.getByRole('menuitem', { name: 'Create Custom var' }).click()
await page.fill('textarea', 'Custom value')
await page.click('text=Click to edit...', { force: true })
await page.fill(
'input[placeholder="Select a variable"] >> nth=-1',
'Addition'
)
await page.getByRole('menuitem', { name: 'Create Addition' }).click()
await page.fill('textarea', '1000 + {{Total}}')
await page.click('text=Preview')
await page
.locator('typebot-standard')
.locator('input[placeholder="Type a number..."]')
.fill('365')
await page.locator('typebot-standard').locator('text=Send').click()
await expect(
page.locator('typebot-standard').locator('text=Multiplication: 365000')
).toBeVisible()
await expect(
page.locator('typebot-standard').locator('text=Custom var: Custom value')
).toBeVisible()
await expect(
page.locator('typebot-standard').locator('text=Addition: 366000')
).toBeVisible()
})
})