✨ (billing) Implement custom plan
This commit is contained in:
committed by
Baptiste Arnaud
parent
3f7dc79918
commit
385853ca3c
@ -1,7 +1,10 @@
|
||||
import test, { expect } from '@playwright/test'
|
||||
import cuid from 'cuid'
|
||||
import { Plan } from 'db'
|
||||
import { addSubscriptionToWorkspace } from 'playwright/services/databaseActions'
|
||||
import {
|
||||
addSubscriptionToWorkspace,
|
||||
createClaimableCustomPlan,
|
||||
} from 'playwright/services/databaseActions'
|
||||
import {
|
||||
createTypebots,
|
||||
createWorkspaces,
|
||||
@ -12,6 +15,7 @@ import {
|
||||
const usageWorkspaceId = cuid()
|
||||
const usageTypebotId = cuid()
|
||||
const planChangeWorkspaceId = cuid()
|
||||
const enterpriseWorkspaceId = cuid()
|
||||
|
||||
test.beforeAll(async () => {
|
||||
await createWorkspaces([
|
||||
@ -24,12 +28,20 @@ test.beforeAll(async () => {
|
||||
id: planChangeWorkspaceId,
|
||||
name: 'Plan Change Workspace',
|
||||
},
|
||||
{
|
||||
id: enterpriseWorkspaceId,
|
||||
name: 'Enterprise Workspace',
|
||||
},
|
||||
])
|
||||
await createTypebots([{ id: usageTypebotId, workspaceId: usageWorkspaceId }])
|
||||
})
|
||||
|
||||
test.afterAll(async () => {
|
||||
await deleteWorkspaces([usageWorkspaceId, planChangeWorkspaceId])
|
||||
await deleteWorkspaces([
|
||||
usageWorkspaceId,
|
||||
planChangeWorkspaceId,
|
||||
enterpriseWorkspaceId,
|
||||
])
|
||||
})
|
||||
|
||||
test('should display valid usage', async ({ page }) => {
|
||||
@ -38,14 +50,37 @@ test('should display valid usage', async ({ page }) => {
|
||||
await page.click('text=Billing & Usage')
|
||||
await expect(page.locator('text="/ 10,000"')).toBeVisible()
|
||||
await expect(page.locator('text="/ 10 GB"')).toBeVisible()
|
||||
await page.getByText('Members', { exact: true }).click()
|
||||
await expect(
|
||||
page.getByRole('heading', { name: 'Members (1/5)' })
|
||||
).toBeVisible()
|
||||
await page.click('text=Pro workspace', { force: true })
|
||||
|
||||
await page.click('text=Pro workspace')
|
||||
await page.click('text="Custom workspace"')
|
||||
await page.click('text=Settings & Members')
|
||||
await page.click('text=Billing & Usage')
|
||||
await expect(page.locator('text="/ 100,000"')).toBeVisible()
|
||||
await expect(page.locator('text="/ 50 GB"')).toBeVisible()
|
||||
await expect(page.getByText('Upgrade to Starter')).toBeHidden()
|
||||
await expect(page.getByText('Upgrade to Pro')).toBeHidden()
|
||||
await expect(page.getByText('Need custom limits?')).toBeHidden()
|
||||
await page.getByText('Members', { exact: true }).click()
|
||||
await expect(
|
||||
page.getByRole('heading', { name: 'Members (1/20)' })
|
||||
).toBeVisible()
|
||||
await page.click('text=Custom workspace', { force: true })
|
||||
|
||||
await page.click('text=Custom workspace')
|
||||
await page.click('text="Free workspace"')
|
||||
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.getByText('Members', { exact: true }).click()
|
||||
await expect(
|
||||
page.getByRole('heading', { name: 'Members (1/1)' })
|
||||
).toBeVisible()
|
||||
await page.click('text=Free workspace', { force: true })
|
||||
|
||||
await injectFakeResults({
|
||||
@ -189,3 +224,30 @@ test('should display invoices', async ({ page }) => {
|
||||
await expect(page.locator('tr')).toHaveCount(2)
|
||||
await expect(page.locator('text="€39.00"')).toBeVisible()
|
||||
})
|
||||
|
||||
test('custom plans should work', async ({ page }) => {
|
||||
await page.goto('/typebots')
|
||||
await page.click('text=Pro workspace')
|
||||
await page.click('text=Enterprise Workspace')
|
||||
await page.click('text=Settings & Members')
|
||||
await page.click('text=Billing & Usage')
|
||||
await expect(page.getByTestId('current-subscription')).toHaveText(
|
||||
'Current workspace subscription: Free'
|
||||
)
|
||||
await createClaimableCustomPlan({
|
||||
currency: 'usd',
|
||||
price: 239,
|
||||
workspaceId: enterpriseWorkspaceId,
|
||||
chatsLimit: 100000,
|
||||
storageLimit: 50,
|
||||
seatsLimit: 10,
|
||||
name: 'Acme custom plan',
|
||||
description: 'Description of the deal',
|
||||
})
|
||||
|
||||
await page.goto('/api/stripe/custom-plan-checkout')
|
||||
|
||||
await expect(page.getByRole('list').getByText('$239.00')).toBeVisible()
|
||||
await expect(page.getByText('Subscribe to Acme custom plan')).toBeVisible()
|
||||
await expect(page.getByText('Description of the deal')).toBeVisible()
|
||||
})
|
||||
|
Reference in New Issue
Block a user