♻️ Normalize data
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
import { parseNewTypebot, PublicTypebot, StepType, Typebot } from 'bot-engine'
|
||||
import { PublicTypebot, StepType, Typebot } from 'models'
|
||||
import { Plan, PrismaClient } from 'db'
|
||||
import { parseTestTypebot } from './utils'
|
||||
|
||||
const prisma = new PrismaClient()
|
||||
|
||||
@ -34,51 +35,50 @@ const createFolders = () =>
|
||||
})
|
||||
|
||||
const createTypebots = async () => {
|
||||
const typebot2: Typebot = {
|
||||
...(parseNewTypebot({
|
||||
const typebot2 = {
|
||||
...parseTestTypebot({
|
||||
id: 'typebot2',
|
||||
name: 'Typebot #2',
|
||||
ownerId: 'test2',
|
||||
folderId: null,
|
||||
}) as Typebot),
|
||||
id: 'typebot2',
|
||||
startBlock: {
|
||||
id: 'start-block',
|
||||
steps: [
|
||||
{
|
||||
id: 'start-step',
|
||||
blockId: 'start-block',
|
||||
type: StepType.START,
|
||||
label: 'Start',
|
||||
target: { blockId: 'block1' },
|
||||
blocks: {
|
||||
byId: {
|
||||
block1: {
|
||||
id: 'block1',
|
||||
title: 'Block #1',
|
||||
stepIds: ['step1'],
|
||||
graphCoordinates: { x: 200, y: 200 },
|
||||
},
|
||||
},
|
||||
],
|
||||
graphCoordinates: { x: 0, y: 0 },
|
||||
title: 'Start',
|
||||
},
|
||||
blocks: [
|
||||
{
|
||||
title: 'Block #1',
|
||||
id: 'block1',
|
||||
steps: [{ id: 'step1', type: StepType.TEXT_INPUT, blockId: 'block1' }],
|
||||
graphCoordinates: { x: 200, y: 200 },
|
||||
allIds: ['block1'],
|
||||
},
|
||||
],
|
||||
steps: {
|
||||
byId: {
|
||||
step1: {
|
||||
id: 'step1',
|
||||
type: StepType.TEXT_INPUT,
|
||||
blockId: 'block1',
|
||||
},
|
||||
},
|
||||
allIds: ['step1'],
|
||||
},
|
||||
}),
|
||||
}
|
||||
await prisma.typebot.createMany({
|
||||
data: [
|
||||
{
|
||||
...parseNewTypebot({
|
||||
...parseTestTypebot({
|
||||
id: 'typebot1',
|
||||
name: 'Typebot #1',
|
||||
ownerId: 'test2',
|
||||
folderId: null,
|
||||
blocks: { byId: {}, allIds: [] },
|
||||
steps: { byId: {}, allIds: [] },
|
||||
}),
|
||||
id: 'typebot1',
|
||||
},
|
||||
typebot2,
|
||||
],
|
||||
] as any,
|
||||
})
|
||||
return prisma.publicTypebot.createMany({
|
||||
data: [parseTypebotToPublicTypebot('publictypebot2', typebot2)],
|
||||
data: [parseTypebotToPublicTypebot('publictypebot2', typebot2)] as any,
|
||||
})
|
||||
}
|
||||
|
||||
@ -118,8 +118,8 @@ const parseTypebotToPublicTypebot = (
|
||||
): PublicTypebot => ({
|
||||
id,
|
||||
blocks: typebot.blocks,
|
||||
steps: typebot.steps,
|
||||
name: typebot.name,
|
||||
startBlock: typebot.startBlock,
|
||||
typebotId: typebot.id,
|
||||
theme: typebot.theme,
|
||||
settings: typebot.settings,
|
||||
|
75
apps/builder/cypress/plugins/utils.ts
Normal file
75
apps/builder/cypress/plugins/utils.ts
Normal file
@ -0,0 +1,75 @@
|
||||
import {
|
||||
Block,
|
||||
StepType,
|
||||
Theme,
|
||||
BackgroundType,
|
||||
Settings,
|
||||
Typebot,
|
||||
Table,
|
||||
Step,
|
||||
} from 'models'
|
||||
|
||||
export const parseTestTypebot = ({
|
||||
id,
|
||||
ownerId,
|
||||
name,
|
||||
blocks,
|
||||
steps,
|
||||
}: {
|
||||
id: string
|
||||
ownerId: string
|
||||
name: string
|
||||
blocks: Table<Block>
|
||||
steps: Table<Step>
|
||||
}): Typebot => {
|
||||
const theme: Theme = {
|
||||
general: {
|
||||
font: 'Open Sans',
|
||||
background: { type: BackgroundType.NONE, content: '#ffffff' },
|
||||
},
|
||||
}
|
||||
const settings: Settings = {
|
||||
typingEmulation: {
|
||||
enabled: true,
|
||||
speed: 300,
|
||||
maxDelay: 1.5,
|
||||
},
|
||||
}
|
||||
return {
|
||||
id,
|
||||
folderId: null,
|
||||
name,
|
||||
ownerId,
|
||||
theme,
|
||||
settings,
|
||||
createdAt: new Date(),
|
||||
blocks: {
|
||||
byId: {
|
||||
block0: {
|
||||
id: 'block0',
|
||||
title: 'Block #0',
|
||||
stepIds: ['step0'],
|
||||
graphCoordinates: { x: 0, y: 0 },
|
||||
},
|
||||
...blocks.byId,
|
||||
},
|
||||
allIds: ['block0', ...blocks.allIds],
|
||||
},
|
||||
steps: {
|
||||
byId: {
|
||||
step0: {
|
||||
id: 'step0',
|
||||
type: StepType.START,
|
||||
blockId: 'block0',
|
||||
label: 'Start',
|
||||
target: { blockId: 'block1' },
|
||||
},
|
||||
...steps.byId,
|
||||
},
|
||||
allIds: ['step0', ...steps.allIds],
|
||||
},
|
||||
publicId: null,
|
||||
publishedTypebotId: null,
|
||||
updatedAt: new Date(),
|
||||
}
|
||||
}
|
@ -2,15 +2,10 @@ import path from 'path'
|
||||
import { parse } from 'papaparse'
|
||||
|
||||
describe('ResultsPage', () => {
|
||||
before(() => {
|
||||
cy.intercept({ url: '/api/typebots/typebot2/results*', method: 'GET' }).as(
|
||||
'getResults'
|
||||
)
|
||||
cy.intercept({ url: '/api/typebots/typebot2/results*', method: 'GET' }).as(
|
||||
'getResults'
|
||||
)
|
||||
})
|
||||
beforeEach(() => {
|
||||
cy.intercept({ url: '/api/typebots/typebot2/results*', method: 'GET' }).as(
|
||||
'getResults'
|
||||
)
|
||||
cy.task('seed')
|
||||
cy.signOut()
|
||||
})
|
||||
@ -48,7 +43,7 @@ describe('ResultsPage', () => {
|
||||
cy.findByText('content0').should('exist')
|
||||
})
|
||||
|
||||
it.only('should correctly export selection in CSV', () => {
|
||||
it('should correctly export selection in CSV', () => {
|
||||
const downloadsFolder = Cypress.config('downloadsFolder')
|
||||
cy.signIn('test2@gmail.com')
|
||||
cy.visit('/typebots/typebot2/results')
|
||||
|
Reference in New Issue
Block a user