🐛 (limits) Fix storage limit trigger and e2e tests
This commit is contained in:
committed by
Baptiste Arnaud
parent
1e26703ad4
commit
30dff2d5d7
@@ -6,7 +6,7 @@ export const refreshUser = async () => {
|
||||
document.dispatchEvent(event)
|
||||
}
|
||||
|
||||
export const connectedAsOtherUser = async (page: Page) =>
|
||||
export const mockSessionResponsesToOtherUser = async (page: Page) =>
|
||||
page.route('/api/auth/session', (route) => {
|
||||
if (route.request().method() === 'GET') {
|
||||
return route.fulfill({
|
||||
|
||||
@@ -21,6 +21,7 @@ import { readFileSync } from 'fs'
|
||||
import { injectFakeResults } from 'utils'
|
||||
import { encrypt } from 'utils/api'
|
||||
import Stripe from 'stripe'
|
||||
import cuid from 'cuid'
|
||||
|
||||
const prisma = new PrismaClient()
|
||||
|
||||
@@ -28,7 +29,7 @@ const stripe = new Stripe(process.env.STRIPE_TEST_SECRET_KEY ?? '', {
|
||||
apiVersion: '2022-08-01',
|
||||
})
|
||||
|
||||
const userId = 'userId'
|
||||
export const userId = 'userId'
|
||||
const otherUserId = 'otherUserId'
|
||||
export const freeWorkspaceId = 'freeWorkspace'
|
||||
export const starterWorkspaceId = 'starterWorkspace'
|
||||
@@ -49,6 +50,12 @@ export const teardownDatabase = async () => {
|
||||
return prisma.webhook.deleteMany()
|
||||
}
|
||||
|
||||
export const deleteWorkspaces = async (workspaceIds: string[]) => {
|
||||
await prisma.workspace.deleteMany({
|
||||
where: { id: { in: workspaceIds } },
|
||||
})
|
||||
}
|
||||
|
||||
export const addSubscriptionToWorkspace = async (
|
||||
workspaceId: string,
|
||||
items: Stripe.SubscriptionCreateParams.Item[],
|
||||
@@ -90,12 +97,12 @@ export const addSubscriptionToWorkspace = async (
|
||||
}
|
||||
|
||||
export const setupDatabase = async () => {
|
||||
await createWorkspaces()
|
||||
await createUsers()
|
||||
return createCredentials()
|
||||
await setupWorkspaces()
|
||||
await setupUsers()
|
||||
return setupCredentials()
|
||||
}
|
||||
|
||||
export const createWorkspaces = async () =>
|
||||
export const setupWorkspaces = async () =>
|
||||
prisma.workspace.createMany({
|
||||
data: [
|
||||
{
|
||||
@@ -122,21 +129,27 @@ export const createWorkspaces = async () =>
|
||||
],
|
||||
})
|
||||
|
||||
export const createWorkspace = async (workspace: Partial<Workspace>) => {
|
||||
const { id: workspaceId } = await prisma.workspace.create({
|
||||
data: {
|
||||
export const createWorkspaces = async (workspaces: Partial<Workspace>[]) => {
|
||||
const workspaceIds = workspaces.map((workspace) => workspace.id ?? cuid())
|
||||
await prisma.workspace.createMany({
|
||||
data: workspaces.map((workspace, index) => ({
|
||||
id: workspaceIds[index],
|
||||
name: 'Free workspace',
|
||||
plan: Plan.FREE,
|
||||
...workspace,
|
||||
},
|
||||
})),
|
||||
})
|
||||
await prisma.memberInWorkspace.create({
|
||||
data: { userId, workspaceId, role: WorkspaceRole.ADMIN },
|
||||
await prisma.memberInWorkspace.createMany({
|
||||
data: workspaces.map((_, index) => ({
|
||||
userId,
|
||||
workspaceId: workspaceIds[index],
|
||||
role: WorkspaceRole.ADMIN,
|
||||
})),
|
||||
})
|
||||
return workspaceId
|
||||
return workspaceIds
|
||||
}
|
||||
|
||||
export const createUsers = async () => {
|
||||
export const setupUsers = async () => {
|
||||
await prisma.user.create({
|
||||
data: {
|
||||
id: userId,
|
||||
@@ -237,7 +250,7 @@ export const createFolders = (partialFolders: Partial<DashboardFolder>[]) =>
|
||||
})),
|
||||
})
|
||||
|
||||
const createCredentials = () => {
|
||||
const setupCredentials = () => {
|
||||
const { encryptedData, iv } = encrypt({
|
||||
expiry_date: 1642441058842,
|
||||
access_token:
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import test, { expect } from '@playwright/test'
|
||||
import path from 'path'
|
||||
import { userId } from 'playwright/services/database'
|
||||
|
||||
test.describe.configure({ mode: 'parallel' })
|
||||
|
||||
test('should display user info properly', async ({ page }) => {
|
||||
await page.goto('/typebots')
|
||||
@@ -18,7 +21,7 @@ test('should display user info properly', async ({ page }) => {
|
||||
await expect(page.locator('img >> nth=1')).toHaveAttribute(
|
||||
'src',
|
||||
new RegExp(
|
||||
`http://localhost:9000/typebot/public/users/proUser/avatar`,
|
||||
`http://localhost:9000/typebot/public/users/${userId}/avatar`,
|
||||
'gm'
|
||||
)
|
||||
)
|
||||
|
||||
30
apps/builder/playwright/tests/analytics.spec.ts
Normal file
30
apps/builder/playwright/tests/analytics.spec.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import test, { expect } from '@playwright/test'
|
||||
import cuid from 'cuid'
|
||||
import path from 'path'
|
||||
import {
|
||||
importTypebotInDatabase,
|
||||
starterWorkspaceId,
|
||||
} from '../services/database'
|
||||
|
||||
test('analytics are not available for non-pro workspaces', async ({ page }) => {
|
||||
const typebotId = cuid()
|
||||
await importTypebotInDatabase(
|
||||
path.join(__dirname, '../fixtures/typebots/results/submissionHeader.json'),
|
||||
{
|
||||
id: typebotId,
|
||||
workspaceId: starterWorkspaceId,
|
||||
}
|
||||
)
|
||||
await page.goto(`/typebots/${typebotId}/results/analytics`)
|
||||
const firstDropoffBox = page.locator('text="%" >> nth=0')
|
||||
await firstDropoffBox.hover()
|
||||
await expect(
|
||||
page.locator('text="Unlock Drop-off rate by upgrading to Pro plan"')
|
||||
).toBeVisible()
|
||||
await firstDropoffBox.click()
|
||||
await expect(
|
||||
page.locator(
|
||||
'text="You need to upgrade your plan in order to unlock in-depth analytics"'
|
||||
)
|
||||
).toBeVisible()
|
||||
})
|
||||
@@ -5,13 +5,34 @@ import {
|
||||
addSubscriptionToWorkspace,
|
||||
createResults,
|
||||
createTypebots,
|
||||
createWorkspace,
|
||||
starterWorkspaceId,
|
||||
createWorkspaces,
|
||||
deleteWorkspaces,
|
||||
} from '../services/database'
|
||||
|
||||
const usageWorkspaceId = cuid()
|
||||
const usageTypebotId = cuid()
|
||||
const planChangeWorkspaceId = cuid()
|
||||
|
||||
test.beforeAll(async () => {
|
||||
await createWorkspaces([
|
||||
{
|
||||
id: usageWorkspaceId,
|
||||
name: 'Usage Workspace',
|
||||
plan: Plan.STARTER,
|
||||
},
|
||||
{
|
||||
id: planChangeWorkspaceId,
|
||||
name: 'Plan Change Workspace',
|
||||
},
|
||||
])
|
||||
await createTypebots([{ id: usageTypebotId, workspaceId: usageWorkspaceId }])
|
||||
})
|
||||
|
||||
test.afterAll(async () => {
|
||||
await deleteWorkspaces([usageWorkspaceId, planChangeWorkspaceId])
|
||||
})
|
||||
|
||||
test('should display valid usage', async ({ page }) => {
|
||||
const starterTypebotId = cuid()
|
||||
createTypebots([{ id: starterTypebotId, workspaceId: starterWorkspaceId }])
|
||||
await page.goto('/typebots')
|
||||
await page.click('text=Settings & Members')
|
||||
await page.click('text=Billing & Usage')
|
||||
@@ -24,37 +45,34 @@ test('should display valid usage', async ({ page }) => {
|
||||
await page.click('text=Settings & Members')
|
||||
await page.click('text=Billing & Usage')
|
||||
await expect(page.locator('text="/ 300"')).toBeVisible()
|
||||
await expect(page.locator('text="Storage"')).toBeHidden()
|
||||
await page.click('text=Free workspace', { force: true })
|
||||
|
||||
await createResults({
|
||||
idPrefix: 'usage',
|
||||
count: 10,
|
||||
typebotId: starterTypebotId,
|
||||
isChronological: false,
|
||||
typebotId: usageTypebotId,
|
||||
fakeStorage: 1100 * 1024 * 1024,
|
||||
})
|
||||
await page.click('text=Free workspace')
|
||||
await page.click('text="Starter workspace"')
|
||||
await page.click('text="Usage Workspace"')
|
||||
await page.click('text=Settings & Members')
|
||||
await page.click('text=Billing & Usage')
|
||||
await expect(page.locator('text="/ 2,000"')).toBeVisible()
|
||||
await expect(page.locator('text="/ 2 GB"')).toBeVisible()
|
||||
await expect(page.locator('text="1.07 GB"')).toBeVisible()
|
||||
await expect(page.locator('text="200"')).toBeVisible()
|
||||
await expect(page.locator('text="10" >> nth=0')).toBeVisible()
|
||||
await expect(page.locator('[role="progressbar"] >> nth=0')).toHaveAttribute(
|
||||
'aria-valuenow',
|
||||
'10'
|
||||
'1'
|
||||
)
|
||||
await expect(page.locator('text="1.07 GB"')).toBeVisible()
|
||||
await expect(page.locator('[role="progressbar"] >> nth=1')).toHaveAttribute(
|
||||
'aria-valuenow',
|
||||
'54'
|
||||
)
|
||||
|
||||
await createResults({
|
||||
idPrefix: 'usage2',
|
||||
typebotId: starterTypebotId,
|
||||
isChronological: false,
|
||||
count: 900,
|
||||
typebotId: usageTypebotId,
|
||||
count: 1090,
|
||||
fakeStorage: 1200 * 1024 * 1024,
|
||||
})
|
||||
await page.click('text="Settings"')
|
||||
@@ -68,12 +86,11 @@ test('should display valid usage', async ({ page }) => {
|
||||
})
|
||||
|
||||
test('plan changes should work', async ({ page }) => {
|
||||
const workspaceId = await createWorkspace({ name: 'Awesome workspace' })
|
||||
|
||||
test.setTimeout(80000)
|
||||
// Upgrade to STARTER
|
||||
await page.goto('/typebots')
|
||||
await page.click('text=Pro workspace')
|
||||
await page.click('text=Awesome workspace')
|
||||
await page.click('text=Plan Change Workspace')
|
||||
await page.click('text=Settings & Members')
|
||||
await page.click('text=Billing & Usage')
|
||||
await page.click('button >> text="2,000"')
|
||||
@@ -89,7 +106,7 @@ test('plan changes should work', async ({ page }) => {
|
||||
await expect(page.locator('text=$4.00 >> nth=0')).toBeVisible()
|
||||
await expect(page.locator('text=user@email.com')).toBeVisible()
|
||||
await addSubscriptionToWorkspace(
|
||||
workspaceId,
|
||||
planChangeWorkspaceId,
|
||||
[
|
||||
{
|
||||
price: process.env.STRIPE_STARTER_PRICE_ID,
|
||||
@@ -148,26 +165,23 @@ test('plan changes should work', async ({ page }) => {
|
||||
await page.goto('/typebots')
|
||||
await page.click('text=Settings & Members')
|
||||
await page.click('text=Billing & Usage')
|
||||
await expect(page.locator('[data-testid="plan-tag"]')).toHaveText('Pro')
|
||||
await expect(page.locator('[data-testid="pro-plan-tag"]')).toBeVisible()
|
||||
await page.click('button >> text="Cancel my subscription"')
|
||||
await expect(page.locator('[data-testid="plan-tag"]')).toHaveText('Free')
|
||||
await expect(page.locator('[data-testid="free-plan-tag"]')).toBeVisible()
|
||||
})
|
||||
|
||||
test('should display invoices', async ({ page }) => {
|
||||
await page.goto('/typebots')
|
||||
await page.click('text=Settings & Members')
|
||||
await page.click('text=Billing & Usage')
|
||||
await expect(
|
||||
page.locator('text="No invoices found for this workspace."')
|
||||
).toBeVisible()
|
||||
await expect(page.locator('text="Invoices"')).toBeHidden()
|
||||
await page.click('text=Pro workspace', { force: true })
|
||||
|
||||
await page.click('text=Pro workspace')
|
||||
await page.click('text=Starter workspace')
|
||||
await page.click('text=Plan Change Workspace')
|
||||
await page.click('text=Settings & Members')
|
||||
await page.click('text=Billing & Usage')
|
||||
await expect(page.locator('text="Invoices"')).toBeVisible()
|
||||
await expect(page.locator('text="Wed Jun 01 2022"')).toBeVisible()
|
||||
await expect(page.locator('text="74567541-0001"')).toBeVisible()
|
||||
await expect(page.locator('text="€30.00" >> nth=0')).toBeVisible()
|
||||
await expect(page.locator('tr')).toHaveCount(2)
|
||||
await expect(page.locator('text="€39.00"')).toBeVisible()
|
||||
})
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
createResults,
|
||||
createTypebots,
|
||||
parseDefaultGroupWithBlock,
|
||||
userId,
|
||||
} from '../services/database'
|
||||
|
||||
test.describe('Typebot owner', () => {
|
||||
@@ -21,7 +22,7 @@ test.describe('Typebot owner', () => {
|
||||
plan: Plan.FREE,
|
||||
members: {
|
||||
createMany: {
|
||||
data: [{ role: WorkspaceRole.ADMIN, userId: 'proUser' }],
|
||||
data: [{ role: WorkspaceRole.ADMIN, userId }],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -51,20 +52,20 @@ test.describe('Typebot owner', () => {
|
||||
await expect(page.locator('text=Free user')).toBeHidden()
|
||||
await page.fill(
|
||||
'input[placeholder="colleague@company.com"]',
|
||||
'free-user@email.com'
|
||||
'other-user@email.com'
|
||||
)
|
||||
await page.click('text=Can edit')
|
||||
await page.click('text=Can view')
|
||||
await page.click('text=Invite')
|
||||
await expect(page.locator('text=Free user')).toBeVisible()
|
||||
await expect(page.locator('text=James Doe')).toBeVisible()
|
||||
await page.click('text="guest@email.com"')
|
||||
await page.click('text="Remove"')
|
||||
await expect(page.locator('text="guest@email.com"')).toBeHidden()
|
||||
})
|
||||
})
|
||||
|
||||
test.describe('Collaborator', () => {
|
||||
test('should display shared typebots', async ({ page }) => {
|
||||
test.describe('Guest', () => {
|
||||
test('should have shared typebots displayed', async ({ page }) => {
|
||||
const typebotId = cuid()
|
||||
const guestWorkspaceId = cuid()
|
||||
await prisma.workspace.create({
|
||||
@@ -74,7 +75,7 @@ test.describe('Collaborator', () => {
|
||||
plan: Plan.FREE,
|
||||
members: {
|
||||
createMany: {
|
||||
data: [{ role: WorkspaceRole.GUEST, userId: 'proUser' }],
|
||||
data: [{ role: WorkspaceRole.GUEST, userId }],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -89,29 +90,34 @@ test.describe('Collaborator', () => {
|
||||
options: defaultTextInputOptions,
|
||||
}),
|
||||
},
|
||||
{
|
||||
name: 'Another typebot',
|
||||
workspaceId: guestWorkspaceId,
|
||||
},
|
||||
])
|
||||
await prisma.collaboratorsOnTypebots.create({
|
||||
data: {
|
||||
typebotId,
|
||||
userId: 'proUser',
|
||||
userId,
|
||||
type: CollaborationType.READ,
|
||||
},
|
||||
})
|
||||
await createFolder(guestWorkspaceId, 'Guest folder')
|
||||
await createResults({ typebotId, count: 10 })
|
||||
await page.goto(`/typebots`)
|
||||
await page.click("text=Pro user's workspace")
|
||||
await page.click('text=Pro workspace')
|
||||
await page.click('text=Guest workspace #2')
|
||||
await expect(page.locator('text=Guest typebot')).toBeVisible()
|
||||
await expect(page.locator('text=Another typebot')).toBeHidden()
|
||||
await expect(page.locator('text=Guest folder')).toBeHidden()
|
||||
await page.click('text=Guest typebot')
|
||||
await page.click('button[aria-label="Show collaboration menu"]')
|
||||
await page.click('text=Everyone at Guest workspace')
|
||||
await expect(page.locator('text="Remove"')).toBeHidden()
|
||||
await expect(page.locator('text=Pro user')).toBeVisible()
|
||||
await expect(page.locator('text=John Doe')).toBeVisible()
|
||||
await page.click('text=Group #1', { force: true })
|
||||
await expect(page.locator('input[value="Group #1"]')).toBeHidden()
|
||||
await page.goto(`/typebots/${typebotId}/results`)
|
||||
await expect(page.locator('text="See logs" >> nth=10')).toBeVisible()
|
||||
await expect(page.locator('text="See logs" >> nth=9')).toBeVisible()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -59,6 +59,10 @@ test.describe('Starter workspace', () => {
|
||||
await page.goto(`/typebots/${typebotId}/share`)
|
||||
await expect(page.locator('text=Pro')).toBeVisible()
|
||||
await page.click('text=Add my domain')
|
||||
await expect(page.locator('text=For solo creator')).toBeVisible()
|
||||
await expect(
|
||||
page.locator(
|
||||
'text="You need to upgrade your plan in order to add custom domains"'
|
||||
)
|
||||
).toBeVisible()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,88 +1,87 @@
|
||||
import test, { expect, Page } from '@playwright/test'
|
||||
import cuid from 'cuid'
|
||||
import path from 'path'
|
||||
import { createFolders, createTypebots } from '../services/database'
|
||||
import { deleteButtonInConfirmDialog } from '../services/selectorUtils'
|
||||
|
||||
test.describe('Dashboard page', () => {
|
||||
test('folders navigation should work', async ({ page }) => {
|
||||
test('folders navigation should work', async ({ page }) => {
|
||||
await page.goto('/typebots')
|
||||
const createFolderButton = page.locator('button:has-text("Create a folder")')
|
||||
await expect(createFolderButton).not.toBeDisabled()
|
||||
await createFolderButton.click()
|
||||
await page.click('text="New folder"')
|
||||
await page.fill('input[value="New folder"]', 'My folder #1')
|
||||
await page.press('input[value="My folder #1"]', 'Enter')
|
||||
await waitForNextApiCall(page)
|
||||
await page.click('li:has-text("My folder #1")')
|
||||
await expect(page.locator('h1:has-text("My folder #1")')).toBeVisible()
|
||||
await createFolderButton.click()
|
||||
await page.click('text="New folder"')
|
||||
await page.fill('input', 'My folder #2')
|
||||
await page.press('input', 'Enter')
|
||||
await waitForNextApiCall(page)
|
||||
|
||||
await page.click('li:has-text("My folder #2")')
|
||||
await expect(page.locator('h1 >> text="My folder #2"')).toBeVisible()
|
||||
|
||||
await page.click('text="Back"')
|
||||
await expect(page.locator('span >> text="My folder #2"')).toBeVisible()
|
||||
|
||||
await page.click('text="Back"')
|
||||
await expect(page.locator('span >> text=My folder #1')).toBeVisible()
|
||||
})
|
||||
|
||||
test('folders and typebots should be deletable', async ({ page }) => {
|
||||
await createFolders([{ name: 'Folder #1' }, { name: 'Folder #2' }])
|
||||
await createTypebots([{ id: 'deletable-typebot', name: 'Typebot #1' }])
|
||||
await page.goto('/typebots')
|
||||
await page.click('button[aria-label="Show Folder #1 menu"]')
|
||||
await page.click('li:has-text("Folder #1") >> button:has-text("Delete")')
|
||||
await deleteButtonInConfirmDialog(page).click()
|
||||
await expect(page.locator('span >> text="Folder #1"')).not.toBeVisible()
|
||||
await page.click('button[aria-label="Show Typebot #1 menu"]')
|
||||
await page.click('li:has-text("Typebot #1") >> button:has-text("Delete")')
|
||||
await deleteButtonInConfirmDialog(page).click()
|
||||
await expect(page.locator('span >> text="Typebot #1"')).not.toBeVisible()
|
||||
})
|
||||
|
||||
test('folders and typebots should be movable', async ({ page }) => {
|
||||
const droppableFolderId = cuid()
|
||||
await createFolders([{ id: droppableFolderId, name: 'Droppable folder' }])
|
||||
await createTypebots([{ name: 'Draggable typebot' }])
|
||||
await page.goto('/typebots')
|
||||
const typebotButton = page.locator('li:has-text("Draggable typebot")')
|
||||
const folderButton = page.locator('li:has-text("Droppable folder")')
|
||||
await page.dragAndDrop(
|
||||
'li:has-text("Draggable typebot")',
|
||||
'li:has-text("Droppable folder")'
|
||||
)
|
||||
await waitForNextApiCall(page)
|
||||
await expect(typebotButton).toBeHidden()
|
||||
await folderButton.click()
|
||||
await expect(page).toHaveURL(new RegExp(`/folders/${droppableFolderId}`))
|
||||
await expect(typebotButton).toBeVisible()
|
||||
await page.dragAndDrop(
|
||||
'li:has-text("Draggable typebot")',
|
||||
'a:has-text("Back")'
|
||||
)
|
||||
await waitForNextApiCall(page)
|
||||
await expect(typebotButton).toBeHidden()
|
||||
await page.click('a:has-text("Back")')
|
||||
await expect(typebotButton).toBeVisible()
|
||||
})
|
||||
|
||||
test.describe('Free user', () => {
|
||||
test("create folder shouldn't be available", async ({ page }) => {
|
||||
await page.goto('/typebots')
|
||||
const createFolderButton = page.locator(
|
||||
'button:has-text("Create a folder")'
|
||||
)
|
||||
await expect(createFolderButton).not.toBeDisabled()
|
||||
await createFolderButton.click()
|
||||
await page.click('text="New folder"')
|
||||
await page.fill('input[value="New folder"]', 'My folder #1')
|
||||
await page.press('input[value="My folder #1"]', 'Enter')
|
||||
await waitForNextApiCall(page)
|
||||
await page.click('li:has-text("My folder #1")')
|
||||
await expect(page.locator('h1:has-text("My folder #1")')).toBeVisible()
|
||||
await createFolderButton.click()
|
||||
await page.click('text="New folder"')
|
||||
await page.fill('input', 'My folder #2')
|
||||
await page.press('input', 'Enter')
|
||||
await waitForNextApiCall(page)
|
||||
|
||||
await page.click('li:has-text("My folder #2")')
|
||||
await expect(page.locator('h1 >> text="My folder #2"')).toBeVisible()
|
||||
|
||||
await page.click('text="Back"')
|
||||
await expect(page.locator('span >> text="My folder #2"')).toBeVisible()
|
||||
|
||||
await page.click('text="Back"')
|
||||
await expect(page.locator('span >> text=My folder #1')).toBeVisible()
|
||||
})
|
||||
|
||||
test('folders and typebots should be deletable', async ({ page }) => {
|
||||
await createFolders([{ name: 'Folder #1' }, { name: 'Folder #2' }])
|
||||
await createTypebots([{ id: 'deletable-typebot', name: 'Typebot #1' }])
|
||||
await page.goto('/typebots')
|
||||
await page.click('button[aria-label="Show Folder #1 menu"]')
|
||||
await page.click('li:has-text("Folder #1") >> button:has-text("Delete")')
|
||||
await deleteButtonInConfirmDialog(page).click()
|
||||
await expect(page.locator('span >> text="Folder #1"')).not.toBeVisible()
|
||||
await page.click('button[aria-label="Show Typebot #1 menu"]')
|
||||
await page.click('li:has-text("Typebot #1") >> button:has-text("Delete")')
|
||||
await deleteButtonInConfirmDialog(page).click()
|
||||
await expect(page.locator('span >> text="Typebot #1"')).not.toBeVisible()
|
||||
})
|
||||
|
||||
test('folders and typebots should be movable', async ({ page }) => {
|
||||
const droppableFolderId = cuid()
|
||||
await createFolders([{ id: droppableFolderId, name: 'Droppable folder' }])
|
||||
await createTypebots([{ name: 'Draggable typebot' }])
|
||||
await page.goto('/typebots')
|
||||
const typebotButton = page.locator('li:has-text("Draggable typebot")')
|
||||
const folderButton = page.locator('li:has-text("Droppable folder")')
|
||||
await page.dragAndDrop(
|
||||
'li:has-text("Draggable typebot")',
|
||||
'li:has-text("Droppable folder")'
|
||||
)
|
||||
await waitForNextApiCall(page)
|
||||
await expect(typebotButton).toBeHidden()
|
||||
await folderButton.click()
|
||||
await expect(page).toHaveURL(new RegExp(`/folders/${droppableFolderId}`))
|
||||
await expect(typebotButton).toBeVisible()
|
||||
await page.dragAndDrop(
|
||||
'li:has-text("Draggable typebot")',
|
||||
'a:has-text("Back")'
|
||||
)
|
||||
await waitForNextApiCall(page)
|
||||
await expect(typebotButton).toBeHidden()
|
||||
await page.click('a:has-text("Back")')
|
||||
await expect(typebotButton).toBeVisible()
|
||||
})
|
||||
|
||||
test.describe('Free user', () => {
|
||||
test.use({
|
||||
storageState: path.join(__dirname, '../secondUser.json'),
|
||||
})
|
||||
test("create folder shouldn't be available", async ({ page }) => {
|
||||
await page.goto('/typebots')
|
||||
await page.click('text=Create a folder')
|
||||
await expect(page.locator('text=For solo creator')).toBeVisible()
|
||||
})
|
||||
await page.click('text="Pro workspace"')
|
||||
await page.click('text="Free workspace"')
|
||||
await expect(page.locator('[data-testid="starter-plan-tag"]')).toBeVisible()
|
||||
await page.click('text=Create a folder')
|
||||
await expect(
|
||||
page.locator(
|
||||
'text="You need to upgrade your plan in order to create folders"'
|
||||
)
|
||||
).toBeVisible()
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -9,174 +9,174 @@ import path from 'path'
|
||||
import cuid from 'cuid'
|
||||
import { typebotViewer } from '../services/selectorUtils'
|
||||
|
||||
test.describe.parallel('Editor', () => {
|
||||
test('Edges connection should work', async ({ page }) => {
|
||||
const typebotId = cuid()
|
||||
await createTypebots([
|
||||
{
|
||||
id: typebotId,
|
||||
},
|
||||
])
|
||||
await page.goto(`/typebots/${typebotId}/edit`)
|
||||
await expect(page.locator("text='Start'")).toBeVisible()
|
||||
await page.dragAndDrop('text=Button', '#editor-container', {
|
||||
targetPosition: { x: 1000, y: 400 },
|
||||
})
|
||||
await page.dragAndDrop(
|
||||
'text=Text >> nth=0',
|
||||
'[data-testid="group"] >> nth=1',
|
||||
{
|
||||
targetPosition: { x: 100, y: 50 },
|
||||
}
|
||||
)
|
||||
await page.dragAndDrop(
|
||||
'[data-testid="endpoint"]',
|
||||
'[data-testid="group"] >> nth=1',
|
||||
{ targetPosition: { x: 100, y: 10 } }
|
||||
)
|
||||
await expect(page.locator('[data-testid="edge"]')).toBeVisible()
|
||||
await page.dragAndDrop(
|
||||
'[data-testid="endpoint"]',
|
||||
'[data-testid="group"] >> nth=1'
|
||||
)
|
||||
await expect(page.locator('[data-testid="edge"]')).toBeVisible()
|
||||
await page.dragAndDrop('text=Date', '#editor-container', {
|
||||
targetPosition: { x: 1000, y: 800 },
|
||||
})
|
||||
await page.dragAndDrop(
|
||||
'[data-testid="endpoint"] >> nth=2',
|
||||
'[data-testid="group"] >> nth=2',
|
||||
{
|
||||
targetPosition: { x: 100, y: 10 },
|
||||
}
|
||||
)
|
||||
await expect(page.locator('[data-testid="edge"] >> nth=0')).toBeVisible()
|
||||
await expect(page.locator('[data-testid="edge"] >> nth=1')).toBeVisible()
|
||||
test.describe.configure({ mode: 'parallel' })
|
||||
|
||||
await page.click('[data-testid="clickable-edge"] >> nth=0', {
|
||||
force: true,
|
||||
button: 'right',
|
||||
})
|
||||
await page.click('text=Delete')
|
||||
const total = await page.locator('[data-testid="edge"]').count()
|
||||
expect(total).toBe(1)
|
||||
test('Edges connection should work', async ({ page }) => {
|
||||
const typebotId = cuid()
|
||||
await createTypebots([
|
||||
{
|
||||
id: typebotId,
|
||||
},
|
||||
])
|
||||
await page.goto(`/typebots/${typebotId}/edit`)
|
||||
await expect(page.locator("text='Start'")).toBeVisible()
|
||||
await page.dragAndDrop('text=Button', '#editor-container', {
|
||||
targetPosition: { x: 1000, y: 400 },
|
||||
})
|
||||
test('Drag and drop blocks and items should work', async ({ page }) => {
|
||||
const typebotId = cuid()
|
||||
await importTypebotInDatabase(
|
||||
path.join(__dirname, '../fixtures/typebots/editor/buttonsDnd.json'),
|
||||
{
|
||||
id: typebotId,
|
||||
}
|
||||
)
|
||||
|
||||
// Blocks dnd
|
||||
await page.goto(`/typebots/${typebotId}/edit`)
|
||||
await expect(page.locator('[data-testid="block"] >> nth=1')).toHaveText(
|
||||
'Hello!'
|
||||
)
|
||||
await page.dragAndDrop('text=Hello', '[data-testid="block"] >> nth=3', {
|
||||
targetPosition: { x: 100, y: 0 },
|
||||
})
|
||||
await expect(page.locator('[data-testid="block"] >> nth=2')).toHaveText(
|
||||
'Hello!'
|
||||
)
|
||||
await page.dragAndDrop('text=Hello', 'text=Group #2')
|
||||
await expect(page.locator('[data-testid="block"] >> nth=3')).toHaveText(
|
||||
'Hello!'
|
||||
)
|
||||
|
||||
// Items dnd
|
||||
await expect(page.locator('[data-testid="item"] >> nth=0')).toHaveText(
|
||||
'Item 1'
|
||||
)
|
||||
await page.dragAndDrop('text=Item 1', 'text=Item 3')
|
||||
await expect(page.locator('[data-testid="item"] >> nth=2')).toHaveText(
|
||||
'Item 1'
|
||||
)
|
||||
await expect(page.locator('[data-testid="item"] >> nth=1')).toHaveText(
|
||||
'Item 3'
|
||||
)
|
||||
await page.dragAndDrop('text=Item 3', 'text=Item 2-3')
|
||||
await expect(page.locator('[data-testid="item"] >> nth=6')).toHaveText(
|
||||
'Item 3'
|
||||
)
|
||||
await page.dragAndDrop(
|
||||
'text=Text >> nth=0',
|
||||
'[data-testid="group"] >> nth=1',
|
||||
{
|
||||
targetPosition: { x: 100, y: 50 },
|
||||
}
|
||||
)
|
||||
await page.dragAndDrop(
|
||||
'[data-testid="endpoint"]',
|
||||
'[data-testid="group"] >> nth=1',
|
||||
{ targetPosition: { x: 100, y: 10 } }
|
||||
)
|
||||
await expect(page.locator('[data-testid="edge"]')).toBeVisible()
|
||||
await page.dragAndDrop(
|
||||
'[data-testid="endpoint"]',
|
||||
'[data-testid="group"] >> nth=1'
|
||||
)
|
||||
await expect(page.locator('[data-testid="edge"]')).toBeVisible()
|
||||
await page.dragAndDrop('text=Date', '#editor-container', {
|
||||
targetPosition: { x: 1000, y: 800 },
|
||||
})
|
||||
test('Undo / Redo buttons should work', async ({ page }) => {
|
||||
const typebotId = cuid()
|
||||
await createTypebots([
|
||||
{
|
||||
id: typebotId,
|
||||
...parseDefaultGroupWithBlock({
|
||||
type: InputBlockType.TEXT,
|
||||
options: defaultTextInputOptions,
|
||||
}),
|
||||
},
|
||||
])
|
||||
await page.dragAndDrop(
|
||||
'[data-testid="endpoint"] >> nth=2',
|
||||
'[data-testid="group"] >> nth=2',
|
||||
{
|
||||
targetPosition: { x: 100, y: 10 },
|
||||
}
|
||||
)
|
||||
await expect(page.locator('[data-testid="edge"] >> nth=0')).toBeVisible()
|
||||
await expect(page.locator('[data-testid="edge"] >> nth=1')).toBeVisible()
|
||||
|
||||
await page.goto(`/typebots/${typebotId}/edit`)
|
||||
await page.click('text=Group #1', { button: 'right' })
|
||||
await page.click('text=Duplicate')
|
||||
await expect(page.locator('text="Group #1"')).toBeVisible()
|
||||
await expect(page.locator('text="Group #1 copy"')).toBeVisible()
|
||||
await page.click('text="Group #1"', { button: 'right' })
|
||||
await page.click('text=Delete')
|
||||
await expect(page.locator('text="Group #1"')).toBeHidden()
|
||||
await page.click('button[aria-label="Undo"]')
|
||||
await expect(page.locator('text="Group #1"')).toBeVisible()
|
||||
await page.click('button[aria-label="Redo"]')
|
||||
await expect(page.locator('text="Group #1"')).toBeHidden()
|
||||
})
|
||||
|
||||
test('Rename and icon change should work', async ({ page }) => {
|
||||
const typebotId = cuid()
|
||||
await createTypebots([
|
||||
{
|
||||
id: typebotId,
|
||||
name: 'My awesome typebot',
|
||||
...parseDefaultGroupWithBlock({
|
||||
type: InputBlockType.TEXT,
|
||||
options: defaultTextInputOptions,
|
||||
}),
|
||||
},
|
||||
])
|
||||
|
||||
await page.goto(`/typebots/${typebotId}/edit`)
|
||||
|
||||
await page.click('[data-testid="editable-icon"]')
|
||||
await expect(page.locator('text="My awesome typebot"')).toBeVisible()
|
||||
await page.fill('input[placeholder="Search..."]', 'love')
|
||||
await page.click('text="😍"')
|
||||
await page.click('text="My awesome typebot"')
|
||||
await page.fill('input[value="My awesome typebot"]', 'My superb typebot')
|
||||
await page.press('input[value="My superb typebot"]', 'Enter')
|
||||
await page.click('[aria-label="Navigate back"]')
|
||||
await expect(page.locator('text="😍"')).toBeVisible()
|
||||
await expect(page.locator('text="My superb typebot"')).toBeVisible()
|
||||
})
|
||||
|
||||
test('Preview from group should work', async ({ page }) => {
|
||||
const typebotId = cuid()
|
||||
await importTypebotInDatabase(
|
||||
path.join(__dirname, '../fixtures/typebots/editor/previewFromGroup.json'),
|
||||
{
|
||||
id: typebotId,
|
||||
}
|
||||
)
|
||||
|
||||
await page.goto(`/typebots/${typebotId}/edit`)
|
||||
await page.click('[aria-label="Preview bot from this group"] >> nth=1')
|
||||
await expect(
|
||||
typebotViewer(page).locator('text="Hello this is group 1"')
|
||||
).toBeVisible()
|
||||
await page.click('[aria-label="Preview bot from this group"] >> nth=2')
|
||||
await expect(
|
||||
typebotViewer(page).locator('text="Hello this is group 2"')
|
||||
).toBeVisible()
|
||||
await page.click('[aria-label="Close"]')
|
||||
await page.click('text="Preview"')
|
||||
await expect(
|
||||
typebotViewer(page).locator('text="Hello this is group 1"')
|
||||
).toBeVisible()
|
||||
await page.click('[data-testid="clickable-edge"] >> nth=0', {
|
||||
force: true,
|
||||
button: 'right',
|
||||
})
|
||||
await page.click('text=Delete')
|
||||
const total = await page.locator('[data-testid="edge"]').count()
|
||||
expect(total).toBe(1)
|
||||
})
|
||||
test('Drag and drop blocks and items should work', async ({ page }) => {
|
||||
const typebotId = cuid()
|
||||
await importTypebotInDatabase(
|
||||
path.join(__dirname, '../fixtures/typebots/editor/buttonsDnd.json'),
|
||||
{
|
||||
id: typebotId,
|
||||
}
|
||||
)
|
||||
|
||||
// Blocks dnd
|
||||
await page.goto(`/typebots/${typebotId}/edit`)
|
||||
await expect(page.locator('[data-testid="block"] >> nth=1')).toHaveText(
|
||||
'Hello!'
|
||||
)
|
||||
await page.dragAndDrop('text=Hello', '[data-testid="block"] >> nth=3', {
|
||||
targetPosition: { x: 100, y: 0 },
|
||||
})
|
||||
await expect(page.locator('[data-testid="block"] >> nth=2')).toHaveText(
|
||||
'Hello!'
|
||||
)
|
||||
await page.dragAndDrop('text=Hello', 'text=Group #2')
|
||||
await expect(page.locator('[data-testid="block"] >> nth=3')).toHaveText(
|
||||
'Hello!'
|
||||
)
|
||||
|
||||
// Items dnd
|
||||
await expect(page.locator('[data-testid="item"] >> nth=0')).toHaveText(
|
||||
'Item 1'
|
||||
)
|
||||
await page.dragAndDrop('text=Item 1', 'text=Item 3')
|
||||
await expect(page.locator('[data-testid="item"] >> nth=2')).toHaveText(
|
||||
'Item 1'
|
||||
)
|
||||
await expect(page.locator('[data-testid="item"] >> nth=1')).toHaveText(
|
||||
'Item 3'
|
||||
)
|
||||
await page.dragAndDrop('text=Item 3', 'text=Item 2-3')
|
||||
await expect(page.locator('[data-testid="item"] >> nth=6')).toHaveText(
|
||||
'Item 3'
|
||||
)
|
||||
})
|
||||
test('Undo / Redo buttons should work', async ({ page }) => {
|
||||
const typebotId = cuid()
|
||||
await createTypebots([
|
||||
{
|
||||
id: typebotId,
|
||||
...parseDefaultGroupWithBlock({
|
||||
type: InputBlockType.TEXT,
|
||||
options: defaultTextInputOptions,
|
||||
}),
|
||||
},
|
||||
])
|
||||
|
||||
await page.goto(`/typebots/${typebotId}/edit`)
|
||||
await page.click('text=Group #1', { button: 'right' })
|
||||
await page.click('text=Duplicate')
|
||||
await expect(page.locator('text="Group #1"')).toBeVisible()
|
||||
await expect(page.locator('text="Group #1 copy"')).toBeVisible()
|
||||
await page.click('text="Group #1"', { button: 'right' })
|
||||
await page.click('text=Delete')
|
||||
await expect(page.locator('text="Group #1"')).toBeHidden()
|
||||
await page.click('button[aria-label="Undo"]')
|
||||
await expect(page.locator('text="Group #1"')).toBeVisible()
|
||||
await page.click('button[aria-label="Redo"]')
|
||||
await expect(page.locator('text="Group #1"')).toBeHidden()
|
||||
})
|
||||
|
||||
test('Rename and icon change should work', async ({ page }) => {
|
||||
const typebotId = cuid()
|
||||
await createTypebots([
|
||||
{
|
||||
id: typebotId,
|
||||
name: 'My awesome typebot',
|
||||
...parseDefaultGroupWithBlock({
|
||||
type: InputBlockType.TEXT,
|
||||
options: defaultTextInputOptions,
|
||||
}),
|
||||
},
|
||||
])
|
||||
|
||||
await page.goto(`/typebots/${typebotId}/edit`)
|
||||
|
||||
await page.click('[data-testid="editable-icon"]')
|
||||
await expect(page.locator('text="My awesome typebot"')).toBeVisible()
|
||||
await page.fill('input[placeholder="Search..."]', 'love')
|
||||
await page.click('text="😍"')
|
||||
await page.click('text="My awesome typebot"')
|
||||
await page.fill('input[value="My awesome typebot"]', 'My superb typebot')
|
||||
await page.press('input[value="My superb typebot"]', 'Enter')
|
||||
await page.click('[aria-label="Navigate back"]')
|
||||
await expect(page.locator('text="😍"')).toBeVisible()
|
||||
await expect(page.locator('text="My superb typebot"')).toBeVisible()
|
||||
})
|
||||
|
||||
test('Preview from group should work', async ({ page }) => {
|
||||
const typebotId = cuid()
|
||||
await importTypebotInDatabase(
|
||||
path.join(__dirname, '../fixtures/typebots/editor/previewFromGroup.json'),
|
||||
{
|
||||
id: typebotId,
|
||||
}
|
||||
)
|
||||
|
||||
await page.goto(`/typebots/${typebotId}/edit`)
|
||||
await page.click('[aria-label="Preview bot from this group"] >> nth=1')
|
||||
await expect(
|
||||
typebotViewer(page).locator('text="Hello this is group 1"')
|
||||
).toBeVisible()
|
||||
await page.click('[aria-label="Preview bot from this group"] >> nth=2')
|
||||
await expect(
|
||||
typebotViewer(page).locator('text="Hello this is group 2"')
|
||||
).toBeVisible()
|
||||
await page.click('[aria-label="Close"]')
|
||||
await page.click('text="Preview"')
|
||||
await expect(
|
||||
typebotViewer(page).locator('text="Hello this is group 1"')
|
||||
).toBeVisible()
|
||||
})
|
||||
|
||||
@@ -62,7 +62,7 @@ test.describe('Payment input block', () => {
|
||||
await stripePaymentForm(page).locator(`[placeholder="CVC"]`).fill('240')
|
||||
await typebotViewer(page).locator(`text="Pay 30€"`).click()
|
||||
await expect(
|
||||
typebotViewer(page).locator(`text="Your card was declined."`)
|
||||
typebotViewer(page).locator(`text="Your card has been declined."`)
|
||||
).toBeVisible()
|
||||
await stripePaymentForm(page)
|
||||
.locator(`[placeholder="1234 1234 1234 1234"]`)
|
||||
|
||||
@@ -43,7 +43,7 @@ test('results should be deletable', async ({ page }) => {
|
||||
}),
|
||||
},
|
||||
])
|
||||
await createResults({ typebotId, count: 200 })
|
||||
await createResults({ typebotId, count: 200, isChronological: true })
|
||||
await page.goto(`/typebots/${typebotId}/results`)
|
||||
await selectFirstResults(page)
|
||||
await page.click('text="Delete"')
|
||||
@@ -67,7 +67,7 @@ test('submissions table should have infinite scroll', async ({ page }) => {
|
||||
tableWrapper.scrollTo(0, tableWrapper.scrollHeight)
|
||||
})
|
||||
|
||||
await createResults({ typebotId, count: 200 })
|
||||
await createResults({ typebotId, count: 200, isChronological: true })
|
||||
await page.goto(`/typebots/${typebotId}/results`)
|
||||
await expect(page.locator('text=content199')).toBeVisible()
|
||||
|
||||
|
||||
@@ -135,9 +135,13 @@ test.describe.parallel('Settings page', () => {
|
||||
typebotViewer(page).locator('text="What\'s your name?"')
|
||||
).toBeVisible()
|
||||
await page.click('button:has-text("General")')
|
||||
await expect(page.locator('text=Pro')).toBeVisible()
|
||||
await expect(page.locator('text=Starter')).toBeVisible()
|
||||
await page.click('text=Typebot.io branding')
|
||||
await expect(page.locator('text=For solo creator')).toBeVisible()
|
||||
await expect(
|
||||
page.locator(
|
||||
'text="You need to upgrade your plan in order to remove branding"'
|
||||
)
|
||||
).toBeVisible()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import test, { expect } from '@playwright/test'
|
||||
import cuid from 'cuid'
|
||||
import { defaultTextInputOptions, InputBlockType } from 'models'
|
||||
import { connectedAsOtherUser } from 'playwright/services/browser'
|
||||
import { mockSessionResponsesToOtherUser } from 'playwright/services/browser'
|
||||
import {
|
||||
createTypebots,
|
||||
parseDefaultGroupWithBlock,
|
||||
@@ -129,7 +129,7 @@ test('can manage members', async ({ page }) => {
|
||||
await page.click('button >> text="Remove"')
|
||||
await expect(page.locator('text="guest@email.com"')).toBeHidden()
|
||||
|
||||
await connectedAsOtherUser(page)
|
||||
await mockSessionResponsesToOtherUser(page)
|
||||
await page.goto('/typebots')
|
||||
await page.click('text=Settings & Members')
|
||||
await expect(page.locator('text="Settings"')).toBeHidden()
|
||||
|
||||
Reference in New Issue
Block a user