🐛 (usage) Archive typebot to be able to compute usage
This commit is contained in:
committed by
Baptiste Arnaud
parent
75ca255af2
commit
15dbc9577d
@@ -102,14 +102,16 @@ export const setupDatabase = async () => {
|
||||
return setupCredentials()
|
||||
}
|
||||
|
||||
export const setupWorkspaces = async () =>
|
||||
prisma.workspace.createMany({
|
||||
export const setupWorkspaces = async () => {
|
||||
await prisma.workspace.create({
|
||||
data: {
|
||||
id: freeWorkspaceId,
|
||||
name: 'Free workspace',
|
||||
plan: Plan.FREE,
|
||||
},
|
||||
})
|
||||
await prisma.workspace.createMany({
|
||||
data: [
|
||||
{
|
||||
id: freeWorkspaceId,
|
||||
name: 'Free workspace',
|
||||
plan: Plan.FREE,
|
||||
},
|
||||
{
|
||||
id: starterWorkspaceId,
|
||||
name: 'Starter workspace',
|
||||
@@ -128,6 +130,7 @@ export const setupWorkspaces = async () =>
|
||||
},
|
||||
],
|
||||
})
|
||||
}
|
||||
|
||||
export const createWorkspaces = async (workspaces: Partial<Workspace>[]) => {
|
||||
const workspaceIds = workspaces.map((workspace) => workspace.id ?? cuid())
|
||||
@@ -231,11 +234,15 @@ export const getSignedInUser = (email: string) =>
|
||||
prisma.user.findFirst({ where: { email } })
|
||||
|
||||
export const createTypebots = async (partialTypebots: Partial<Typebot>[]) => {
|
||||
const typebotsWithId = partialTypebots.map((typebot) => ({
|
||||
...typebot,
|
||||
id: typebot.id ?? cuid(),
|
||||
}))
|
||||
await prisma.typebot.createMany({
|
||||
data: partialTypebots.map(parseTestTypebot),
|
||||
data: typebotsWithId.map(parseTestTypebot),
|
||||
})
|
||||
return prisma.publicTypebot.createMany({
|
||||
data: partialTypebots.map((t) =>
|
||||
data: typebotsWithId.map((t) =>
|
||||
parseTypebotToPublicTypebot(t.id + '-public', parseTestTypebot(t))
|
||||
),
|
||||
})
|
||||
@@ -304,7 +311,7 @@ const parseTypebotToPublicTypebot = (
|
||||
})
|
||||
|
||||
const parseTestTypebot = (partialTypebot: Partial<Typebot>): Typebot => ({
|
||||
id: partialTypebot.id ?? 'typebot',
|
||||
id: cuid(),
|
||||
workspaceId: proWorkspaceId,
|
||||
folderId: null,
|
||||
name: 'My typebot',
|
||||
|
||||
@@ -165,9 +165,13 @@ 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="pro-plan-tag"]')).toBeVisible()
|
||||
await expect(page.locator('[data-testid="current-subscription"]')).toHaveText(
|
||||
'Current workspace subscription: ProCancel my subscription'
|
||||
)
|
||||
await page.click('button >> text="Cancel my subscription"')
|
||||
await expect(page.locator('[data-testid="free-plan-tag"]')).toBeVisible()
|
||||
await expect(page.locator('[data-testid="current-subscription"]')).toHaveText(
|
||||
'Current workspace subscription: Free'
|
||||
)
|
||||
})
|
||||
|
||||
test('should display invoices', async ({ page }) => {
|
||||
|
||||
@@ -57,7 +57,7 @@ test.describe('Starter workspace', () => {
|
||||
},
|
||||
])
|
||||
await page.goto(`/typebots/${typebotId}/share`)
|
||||
await expect(page.locator('text=Pro')).toBeVisible()
|
||||
await expect(page.locator('[data-testid="pro-lock-tag"]')).toBeVisible()
|
||||
await page.click('text=Add my domain')
|
||||
await expect(
|
||||
page.locator(
|
||||
|
||||
@@ -75,7 +75,7 @@ test.describe('Free user', () => {
|
||||
await page.goto('/typebots')
|
||||
await page.click('text="Pro workspace"')
|
||||
await page.click('text="Free workspace"')
|
||||
await expect(page.locator('[data-testid="starter-plan-tag"]')).toBeVisible()
|
||||
await expect(page.locator('[data-testid="starter-lock-tag"]')).toBeVisible()
|
||||
await page.click('text=Create a folder')
|
||||
await expect(
|
||||
page.locator(
|
||||
|
||||
@@ -135,7 +135,9 @@ 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=Starter')).toBeVisible()
|
||||
await expect(
|
||||
page.locator('[data-testid="starter-lock-tag"]')
|
||||
).toBeVisible()
|
||||
await page.click('text=Typebot.io branding')
|
||||
await expect(
|
||||
page.locator(
|
||||
|
||||
@@ -144,7 +144,7 @@ test('can manage members', async ({ page }) => {
|
||||
|
||||
test("can't add new members when limit is reached", async ({ page }) => {
|
||||
await page.goto('/typebots')
|
||||
await page.click('text="Pro workspace"')
|
||||
await page.click('text="My awesome workspace"')
|
||||
await page.click('text="Free workspace"')
|
||||
await page.click('text=Settings & Members')
|
||||
await page.click('text="Members"')
|
||||
|
||||
Reference in New Issue
Block a user