2022-01-28 09:42:31 +01:00
|
|
|
import test, { expect } from '@playwright/test'
|
|
|
|
import {
|
|
|
|
createTypebots,
|
|
|
|
parseDefaultBlockWithStep,
|
|
|
|
} from '../../services/database'
|
|
|
|
import { defaultDateInputOptions, InputStepType } from 'models'
|
|
|
|
import { typebotViewer } from '../../services/selectorUtils'
|
2022-02-02 08:05:02 +01:00
|
|
|
import { generate } from 'short-uuid'
|
2022-01-28 09:42:31 +01:00
|
|
|
|
|
|
|
test.describe('Date input step', () => {
|
|
|
|
test('options should work', async ({ page }) => {
|
2022-02-02 08:05:02 +01:00
|
|
|
const typebotId = generate()
|
2022-01-28 09:42:31 +01:00
|
|
|
await createTypebots([
|
|
|
|
{
|
|
|
|
id: typebotId,
|
|
|
|
...parseDefaultBlockWithStep({
|
|
|
|
type: InputStepType.DATE,
|
|
|
|
options: defaultDateInputOptions,
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
])
|
|
|
|
|
|
|
|
await page.goto(`/typebots/${typebotId}/edit`)
|
|
|
|
|
|
|
|
await page.click('text=Preview')
|
|
|
|
await expect(
|
|
|
|
typebotViewer(page).locator('[data-testid="from-date"]')
|
|
|
|
).toHaveAttribute('type', 'date')
|
|
|
|
await expect(typebotViewer(page).locator(`button`)).toBeDisabled()
|
|
|
|
|
|
|
|
await page.click(`text=Pick a date...`)
|
|
|
|
await page.click('text=Is range?')
|
|
|
|
await page.click('text=With time?')
|
|
|
|
await page.fill('#from', 'Previous:')
|
|
|
|
await page.fill('#to', 'After:')
|
|
|
|
await page.fill('#button', 'Go')
|
|
|
|
|
|
|
|
await page.click('text=Restart')
|
|
|
|
await expect(
|
|
|
|
typebotViewer(page).locator(`[data-testid="from-date"]`)
|
|
|
|
).toHaveAttribute('type', 'datetime-local')
|
|
|
|
await expect(
|
|
|
|
typebotViewer(page).locator(`[data-testid="to-date"]`)
|
|
|
|
).toHaveAttribute('type', 'datetime-local')
|
|
|
|
})
|
|
|
|
})
|