2
0
Files
bot/apps/builder/cypress/plugins/database.ts

48 lines
1.1 KiB
TypeScript
Raw Normal View History

2021-12-06 15:48:50 +01:00
import { PrismaClient } from '.prisma/client'
2021-12-16 10:43:49 +01:00
import { StartBlock, StepType } from 'bot-engine'
2021-12-06 15:48:50 +01:00
const prisma = new PrismaClient()
const teardownTestData = async () => prisma.user.deleteMany()
export const seedDb = async () => {
await teardownTestData()
await createUsers()
await createFolders()
return createTypebots()
}
const createUsers = () =>
prisma.user.createMany({
data: [
{ id: 'test1', email: 'test1@gmail.com', emailVerified: new Date() },
{ id: 'test2', email: 'test2@gmail.com', emailVerified: new Date() },
],
})
const createFolders = () =>
prisma.dashboardFolder.createMany({
data: [{ ownerId: 'test2', name: 'Folder #1', id: 'folder1' }],
})
2021-12-16 10:43:49 +01:00
const createTypebots = () => {
const startBlock: StartBlock = {
graphCoordinates: { x: 0, y: 0 },
id: 'start-block',
steps: [
{
id: 'start-step',
blockId: 'start-block',
type: StepType.START,
label: 'Start',
},
],
title: 'Start',
}
2021-12-06 15:48:50 +01:00
prisma.typebot.createMany({
2021-12-16 10:43:49 +01:00
data: [
{ id: 'typebot1', name: 'Typebot #1', ownerId: 'test2', startBlock },
],
2021-12-06 15:48:50 +01:00
})
2021-12-16 10:43:49 +01:00
}