2
0

chore(inputs): Add Button targets e2e tests

This commit is contained in:
Baptiste Arnaud
2022-01-12 09:57:00 +01:00
parent 659f50eb06
commit 13f72f5ff7
10 changed files with 168 additions and 13 deletions

View File

@ -0,0 +1 @@
export const userIds = ['user1', 'user2']

View File

@ -1,6 +1,7 @@
import { InputStepType, PublicTypebot, Typebot } from 'models'
import { Plan, PrismaClient } from 'db'
import { parseTestTypebot } from './utils'
import { userIds } from './data'
const prisma = new PrismaClient()
@ -21,9 +22,9 @@ export const createTypebot = (typebot: Typebot) =>
const createUsers = () =>
prisma.user.createMany({
data: [
{ id: 'test1', email: 'test1@gmail.com', emailVerified: new Date() },
{ id: userIds[0], email: 'test1@gmail.com', emailVerified: new Date() },
{
id: 'test2',
id: userIds[1],
email: 'test2@gmail.com',
emailVerified: new Date(),
plan: Plan.PRO,
@ -34,7 +35,7 @@ const createUsers = () =>
const createFolders = () =>
prisma.dashboardFolder.createMany({
data: [{ ownerId: 'test2', name: 'Folder #1', id: 'folder1' }],
data: [{ ownerId: userIds[1], name: 'Folder #1', id: 'folder1' }],
})
const createTypebots = async () => {
@ -42,7 +43,7 @@ const createTypebots = async () => {
...parseTestTypebot({
id: 'typebot2',
name: 'Typebot #2',
ownerId: 'test2',
ownerId: userIds[1],
blocks: {
byId: {
block1: {
@ -72,7 +73,7 @@ const createTypebots = async () => {
...parseTestTypebot({
id: 'typebot1',
name: 'Typebot #1',
ownerId: 'test2',
ownerId: userIds[1],
blocks: { byId: {}, allIds: [] },
steps: { byId: {}, allIds: [] },
}),
@ -129,3 +130,6 @@ const parseTypebotToPublicTypebot = (
publicId: typebot.publicId,
choiceItems: typebot.choiceItems,
})
export const loadRawTypebotInDatabase = (typebot: Typebot) =>
prisma.typebot.create({ data: { ...typebot, ownerId: userIds[1] } as any })

View File

@ -3,7 +3,7 @@ import {
FacebookSocialLogin,
GoogleSocialLogin,
} from 'cypress-social-logins/src/Plugins'
import { createTypebot, seedDb } from './database'
import { createTypebot, loadRawTypebotInDatabase, seedDb } from './database'
/// <reference types="cypress" />
/**
@ -17,6 +17,7 @@ const handler = (on: any) => {
GitHubSocialLogin: GitHubSocialLogin,
seed: seedDb,
createTypebot,
loadRawTypebotInDatabase,
})
}