✨ Introduce bot v2 in builder (#328)
Also, the new engine is the default for updated typebots for viewer Closes #211
This commit is contained in:
@ -2,7 +2,6 @@ import { getTestAsset } from '@/test/utils/playwright'
|
||||
import test, { expect } from '@playwright/test'
|
||||
import { createId } from '@paralleldrive/cuid2'
|
||||
import { importTypebotInDatabase } from 'utils/playwright/databaseActions'
|
||||
import { typebotViewer } from 'utils/playwright/testHelpers'
|
||||
|
||||
const hostAvatarUrl =
|
||||
'https://images.unsplash.com/photo-1535713875002-d1d0cf377fde?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1760&q=80'
|
||||
@ -13,30 +12,29 @@ test.describe.parallel('Theme page', () => {
|
||||
test.describe('General', () => {
|
||||
test('should reflect change in real-time', async ({ page }) => {
|
||||
const typebotId = createId()
|
||||
const chatContainer = typebotViewer(page).locator(
|
||||
'[data-testid="container"]'
|
||||
)
|
||||
await importTypebotInDatabase(getTestAsset('typebots/theme.json'), {
|
||||
id: typebotId,
|
||||
})
|
||||
await page.goto(`/typebots/${typebotId}/theme`)
|
||||
await expect(
|
||||
typebotViewer(page).locator('button >> text="Go"')
|
||||
).toBeVisible()
|
||||
await expect(page.locator('button >> text="Go"')).toBeVisible()
|
||||
|
||||
// Font
|
||||
await page.fill('input[type="text"]', 'Roboto Slab')
|
||||
await expect(chatContainer).toHaveCSS('font-family', '"Roboto Slab"')
|
||||
await expect(page.locator('.typebot-container')).toHaveCSS(
|
||||
'font-family',
|
||||
/"Roboto Slab"/
|
||||
)
|
||||
|
||||
// BG color
|
||||
await expect(chatContainer).toHaveCSS(
|
||||
await expect(page.locator('.typebot-container')).toHaveCSS(
|
||||
'background-color',
|
||||
'rgba(0, 0, 0, 0)'
|
||||
)
|
||||
await page.click('text=Color')
|
||||
await page.click('[aria-label="Pick a color"]')
|
||||
await page.waitForTimeout(100)
|
||||
await page.getByRole('button', { name: 'Pick a color' }).click()
|
||||
await page.fill('[aria-label="Color value"] >> nth=-1', '#2a9d8f')
|
||||
await expect(chatContainer).toHaveCSS(
|
||||
await expect(page.locator('.typebot-container')).toHaveCSS(
|
||||
'background-color',
|
||||
'rgb(42, 157, 143)'
|
||||
)
|
||||
@ -55,30 +53,26 @@ test.describe.parallel('Theme page', () => {
|
||||
}
|
||||
|
||||
await page.goto(`/typebots/${typebotId}/theme`)
|
||||
await expect(
|
||||
typebotViewer(page).locator('button >> text="Go"')
|
||||
).toBeVisible()
|
||||
await expect(page.locator('button >> text="Go"')).toBeVisible()
|
||||
await page.click('button:has-text("Chat")')
|
||||
|
||||
// Host avatar
|
||||
await expect(
|
||||
typebotViewer(page).locator('[data-testid="default-avatar"]')
|
||||
).toBeVisible()
|
||||
await expect(page.locator('[data-testid="default-avatar"]')).toBeVisible()
|
||||
await page.click('[data-testid="default-avatar"]')
|
||||
await page.click('button:has-text("Embed link")')
|
||||
await page.fill(
|
||||
'input[placeholder="Paste the image link..."]',
|
||||
hostAvatarUrl
|
||||
)
|
||||
await typebotViewer(page).locator('button >> text="Go"').click()
|
||||
await page.locator('button >> text="Go"').click()
|
||||
|
||||
await expect(typebotViewer(page).locator('img')).toHaveAttribute(
|
||||
await expect(page.locator('.typebot-container img')).toHaveAttribute(
|
||||
'src',
|
||||
hostAvatarUrl
|
||||
)
|
||||
await page.click('text=Bot avatar')
|
||||
|
||||
await expect(typebotViewer(page).locator('img')).toBeHidden()
|
||||
await expect(page.locator('.typebot-container img')).toBeHidden()
|
||||
|
||||
// Host bubbles
|
||||
await page.click(
|
||||
@ -89,9 +83,7 @@ test.describe.parallel('Theme page', () => {
|
||||
'[data-testid="host-bubbles-theme"] >> [aria-label="Pick a color"] >> nth=1'
|
||||
)
|
||||
await page.fill('input[value="#303235"]', '#ffffff')
|
||||
const hostBubble = typebotViewer(page).locator(
|
||||
'[data-testid="host-bubble"] >> nth=-1'
|
||||
)
|
||||
const hostBubble = page.locator('[data-testid="host-bubble"] >> nth=-1')
|
||||
await expect(hostBubble).toHaveCSS(
|
||||
'background-color',
|
||||
'rgb(42, 157, 143)'
|
||||
@ -107,7 +99,7 @@ test.describe.parallel('Theme page', () => {
|
||||
'[data-testid="buttons-theme"] >> [aria-label="Pick a color"] >> nth=1'
|
||||
)
|
||||
await page.fill('input[value="#FFFFFF"]', '#e9c46a')
|
||||
const button = typebotViewer(page).locator('[data-testid="button"]')
|
||||
const button = page.getByRole('button', { name: 'Go' })
|
||||
await expect(button).toHaveCSS('background-color', 'rgb(114, 9, 183)')
|
||||
await expect(button).toHaveCSS('color', 'rgb(233, 196, 106)')
|
||||
|
||||
@ -120,10 +112,8 @@ test.describe.parallel('Theme page', () => {
|
||||
'[data-testid="guest-bubbles-theme"] >> [aria-label="Pick a color"] >> nth=1'
|
||||
)
|
||||
await page.fill('input[value="#FFFFFF"]', '#264653')
|
||||
await typebotViewer(page).locator('button >> text="Go"').click()
|
||||
const guestBubble = typebotViewer(page).locator(
|
||||
'[data-testid="guest-bubble"] >> nth=-1'
|
||||
)
|
||||
await page.locator('button >> text="Go"').click()
|
||||
const guestBubble = page.locator('[data-testid="guest-bubble"] >> nth=-1')
|
||||
await expect(guestBubble).toHaveCSS(
|
||||
'background-color',
|
||||
'rgb(216, 243, 220)'
|
||||
@ -133,21 +123,20 @@ test.describe.parallel('Theme page', () => {
|
||||
// Guest avatar
|
||||
await page.click('text=User avatar')
|
||||
await expect(
|
||||
typebotViewer(page).locator('[data-testid="default-avatar"] >> nth=-1')
|
||||
page.locator('[data-testid="default-avatar"] >> nth=-1')
|
||||
).toBeVisible()
|
||||
await page.click('[data-testid="default-avatar"]')
|
||||
await page.click('button:has-text("Embed link")')
|
||||
await page.fill(
|
||||
'input[placeholder="Paste the image link..."]',
|
||||
guestAvatarUrl
|
||||
)
|
||||
|
||||
typebotViewer(page).locator('button >> text="Go"').click()
|
||||
await expect(typebotViewer(page).locator('img')).toHaveAttribute(
|
||||
await page
|
||||
.locator('input[placeholder="Paste the image link..."]')
|
||||
.fill(guestAvatarUrl)
|
||||
await page.locator('button >> text="Go"').click()
|
||||
await expect(page.locator('.typebot-container img')).toHaveAttribute(
|
||||
'src',
|
||||
guestAvatarUrl
|
||||
)
|
||||
|
||||
await page.waitForTimeout(1000)
|
||||
// Input
|
||||
await page.click(
|
||||
'[data-testid="inputs-theme"] >> [aria-label="Pick a color"] >> nth=0'
|
||||
@ -157,7 +146,7 @@ test.describe.parallel('Theme page', () => {
|
||||
'[data-testid="inputs-theme"] >> [aria-label="Pick a color"] >> nth=1'
|
||||
)
|
||||
await page.fill('input[value="#303235"]', '#023e8a')
|
||||
const input = typebotViewer(page).locator('.typebot-input')
|
||||
const input = page.locator('.typebot-input')
|
||||
await expect(input).toHaveCSS('background-color', 'rgb(255, 232, 214)')
|
||||
await expect(input).toHaveCSS('color', 'rgb(2, 62, 138)')
|
||||
})
|
||||
@ -170,17 +159,16 @@ test.describe.parallel('Theme page', () => {
|
||||
id: typebotId,
|
||||
})
|
||||
await page.goto(`/typebots/${typebotId}/theme`)
|
||||
await expect(
|
||||
typebotViewer(page).locator('button >> text="Go"')
|
||||
).toBeVisible()
|
||||
await expect(page.locator('button >> text="Go"')).toBeVisible()
|
||||
await page.click('button:has-text("Custom CSS")')
|
||||
await page.fill(
|
||||
'div[role="textbox"]',
|
||||
'.typebot-button {background-color: green}'
|
||||
)
|
||||
await expect(
|
||||
typebotViewer(page).locator('[data-testid="button"]')
|
||||
).toHaveCSS('background-color', 'rgb(0, 128, 0)')
|
||||
await expect(page.getByRole('button', { name: 'Go' })).toHaveCSS(
|
||||
'background-color',
|
||||
'rgb(0, 128, 0)'
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
Reference in New Issue
Block a user