2022-01-28 09:42:31 +01:00
|
|
|
import test, { expect } from '@playwright/test'
|
2022-10-06 08:33:46 +02:00
|
|
|
import { createTypebots } from 'utils/playwright/databaseActions'
|
|
|
|
import { parseDefaultGroupWithBlock } from 'utils/playwright/databaseHelpers'
|
2022-06-11 07:27:38 +02:00
|
|
|
import { defaultEmailInputOptions, InputBlockType } from 'models'
|
2022-10-06 08:33:46 +02:00
|
|
|
import { typebotViewer } from 'utils/playwright/testHelpers'
|
2022-03-18 12:30:42 +01:00
|
|
|
import cuid from 'cuid'
|
2022-01-28 09:42:31 +01:00
|
|
|
|
2022-06-11 07:27:38 +02:00
|
|
|
test.describe('Email input block', () => {
|
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,
|
2022-06-11 07:27:38 +02:00
|
|
|
...parseDefaultGroupWithBlock({
|
|
|
|
type: InputBlockType.EMAIL,
|
2022-01-28 09:42:31 +01:00
|
|
|
options: defaultEmailInputOptions,
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
])
|
|
|
|
|
|
|
|
await page.goto(`/typebots/${typebotId}/edit`)
|
|
|
|
|
|
|
|
await page.click('text=Preview')
|
|
|
|
await expect(
|
|
|
|
typebotViewer(page).locator(
|
|
|
|
`input[placeholder="${defaultEmailInputOptions.labels.placeholder}"]`
|
|
|
|
)
|
|
|
|
).toHaveAttribute('type', 'email')
|
|
|
|
await expect(typebotViewer(page).locator(`button`)).toBeDisabled()
|
|
|
|
|
|
|
|
await page.click(`text=${defaultEmailInputOptions.labels.placeholder}`)
|
2022-08-08 08:21:36 +02:00
|
|
|
await page.fill(
|
|
|
|
`input[value="${defaultEmailInputOptions.labels.placeholder}"]`,
|
|
|
|
'Your email...'
|
|
|
|
)
|
2022-01-28 09:42:31 +01:00
|
|
|
await expect(page.locator('text=Your email...')).toBeVisible()
|
|
|
|
await page.fill('#button', 'Go')
|
2022-02-10 10:25:38 +01:00
|
|
|
await page.fill(
|
|
|
|
`input[value="${defaultEmailInputOptions.retryMessageContent}"]`,
|
|
|
|
'Try again bro'
|
|
|
|
)
|
2022-01-28 09:42:31 +01:00
|
|
|
|
|
|
|
await page.click('text=Restart')
|
2022-02-10 10:25:38 +01:00
|
|
|
await typebotViewer(page)
|
|
|
|
.locator(`input[placeholder="Your email..."]`)
|
|
|
|
.fill('test@test')
|
|
|
|
await typebotViewer(page).locator('text=Go').click()
|
2022-01-28 09:42:31 +01:00
|
|
|
await expect(
|
2022-02-10 10:25:38 +01:00
|
|
|
typebotViewer(page).locator('text=Try again bro')
|
|
|
|
).toBeVisible()
|
|
|
|
await typebotViewer(page)
|
|
|
|
.locator(`input[placeholder="Your email..."]`)
|
|
|
|
.fill('test@test.com')
|
|
|
|
await typebotViewer(page).locator('text=Go').click()
|
|
|
|
await expect(
|
|
|
|
typebotViewer(page).locator('text=test@test.com')
|
2022-01-28 09:42:31 +01:00
|
|
|
).toBeVisible()
|
|
|
|
})
|
|
|
|
})
|