2022-01-28 09:42:31 +01:00
|
|
|
import test, { expect } from '@playwright/test'
|
2022-03-18 12:30:42 +01:00
|
|
|
import cuid from 'cuid'
|
2022-03-10 12:05:34 +01:00
|
|
|
import { defaultTextInputOptions } from 'models'
|
2022-01-28 09:42:31 +01:00
|
|
|
import path from 'path'
|
2022-10-06 08:33:46 +02:00
|
|
|
import { importTypebotInDatabase } from 'utils/playwright/databaseActions'
|
|
|
|
import { freeWorkspaceId } from 'utils/playwright/databaseSetup'
|
|
|
|
import { typebotViewer } from 'utils/playwright/testHelpers'
|
2022-01-28 09:42:31 +01:00
|
|
|
|
|
|
|
test.describe.parallel('Settings page', () => {
|
|
|
|
test.describe('General', () => {
|
|
|
|
test('should reflect change in real-time', async ({ page }) => {
|
2022-03-18 12:30:42 +01:00
|
|
|
const typebotId = cuid()
|
2022-01-28 09:42:31 +01:00
|
|
|
await importTypebotInDatabase(
|
2022-03-10 12:05:34 +01:00
|
|
|
path.join(__dirname, '../fixtures/typebots/settings.json'),
|
2022-01-28 09:42:31 +01:00
|
|
|
{
|
|
|
|
id: typebotId,
|
|
|
|
}
|
|
|
|
)
|
2022-03-10 12:05:34 +01:00
|
|
|
|
2022-01-28 09:42:31 +01:00
|
|
|
await page.goto(`/typebots/${typebotId}/settings`)
|
|
|
|
await expect(
|
|
|
|
typebotViewer(page).locator('a:has-text("Made with Typebot")')
|
|
|
|
).toHaveAttribute('href', 'https://www.typebot.io/?utm_source=litebadge')
|
2022-05-13 09:18:25 -07:00
|
|
|
await page.click('text="Typebot.io branding"')
|
2022-01-28 09:42:31 +01:00
|
|
|
await expect(
|
|
|
|
typebotViewer(page).locator('a:has-text("Made with Typebot")')
|
|
|
|
).toBeHidden()
|
2022-03-10 12:05:34 +01:00
|
|
|
|
2022-07-01 17:08:35 +02:00
|
|
|
await page.click('text="Remember session"')
|
2022-03-07 18:21:01 +01:00
|
|
|
await expect(
|
|
|
|
page.locator('input[type="checkbox"] >> nth=-1')
|
|
|
|
).toHaveAttribute('checked', '')
|
2022-03-10 12:05:34 +01:00
|
|
|
|
|
|
|
await expect(
|
|
|
|
typebotViewer(page).locator('input[value="Baptiste"]')
|
|
|
|
).toBeVisible()
|
|
|
|
await page.click('text=Prefill input')
|
|
|
|
await page.click('text=Theme')
|
|
|
|
await expect(
|
|
|
|
typebotViewer(page).locator(
|
|
|
|
`input[placeholder="${defaultTextInputOptions.labels.placeholder}"]`
|
|
|
|
)
|
|
|
|
).toHaveValue('')
|
2022-01-28 09:42:31 +01:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
test.describe('Typing emulation', () => {
|
|
|
|
test('should be fillable', async ({ page }) => {
|
2022-03-18 12:30:42 +01:00
|
|
|
const typebotId = cuid()
|
2022-01-28 09:42:31 +01:00
|
|
|
await importTypebotInDatabase(
|
2022-03-10 12:05:34 +01:00
|
|
|
path.join(__dirname, '../fixtures/typebots/settings.json'),
|
2022-01-28 09:42:31 +01:00
|
|
|
{
|
|
|
|
id: typebotId,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
await page.goto(`/typebots/${typebotId}/settings`)
|
2022-06-24 16:44:41 +02:00
|
|
|
await expect(
|
|
|
|
typebotViewer(page).locator('a:has-text("Made with Typebot")')
|
|
|
|
).toHaveAttribute('href', 'https://www.typebot.io/?utm_source=litebadge')
|
2022-01-28 09:42:31 +01:00
|
|
|
await page.click('button:has-text("Typing emulation")')
|
|
|
|
await page.fill('[data-testid="speed"] input', '350')
|
|
|
|
await page.fill('[data-testid="max-delay"] input', '1.5')
|
2022-05-13 09:18:25 -07:00
|
|
|
await page.click('text="Typing emulation" >> nth=-1')
|
2022-01-28 09:42:31 +01:00
|
|
|
await expect(page.locator('[data-testid="speed"]')).toBeHidden()
|
|
|
|
await expect(page.locator('[data-testid="max-delay"]')).toBeHidden()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
test.describe('Metadata', () => {
|
|
|
|
test('should be fillable', async ({ page }) => {
|
|
|
|
const favIconUrl = 'https://www.baptistearno.com/favicon.png'
|
|
|
|
const imageUrl = 'https://www.baptistearno.com/images/site-preview.png'
|
|
|
|
const typebotId = 'metadata-typebot'
|
|
|
|
await importTypebotInDatabase(
|
2022-03-10 12:05:34 +01:00
|
|
|
path.join(__dirname, '../fixtures/typebots/settings.json'),
|
2022-01-28 09:42:31 +01:00
|
|
|
{
|
|
|
|
id: typebotId,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
await page.goto(`/typebots/${typebotId}/settings`)
|
2022-06-12 17:34:33 +02:00
|
|
|
await expect(
|
|
|
|
typebotViewer(page).locator(
|
|
|
|
`input[placeholder="${defaultTextInputOptions.labels.placeholder}"]`
|
|
|
|
)
|
|
|
|
).toHaveValue('Baptiste')
|
2022-01-28 09:42:31 +01:00
|
|
|
await page.click('button:has-text("Metadata")')
|
|
|
|
|
|
|
|
// Fav icon
|
2022-04-21 10:33:16 -07:00
|
|
|
const favIconImg = page.locator('img >> nth=0')
|
2022-01-28 09:42:31 +01:00
|
|
|
await expect(favIconImg).toHaveAttribute('src', '/favicon.png')
|
|
|
|
await favIconImg.click()
|
|
|
|
await expect(page.locator('text=Giphy')).toBeHidden()
|
|
|
|
await page.click('button:has-text("Embed link")')
|
|
|
|
await page.fill(
|
|
|
|
'input[placeholder="Paste the image link..."]',
|
|
|
|
favIconUrl
|
|
|
|
)
|
|
|
|
await expect(favIconImg).toHaveAttribute('src', favIconUrl)
|
|
|
|
|
|
|
|
// Website image
|
2022-04-21 10:33:16 -07:00
|
|
|
const websiteImg = page.locator('img >> nth=1')
|
2022-01-28 09:42:31 +01:00
|
|
|
await expect(websiteImg).toHaveAttribute('src', '/viewer-preview.png')
|
2022-04-21 10:33:16 -07:00
|
|
|
await websiteImg.click({ position: { x: 0, y: 160 }, force: true })
|
2022-01-28 09:42:31 +01:00
|
|
|
await expect(page.locator('text=Giphy')).toBeHidden()
|
2022-04-21 10:33:16 -07:00
|
|
|
await page.click('button >> text="Embed link"')
|
2022-01-28 09:42:31 +01:00
|
|
|
await page.fill('input[placeholder="Paste the image link..."]', imageUrl)
|
|
|
|
await expect(websiteImg).toHaveAttribute('src', imageUrl)
|
|
|
|
|
|
|
|
// Title
|
|
|
|
await page.fill('input#title', 'Awesome typebot')
|
|
|
|
|
|
|
|
// Description
|
|
|
|
await page.fill('textarea#description', 'Lorem ipsum')
|
2022-04-21 10:33:16 -07:00
|
|
|
|
|
|
|
// Custom head code
|
|
|
|
await page.fill(
|
|
|
|
'div[contenteditable=true]',
|
|
|
|
'<script>Lorem ipsum</script>'
|
|
|
|
)
|
2022-01-28 09:42:31 +01:00
|
|
|
})
|
|
|
|
})
|
2022-02-13 07:09:22 +01:00
|
|
|
|
2022-09-17 16:37:33 +02:00
|
|
|
test.describe('Free workspace', () => {
|
2022-02-13 07:09:22 +01:00
|
|
|
test("can't remove branding", async ({ page }) => {
|
|
|
|
const typebotId = 'free-branding-typebot'
|
|
|
|
await importTypebotInDatabase(
|
2022-03-10 12:05:34 +01:00
|
|
|
path.join(__dirname, '../fixtures/typebots/settings.json'),
|
2022-02-13 07:09:22 +01:00
|
|
|
{
|
|
|
|
id: typebotId,
|
2022-06-22 07:36:11 +02:00
|
|
|
workspaceId: freeWorkspaceId,
|
2022-02-13 07:09:22 +01:00
|
|
|
}
|
|
|
|
)
|
|
|
|
await page.goto(`/typebots/${typebotId}/settings`)
|
2022-06-18 12:14:05 +02:00
|
|
|
await expect(
|
|
|
|
typebotViewer(page).locator('text="What\'s your name?"')
|
|
|
|
).toBeVisible()
|
2022-02-13 07:09:22 +01:00
|
|
|
await page.click('button:has-text("General")')
|
2022-10-01 08:36:49 +02:00
|
|
|
await expect(
|
|
|
|
page.locator('[data-testid="starter-lock-tag"]')
|
|
|
|
).toBeVisible()
|
2022-02-13 07:09:22 +01:00
|
|
|
await page.click('text=Typebot.io branding')
|
2022-09-24 08:58:23 +02:00
|
|
|
await expect(
|
|
|
|
page.locator(
|
|
|
|
'text="You need to upgrade your plan in order to remove branding"'
|
|
|
|
)
|
|
|
|
).toBeVisible()
|
2022-02-13 07:09:22 +01:00
|
|
|
})
|
|
|
|
})
|
2022-01-28 09:42:31 +01:00
|
|
|
})
|