2022-11-15 09:35:48 +01:00
|
|
|
import { getTestAsset } from '@/test/utils/playwright'
|
2022-01-28 09:42:31 +01:00
|
|
|
import test, { expect } from '@playwright/test'
|
2023-02-10 15:06:02 +01:00
|
|
|
import { createId } from '@paralleldrive/cuid2'
|
2023-03-15 08:35:16 +01:00
|
|
|
import { importTypebotInDatabase } from '@typebot.io/lib/playwright/databaseActions'
|
2022-01-28 09:42:31 +01:00
|
|
|
|
2022-02-16 15:08:50 +01:00
|
|
|
const hostAvatarUrl =
|
|
|
|
|
'https://images.unsplash.com/photo-1535713875002-d1d0cf377fde?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1760&q=80'
|
|
|
|
|
const guestAvatarUrl =
|
|
|
|
|
'https://images.unsplash.com/photo-1494790108377-be9c29b29330?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1287&q=80'
|
2023-03-22 14:45:10 +01:00
|
|
|
const backgroundImageUrl =
|
|
|
|
|
'https://images.unsplash.com/photo-1508739773434-c26b3d09e071?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2940&q=80'
|
2022-02-16 15:08:50 +01:00
|
|
|
|
2022-01-28 09:42:31 +01:00
|
|
|
test.describe.parallel('Theme page', () => {
|
|
|
|
|
test.describe('General', () => {
|
|
|
|
|
test('should reflect change in real-time', async ({ page }) => {
|
2023-02-10 15:06:02 +01:00
|
|
|
const typebotId = createId()
|
2022-11-15 09:35:48 +01:00
|
|
|
await importTypebotInDatabase(getTestAsset('typebots/theme.json'), {
|
|
|
|
|
id: typebotId,
|
|
|
|
|
})
|
2022-01-28 09:42:31 +01:00
|
|
|
await page.goto(`/typebots/${typebotId}/theme`)
|
2023-04-26 15:59:22 +02:00
|
|
|
await expect(page.getByRole('button', { name: 'Go' })).toBeVisible()
|
2022-01-28 09:42:31 +01:00
|
|
|
|
|
|
|
|
// Font
|
2023-03-28 15:10:06 +02:00
|
|
|
await page.getByRole('button', { name: 'Font & Background' }).click()
|
2023-03-03 09:01:11 +01:00
|
|
|
await page.getByRole('textbox').fill('Roboto Slab')
|
2023-02-21 15:25:14 +01:00
|
|
|
await expect(page.locator('.typebot-container')).toHaveCSS(
|
|
|
|
|
'font-family',
|
|
|
|
|
/"Roboto Slab"/
|
|
|
|
|
)
|
2022-01-28 09:42:31 +01:00
|
|
|
|
|
|
|
|
// BG color
|
2023-02-21 15:25:14 +01:00
|
|
|
await expect(page.locator('.typebot-container')).toHaveCSS(
|
2022-01-28 09:42:31 +01:00
|
|
|
'background-color',
|
|
|
|
|
'rgba(0, 0, 0, 0)'
|
|
|
|
|
)
|
|
|
|
|
await page.click('text=Color')
|
2023-02-21 15:25:14 +01:00
|
|
|
await page.waitForTimeout(100)
|
|
|
|
|
await page.getByRole('button', { name: 'Pick a color' }).click()
|
2022-02-04 19:00:08 +01:00
|
|
|
await page.fill('[aria-label="Color value"] >> nth=-1', '#2a9d8f')
|
2023-02-21 15:25:14 +01:00
|
|
|
await expect(page.locator('.typebot-container')).toHaveCSS(
|
2022-01-28 09:42:31 +01:00
|
|
|
'background-color',
|
|
|
|
|
'rgb(42, 157, 143)'
|
|
|
|
|
)
|
2023-03-22 14:45:10 +01:00
|
|
|
await page.click('text=Color')
|
|
|
|
|
|
|
|
|
|
await page.click('text="Image"')
|
|
|
|
|
await page.getByRole('button', { name: 'Select an image' }).click()
|
|
|
|
|
await page
|
|
|
|
|
.getByPlaceholder('Paste the image link...')
|
|
|
|
|
.fill(backgroundImageUrl)
|
|
|
|
|
await expect(
|
|
|
|
|
page.getByRole('img', { name: 'Background image' })
|
|
|
|
|
).toHaveAttribute('src', backgroundImageUrl)
|
|
|
|
|
await expect(page.locator('.typebot-container')).toHaveCSS(
|
|
|
|
|
'background-image',
|
|
|
|
|
`url("${backgroundImageUrl}")`
|
|
|
|
|
)
|
2022-01-28 09:42:31 +01:00
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test.describe('Chat', () => {
|
2022-02-17 10:46:04 +01:00
|
|
|
test('should reflect change in real-time', async ({ page }) => {
|
2022-01-28 09:42:31 +01:00
|
|
|
const typebotId = 'chat-theme-typebot'
|
2022-01-28 17:57:14 +01:00
|
|
|
try {
|
2022-11-15 09:35:48 +01:00
|
|
|
await importTypebotInDatabase(getTestAsset('typebots/theme.json'), {
|
|
|
|
|
id: typebotId,
|
|
|
|
|
})
|
2022-12-22 17:02:34 +01:00
|
|
|
} catch {
|
|
|
|
|
/* empty */
|
|
|
|
|
}
|
2022-01-28 17:57:14 +01:00
|
|
|
|
2022-01-28 09:42:31 +01:00
|
|
|
await page.goto(`/typebots/${typebotId}/theme`)
|
2023-04-26 15:59:22 +02:00
|
|
|
await expect(page.getByRole('button', { name: 'Go' })).toBeVisible()
|
2022-01-28 09:42:31 +01:00
|
|
|
await page.click('button:has-text("Chat")')
|
2022-02-16 15:08:50 +01:00
|
|
|
|
|
|
|
|
// Host avatar
|
2023-02-21 15:25:14 +01:00
|
|
|
await expect(page.locator('[data-testid="default-avatar"]')).toBeVisible()
|
2022-02-16 15:08:50 +01:00
|
|
|
await page.click('[data-testid="default-avatar"]')
|
2023-05-04 09:20:30 -04:00
|
|
|
await page.click('button:has-text("Link")')
|
2022-02-16 15:08:50 +01:00
|
|
|
await page.fill(
|
|
|
|
|
'input[placeholder="Paste the image link..."]',
|
|
|
|
|
hostAvatarUrl
|
|
|
|
|
)
|
2023-04-26 15:59:22 +02:00
|
|
|
await page.getByRole('button', { name: 'Go' }).click()
|
2022-06-26 16:12:28 +02:00
|
|
|
|
2023-02-21 15:25:14 +01:00
|
|
|
await expect(page.locator('.typebot-container img')).toHaveAttribute(
|
2022-02-16 15:08:50 +01:00
|
|
|
'src',
|
|
|
|
|
hostAvatarUrl
|
|
|
|
|
)
|
|
|
|
|
await page.click('text=Bot avatar')
|
2022-06-26 16:12:28 +02:00
|
|
|
|
2023-02-21 15:25:14 +01:00
|
|
|
await expect(page.locator('.typebot-container img')).toBeHidden()
|
2022-01-28 09:42:31 +01:00
|
|
|
|
2023-03-22 16:43:34 +01:00
|
|
|
// Roundness
|
|
|
|
|
await expect(page.getByRole('button', { name: 'Go' })).toHaveCSS(
|
|
|
|
|
'border-radius',
|
|
|
|
|
'6px'
|
|
|
|
|
)
|
|
|
|
|
await page
|
|
|
|
|
.getByRole('region', { name: 'Chat' })
|
|
|
|
|
.getByRole('radiogroup')
|
|
|
|
|
.locator('div')
|
|
|
|
|
.first()
|
|
|
|
|
.click()
|
|
|
|
|
await expect(page.getByRole('button', { name: 'Go' })).toHaveCSS(
|
|
|
|
|
'border-radius',
|
|
|
|
|
'0px'
|
|
|
|
|
)
|
|
|
|
|
await page
|
|
|
|
|
.getByRole('region', { name: 'Chat' })
|
|
|
|
|
.getByRole('radiogroup')
|
|
|
|
|
.locator('div')
|
|
|
|
|
.nth(2)
|
|
|
|
|
.click()
|
|
|
|
|
await expect(page.getByRole('button', { name: 'Go' })).toHaveCSS(
|
|
|
|
|
'border-radius',
|
|
|
|
|
'20px'
|
|
|
|
|
)
|
|
|
|
|
|
2022-01-28 09:42:31 +01:00
|
|
|
// Host bubbles
|
2022-02-04 19:00:08 +01:00
|
|
|
await page.click(
|
|
|
|
|
'[data-testid="host-bubbles-theme"] >> [aria-label="Pick a color"] >> nth=0'
|
|
|
|
|
)
|
|
|
|
|
await page.fill('input[value="#F7F8FF"]', '#2a9d8f')
|
|
|
|
|
await page.click(
|
|
|
|
|
'[data-testid="host-bubbles-theme"] >> [aria-label="Pick a color"] >> nth=1'
|
|
|
|
|
)
|
|
|
|
|
await page.fill('input[value="#303235"]', '#ffffff')
|
2023-02-21 15:25:14 +01:00
|
|
|
const hostBubble = page.locator('[data-testid="host-bubble"] >> nth=-1')
|
2022-01-28 09:42:31 +01:00
|
|
|
await expect(hostBubble).toHaveCSS(
|
|
|
|
|
'background-color',
|
|
|
|
|
'rgb(42, 157, 143)'
|
|
|
|
|
)
|
|
|
|
|
await expect(hostBubble).toHaveCSS('color', 'rgb(255, 255, 255)')
|
|
|
|
|
|
|
|
|
|
// Buttons
|
2022-02-04 19:00:08 +01:00
|
|
|
await page.click(
|
|
|
|
|
'[data-testid="buttons-theme"] >> [aria-label="Pick a color"] >> nth=0'
|
|
|
|
|
)
|
|
|
|
|
await page.fill('input[value="#0042DA"]', '#7209b7')
|
|
|
|
|
await page.click(
|
|
|
|
|
'[data-testid="buttons-theme"] >> [aria-label="Pick a color"] >> nth=1'
|
|
|
|
|
)
|
|
|
|
|
await page.fill('input[value="#FFFFFF"]', '#e9c46a')
|
2023-02-21 15:25:14 +01:00
|
|
|
const button = page.getByRole('button', { name: 'Go' })
|
2022-01-28 09:42:31 +01:00
|
|
|
await expect(button).toHaveCSS('background-color', 'rgb(114, 9, 183)')
|
|
|
|
|
await expect(button).toHaveCSS('color', 'rgb(233, 196, 106)')
|
|
|
|
|
|
|
|
|
|
// Guest bubbles
|
2022-02-04 19:00:08 +01:00
|
|
|
await page.click(
|
|
|
|
|
'[data-testid="guest-bubbles-theme"] >> [aria-label="Pick a color"] >> nth=0'
|
|
|
|
|
)
|
|
|
|
|
await page.fill('input[value="#FF8E21"]', '#d8f3dc')
|
|
|
|
|
await page.click(
|
|
|
|
|
'[data-testid="guest-bubbles-theme"] >> [aria-label="Pick a color"] >> nth=1'
|
|
|
|
|
)
|
|
|
|
|
await page.fill('input[value="#FFFFFF"]', '#264653')
|
2023-04-26 15:59:22 +02:00
|
|
|
await page.getByRole('button', { name: 'Go' }).click()
|
2023-02-21 15:25:14 +01:00
|
|
|
const guestBubble = page.locator('[data-testid="guest-bubble"] >> nth=-1')
|
2022-01-28 09:42:31 +01:00
|
|
|
await expect(guestBubble).toHaveCSS(
|
|
|
|
|
'background-color',
|
|
|
|
|
'rgb(216, 243, 220)'
|
|
|
|
|
)
|
|
|
|
|
await expect(guestBubble).toHaveCSS('color', 'rgb(38, 70, 83)')
|
|
|
|
|
|
2022-02-16 15:08:50 +01:00
|
|
|
// Guest avatar
|
|
|
|
|
await page.click('text=User avatar')
|
|
|
|
|
await expect(
|
2023-02-21 15:25:14 +01:00
|
|
|
page.locator('[data-testid="default-avatar"] >> nth=-1')
|
2022-02-16 15:08:50 +01:00
|
|
|
).toBeVisible()
|
|
|
|
|
await page.click('[data-testid="default-avatar"]')
|
2023-05-04 09:20:30 -04:00
|
|
|
await page.click('button:has-text("Link")')
|
2023-02-21 15:25:14 +01:00
|
|
|
await page
|
|
|
|
|
.locator('input[placeholder="Paste the image link..."]')
|
|
|
|
|
.fill(guestAvatarUrl)
|
2023-04-26 15:59:22 +02:00
|
|
|
await page.getByRole('button', { name: 'Go' }).click()
|
2023-02-21 15:25:14 +01:00
|
|
|
await expect(page.locator('.typebot-container img')).toHaveAttribute(
|
2022-02-16 15:08:50 +01:00
|
|
|
'src',
|
|
|
|
|
guestAvatarUrl
|
|
|
|
|
)
|
|
|
|
|
|
2023-02-21 15:25:14 +01:00
|
|
|
await page.waitForTimeout(1000)
|
2022-01-28 09:42:31 +01:00
|
|
|
// Input
|
2022-02-04 19:00:08 +01:00
|
|
|
await page.click(
|
|
|
|
|
'[data-testid="inputs-theme"] >> [aria-label="Pick a color"] >> nth=0'
|
|
|
|
|
)
|
|
|
|
|
await page.fill('input[value="#FFFFFF"]', '#ffe8d6')
|
|
|
|
|
await page.click(
|
|
|
|
|
'[data-testid="inputs-theme"] >> [aria-label="Pick a color"] >> nth=1'
|
|
|
|
|
)
|
|
|
|
|
await page.fill('input[value="#303235"]', '#023e8a')
|
2023-02-21 15:25:14 +01:00
|
|
|
const input = page.locator('.typebot-input')
|
2022-01-28 09:42:31 +01:00
|
|
|
await expect(input).toHaveCSS('background-color', 'rgb(255, 232, 214)')
|
|
|
|
|
await expect(input).toHaveCSS('color', 'rgb(2, 62, 138)')
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test.describe('Custom CSS', () => {
|
|
|
|
|
test('should reflect change in real-time', async ({ page }) => {
|
2023-02-10 15:06:02 +01:00
|
|
|
const typebotId = createId()
|
2022-11-15 09:35:48 +01:00
|
|
|
await importTypebotInDatabase(getTestAsset('typebots/theme.json'), {
|
|
|
|
|
id: typebotId,
|
|
|
|
|
})
|
2022-01-28 09:42:31 +01:00
|
|
|
await page.goto(`/typebots/${typebotId}/theme`)
|
2023-04-26 15:59:22 +02:00
|
|
|
await expect(page.getByRole('button', { name: 'Go' })).toBeVisible()
|
2022-01-28 09:42:31 +01:00
|
|
|
await page.click('button:has-text("Custom CSS")')
|
|
|
|
|
await page.fill(
|
|
|
|
|
'div[role="textbox"]',
|
|
|
|
|
'.typebot-button {background-color: green}'
|
|
|
|
|
)
|
2023-02-21 15:25:14 +01:00
|
|
|
await expect(page.getByRole('button', { name: 'Go' })).toHaveCSS(
|
|
|
|
|
'background-color',
|
|
|
|
|
'rgb(0, 128, 0)'
|
|
|
|
|
)
|
2022-01-28 09:42:31 +01:00
|
|
|
})
|
|
|
|
|
})
|
2023-03-28 15:10:06 +02:00
|
|
|
|
|
|
|
|
test.describe('Theme templates', () => {
|
|
|
|
|
test('should reflect change in real-time', async ({ page }) => {
|
|
|
|
|
const typebotId = createId()
|
|
|
|
|
await importTypebotInDatabase(getTestAsset('typebots/theme.json'), {
|
|
|
|
|
id: typebotId,
|
|
|
|
|
})
|
|
|
|
|
await page.goto(`/typebots/${typebotId}/theme`)
|
2023-04-26 15:59:22 +02:00
|
|
|
await expect(page.getByRole('button', { name: 'Go' })).toBeVisible()
|
2023-03-30 10:30:26 +02:00
|
|
|
await page.getByRole('button', { name: 'Templates New!' }).click()
|
2023-03-28 15:10:06 +02:00
|
|
|
await page.getByRole('button', { name: 'Save current theme' }).click()
|
|
|
|
|
await page.getByPlaceholder('My template').fill('My awesome theme')
|
|
|
|
|
await page.getByRole('button', { name: 'Save' }).click()
|
|
|
|
|
await page.getByRole('button', { name: 'Open template menu' }).click()
|
|
|
|
|
await page.getByRole('menuitem', { name: 'Rename' }).click()
|
|
|
|
|
await expect(page.getByPlaceholder('My template')).toHaveValue(
|
|
|
|
|
'My awesome theme'
|
|
|
|
|
)
|
|
|
|
|
await page.getByPlaceholder('My template').fill('My awesome theme 2')
|
|
|
|
|
await page.getByRole('button', { name: 'Save as new template' }).click()
|
|
|
|
|
await expect(
|
|
|
|
|
page.getByRole('button', { name: 'Open template menu' })
|
|
|
|
|
).toHaveCount(2)
|
|
|
|
|
await page
|
|
|
|
|
.getByRole('button', { name: 'Open template menu' })
|
|
|
|
|
.first()
|
|
|
|
|
.click()
|
|
|
|
|
await page.getByRole('menuitem', { name: 'Delete' }).click()
|
|
|
|
|
await expect(page.getByText('My awesome theme 2')).toBeHidden()
|
|
|
|
|
await page.getByRole('button', { name: 'Gallery' }).click()
|
|
|
|
|
await page.getByText('Typebot Dark').click()
|
|
|
|
|
await expect(page.getByTestId('host-bubble')).toHaveCSS(
|
|
|
|
|
'background-color',
|
|
|
|
|
'rgb(30, 41, 59)'
|
|
|
|
|
)
|
|
|
|
|
})
|
|
|
|
|
})
|
2022-01-28 09:42:31 +01:00
|
|
|
})
|