2
0

feat(bot): Support variables in buttons

This commit is contained in:
Baptiste Arnaud
2022-06-15 17:55:19 +02:00
parent 0ffdd88dba
commit 46900ac6df
5 changed files with 184 additions and 7 deletions

View File

@ -1,11 +1,13 @@
import test, { expect } from '@playwright/test'
import {
createTypebots,
importTypebotInDatabase,
parseDefaultGroupWithBlock,
} from '../../services/database'
import { defaultChoiceInputOptions, InputBlockType, ItemType } from 'models'
import { typebotViewer } from '../../services/selectorUtils'
import cuid from 'cuid'
import path from 'path'
test.describe.parallel('Buttons input block', () => {
test('can edit button items', async ({ page }) => {
@ -67,3 +69,30 @@ test.describe.parallel('Buttons input block', () => {
).toBeVisible()
})
})
test('Variable buttons should work', async ({ page }) => {
const typebotId = cuid()
await importTypebotInDatabase(
path.join(__dirname, '../../fixtures/typebots/inputs/variableButton.json'),
{
id: typebotId,
}
)
await page.goto(`/typebots/${typebotId}/edit`)
await page.click('text=Preview')
await typebotViewer(page).locator('text=Variable item').click()
await expect(typebotViewer(page).locator('text=Variable item')).toBeVisible()
await expect(typebotViewer(page).locator('text=Ok great!')).toBeVisible()
await page.click('text="Item 1"')
await page.fill('input[value="Item 1"]', '{{Item 2}}')
await page.click('[data-testid="block1-icon"]')
await page.click('text=Multiple choice?')
await page.click('text="Restart"')
await typebotViewer(page).locator('text="Variable item" >> nth=0').click()
await typebotViewer(page).locator('text="Variable item" >> nth=1').click()
await typebotViewer(page).locator('text="Send"').click()
await expect(
typebotViewer(page).locator('text="Variable item, Variable item"')
).toBeVisible()
})