2
0
Files
bot/apps/builder/playwright/tests/inputs/number.spec.ts
Baptiste Arnaud 8a350eee6c refactor(editor): ♻️ Undo / Redo buttons + structure refacto
Yet another huge refacto... While implementing undo and redo features I understood that I updated the stored typebot too many times (i.e. on each key input) so I had to rethink it entirely. I also moved around some files.
2022-02-02 08:05:02 +01:00

54 lines
1.7 KiB
TypeScript

import test, { expect } from '@playwright/test'
import {
createTypebots,
parseDefaultBlockWithStep,
} from '../../services/database'
import { defaultNumberInputOptions, InputStepType } from 'models'
import { typebotViewer } from '../../services/selectorUtils'
import { generate } from 'short-uuid'
test.describe('Number input step', () => {
test('options should work', async ({ page }) => {
const typebotId = generate()
await createTypebots([
{
id: typebotId,
...parseDefaultBlockWithStep({
type: InputStepType.NUMBER,
options: defaultNumberInputOptions,
}),
},
])
await page.goto(`/typebots/${typebotId}/edit`)
await page.click('text=Preview')
await expect(
typebotViewer(page).locator(
`input[placeholder="${defaultNumberInputOptions.labels.placeholder}"]`
)
).toHaveAttribute('type', 'number')
await expect(typebotViewer(page).locator(`button`)).toBeDisabled()
await page.click(`text=${defaultNumberInputOptions.labels.placeholder}`)
await page.fill('#placeholder', 'Your number...')
await expect(page.locator('text=Your number...')).toBeVisible()
await page.fill('#button', 'Go')
await page.fill('[role="spinbutton"] >> nth=0', '0')
await page.fill('[role="spinbutton"] >> nth=1', '100')
await page.fill('[role="spinbutton"] >> nth=2', '10')
await page.click('text=Restart')
const input = typebotViewer(page).locator(
`input[placeholder="Your number..."]`
)
await input.fill('-1')
await input.press('Enter')
await input.fill('150')
await input.press('Enter')
await input.fill('50')
await input.press('Enter')
await expect(typebotViewer(page).locator('text=50')).toBeVisible()
})
})