♻️ (builder) Change to features-centric folder structure
This commit is contained in:
committed by
Baptiste Arnaud
parent
3686465a85
commit
643571fe7d
5
apps/builder/src/test/utils/browser.ts
Normal file
5
apps/builder/src/test/utils/browser.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export const refreshUser = async () => {
|
||||
await fetch('/api/auth/session?update')
|
||||
const event = new Event('visibilitychange')
|
||||
document.dispatchEvent(event)
|
||||
}
|
||||
89
apps/builder/src/test/utils/databaseActions.ts
Normal file
89
apps/builder/src/test/utils/databaseActions.ts
Normal file
@@ -0,0 +1,89 @@
|
||||
import {
|
||||
CollaborationType,
|
||||
DashboardFolder,
|
||||
Prisma,
|
||||
PrismaClient,
|
||||
Workspace,
|
||||
} from 'db'
|
||||
import Stripe from 'stripe'
|
||||
import { proWorkspaceId } from 'utils/playwright/databaseSetup'
|
||||
|
||||
const prisma = new PrismaClient()
|
||||
|
||||
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY ?? '', {
|
||||
apiVersion: '2022-08-01',
|
||||
})
|
||||
|
||||
export const addSubscriptionToWorkspace = async (
|
||||
workspaceId: string,
|
||||
items: Stripe.SubscriptionCreateParams.Item[],
|
||||
metadata: Pick<
|
||||
Workspace,
|
||||
'additionalChatsIndex' | 'additionalStorageIndex' | 'plan'
|
||||
>
|
||||
) => {
|
||||
const { id: stripeId } = await stripe.customers.create({
|
||||
email: 'test-user@gmail.com',
|
||||
name: 'Test User',
|
||||
})
|
||||
const { id: paymentId } = await stripe.paymentMethods.create({
|
||||
card: {
|
||||
number: '4242424242424242',
|
||||
exp_month: 12,
|
||||
exp_year: 2022,
|
||||
cvc: '123',
|
||||
},
|
||||
type: 'card',
|
||||
})
|
||||
await stripe.paymentMethods.attach(paymentId, { customer: stripeId })
|
||||
await stripe.subscriptions.create({
|
||||
customer: stripeId,
|
||||
items,
|
||||
default_payment_method: paymentId,
|
||||
currency: 'usd',
|
||||
})
|
||||
await stripe.customers.update(stripeId, {
|
||||
invoice_settings: { default_payment_method: paymentId },
|
||||
})
|
||||
await prisma.workspace.update({
|
||||
where: { id: workspaceId },
|
||||
data: {
|
||||
stripeId,
|
||||
...metadata,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
export const createCollaboration = (
|
||||
userId: string,
|
||||
typebotId: string,
|
||||
type: CollaborationType
|
||||
) =>
|
||||
prisma.collaboratorsOnTypebots.create({ data: { userId, typebotId, type } })
|
||||
|
||||
export const getSignedInUser = (email: string) =>
|
||||
prisma.user.findFirst({ where: { email } })
|
||||
|
||||
export const createFolders = (partialFolders: Partial<DashboardFolder>[]) =>
|
||||
prisma.dashboardFolder.createMany({
|
||||
data: partialFolders.map((folder) => ({
|
||||
workspaceId: proWorkspaceId,
|
||||
name: 'Folder #1',
|
||||
...folder,
|
||||
})),
|
||||
})
|
||||
|
||||
export const createFolder = (workspaceId: string, name: string) =>
|
||||
prisma.dashboardFolder.create({
|
||||
data: {
|
||||
workspaceId,
|
||||
name,
|
||||
},
|
||||
})
|
||||
|
||||
export const createClaimableCustomPlan = async (
|
||||
data: Prisma.ClaimableCustomPlanUncheckedCreateInput
|
||||
) =>
|
||||
prisma.claimableCustomPlan.create({
|
||||
data,
|
||||
})
|
||||
4
apps/builder/src/test/utils/playwright.ts
Normal file
4
apps/builder/src/test/utils/playwright.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
import path from 'path'
|
||||
|
||||
export const getTestAsset = (name: string) =>
|
||||
path.join(__dirname, '..', 'assets', name)
|
||||
9
apps/builder/src/test/utils/selectorUtils.ts
Normal file
9
apps/builder/src/test/utils/selectorUtils.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { Page } from '@playwright/test'
|
||||
|
||||
export const deleteButtonInConfirmDialog = (page: Page) =>
|
||||
page.locator('section[role="alertdialog"] button:has-text("Delete")')
|
||||
|
||||
export const stripePaymentForm = (page: Page) =>
|
||||
page
|
||||
.frameLocator('#typebot-iframe')
|
||||
.frameLocator('[title="Secure payment input frame"]')
|
||||
Reference in New Issue
Block a user