2022-01-28 09:42:31 +01:00
|
|
|
import test, { expect } from '@playwright/test'
|
|
|
|
import {
|
|
|
|
createTypebots,
|
|
|
|
parseDefaultBlockWithStep,
|
|
|
|
} from '../../services/database'
|
|
|
|
import { defaultTextInputOptions, InputStepType } from 'models'
|
|
|
|
import { typebotViewer } from '../../services/selectorUtils'
|
2022-03-18 12:30:42 +01:00
|
|
|
import cuid from 'cuid'
|
2022-01-28 09:42:31 +01:00
|
|
|
|
2022-02-17 10:46:04 +01:00
|
|
|
test.describe.parallel('Text input step', () => {
|
2022-01-28 09:42:31 +01:00
|
|
|
test('options should work', async ({ page }) => {
|
2022-03-18 12:30:42 +01:00
|
|
|
const typebotId = cuid()
|
2022-01-28 09:42:31 +01:00
|
|
|
await createTypebots([
|
|
|
|
{
|
|
|
|
id: typebotId,
|
|
|
|
...parseDefaultBlockWithStep({
|
|
|
|
type: InputStepType.TEXT,
|
|
|
|
options: defaultTextInputOptions,
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
])
|
|
|
|
|
|
|
|
await page.goto(`/typebots/${typebotId}/edit`)
|
|
|
|
|
|
|
|
await page.click('text=Preview')
|
|
|
|
await expect(
|
|
|
|
typebotViewer(page).locator(
|
|
|
|
`input[placeholder="${defaultTextInputOptions.labels.placeholder}"]`
|
|
|
|
)
|
|
|
|
).toHaveAttribute('type', 'text')
|
|
|
|
await expect(typebotViewer(page).locator(`button`)).toBeDisabled()
|
|
|
|
|
|
|
|
await page.click(`text=${defaultTextInputOptions.labels.placeholder}`)
|
|
|
|
await page.fill('#placeholder', 'Your name...')
|
|
|
|
await page.fill('#button', 'Go')
|
|
|
|
await page.click('text=Long text?')
|
|
|
|
|
|
|
|
await page.click('text=Restart')
|
|
|
|
await expect(
|
|
|
|
typebotViewer(page).locator(`textarea[placeholder="Your name..."]`)
|
|
|
|
).toBeVisible()
|
|
|
|
await expect(typebotViewer(page).locator(`text=Go`)).toBeVisible()
|
|
|
|
})
|
|
|
|
})
|