2
0

feat(viewer): Add variables in URL support

This commit is contained in:
Baptiste Arnaud
2022-02-17 10:46:04 +01:00
parent f7d6f0b766
commit 6e0ab67502
15 changed files with 550 additions and 58 deletions

View File

@ -7,7 +7,7 @@ import { defaultTextInputOptions, InputStepType } from 'models'
import { typebotViewer } from '../../services/selectorUtils'
import { generate } from 'short-uuid'
test.describe('Text input step', () => {
test.describe.parallel('Text input step', () => {
test('options should work', async ({ page }) => {
const typebotId = generate()
await createTypebots([
@ -41,4 +41,26 @@ test.describe('Text input step', () => {
).toBeVisible()
await expect(typebotViewer(page).locator(`text=Go`)).toBeVisible()
})
test('variable in URL should prefill the input', async ({ page }) => {
const typebotId = generate()
await createTypebots([
{
id: typebotId,
...parseDefaultBlockWithStep({
type: InputStepType.TEXT,
options: { ...defaultTextInputOptions, variableId: 'var1' },
}),
},
])
await page.goto(`/typebots/${typebotId}/edit?var1=My prefilled answer`)
await page.click('text=Preview')
await expect(
typebotViewer(page).locator(
`input[placeholder="${defaultTextInputOptions.labels.placeholder}"]`
)
).toHaveAttribute('value', 'My prefilled answer')
await expect(typebotViewer(page).locator(`button`)).toBeEnabled()
})
})