🛠️ Adapt Cypress to Turbo Repo
This commit is contained in:
2
apps/builder/.gitignore
vendored
Normal file
2
apps/builder/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
cypress/videos
|
||||||
|
cypress/screenshots
|
@ -1,13 +1,13 @@
|
|||||||
import { Flex } from '@chakra-ui/react'
|
import { Flex } from '@chakra-ui/react'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import StepsList from './StepTypesList'
|
|
||||||
import Graph from './graph/Graph'
|
import Graph from './graph/Graph'
|
||||||
import { DndContext } from 'contexts/DndContext'
|
import { DndContext } from 'contexts/DndContext'
|
||||||
|
import StepTypesList from './StepTypesList'
|
||||||
|
|
||||||
export const Board = () => (
|
export const Board = () => (
|
||||||
<Flex flex="1" pos="relative" bgColor="gray.50">
|
<Flex flex="1" pos="relative" bgColor="gray.50">
|
||||||
<DndContext>
|
<DndContext>
|
||||||
<StepsList />
|
<StepTypesList />
|
||||||
<Graph />
|
<Graph />
|
||||||
</DndContext>
|
</DndContext>
|
||||||
</Flex>
|
</Flex>
|
||||||
|
@ -10,7 +10,6 @@ import { StartBlockNode } from './BlockNode/StartBlockNode'
|
|||||||
const Graph = () => {
|
const Graph = () => {
|
||||||
const { draggedStepType, setDraggedStepType, draggedStep, setDraggedStep } =
|
const { draggedStepType, setDraggedStepType, draggedStep, setDraggedStep } =
|
||||||
useDnd()
|
useDnd()
|
||||||
const graphRef = useRef<HTMLDivElement | null>(null)
|
|
||||||
const graphContainerRef = useRef<HTMLDivElement | null>(null)
|
const graphContainerRef = useRef<HTMLDivElement | null>(null)
|
||||||
const { typebot } = useTypebot()
|
const { typebot } = useTypebot()
|
||||||
const {
|
const {
|
||||||
@ -59,8 +58,8 @@ const Graph = () => {
|
|||||||
addNewBlock({
|
addNewBlock({
|
||||||
step: draggedStep,
|
step: draggedStep,
|
||||||
type: draggedStepType,
|
type: draggedStepType,
|
||||||
x: e.x - graphPosition.x - blockWidth / 3,
|
x: e.clientX - graphPosition.x - blockWidth / 3,
|
||||||
y: e.y - graphPosition.y - 20,
|
y: e.clientY - graphPosition.y - 20,
|
||||||
})
|
})
|
||||||
setDraggedStep(undefined)
|
setDraggedStep(undefined)
|
||||||
setDraggedStepType(undefined)
|
setDraggedStepType(undefined)
|
||||||
@ -69,11 +68,10 @@ const Graph = () => {
|
|||||||
|
|
||||||
if (!typebot) return <></>
|
if (!typebot) return <></>
|
||||||
return (
|
return (
|
||||||
<Flex ref={graphContainerRef} pos="relative" flex="1" h="full">
|
<Flex ref={graphContainerRef} flex="1" h="full">
|
||||||
<Flex
|
<Flex
|
||||||
ref={graphRef}
|
|
||||||
flex="1"
|
flex="1"
|
||||||
h="full"
|
boxSize={'200px'}
|
||||||
style={{
|
style={{
|
||||||
transform,
|
transform,
|
||||||
}}
|
}}
|
||||||
|
@ -85,7 +85,7 @@ export const TypebotButton = ({
|
|||||||
mb={6}
|
mb={6}
|
||||||
rounded="lg"
|
rounded="lg"
|
||||||
whiteSpace="normal"
|
whiteSpace="normal"
|
||||||
data-testid="typebot-button"
|
data-testid={`typebot-button-${typebot.id}`}
|
||||||
opacity={isDragging ? 0.2 : 1}
|
opacity={isDragging ? 0.2 : 1}
|
||||||
ref={setNodeRef}
|
ref={setNodeRef}
|
||||||
{...listeners}
|
{...listeners}
|
||||||
|
@ -3,5 +3,6 @@
|
|||||||
"chromeWebSecurity": false,
|
"chromeWebSecurity": false,
|
||||||
"integrationFolder": "cypress/tests",
|
"integrationFolder": "cypress/tests",
|
||||||
"viewportWidth": 1400,
|
"viewportWidth": 1400,
|
||||||
"viewportHeight": 800
|
"viewportHeight": 800,
|
||||||
|
"video": false
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { PrismaClient } from '.prisma/client'
|
import { PrismaClient } from '.prisma/client'
|
||||||
import { StartBlock, StepType } from 'bot-engine'
|
import { Block, StartBlock, StepType } from 'bot-engine'
|
||||||
|
|
||||||
const prisma = new PrismaClient()
|
const prisma = new PrismaClient()
|
||||||
|
|
||||||
@ -37,11 +37,42 @@ const createTypebots = () => {
|
|||||||
label: 'Start',
|
label: 'Start',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
title: 'Start',
|
title: 'Home',
|
||||||
}
|
}
|
||||||
prisma.typebot.createMany({
|
const blocks: Block[] = [
|
||||||
|
{
|
||||||
|
id: 'block1',
|
||||||
|
title: 'Block1',
|
||||||
|
graphCoordinates: { x: 150, y: 150 },
|
||||||
|
steps: [
|
||||||
|
{ id: 'step1', blockId: 'block1', type: StepType.TEXT, content: '' },
|
||||||
|
{
|
||||||
|
id: 'step2',
|
||||||
|
blockId: 'block1',
|
||||||
|
type: StepType.DATE_PICKER,
|
||||||
|
content: '',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'block2',
|
||||||
|
title: 'Block2',
|
||||||
|
graphCoordinates: { x: 300, y: 300 },
|
||||||
|
steps: [
|
||||||
|
{ id: 'step1', blockId: 'block2', type: StepType.TEXT, content: '' },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
]
|
||||||
|
return prisma.typebot.createMany({
|
||||||
data: [
|
data: [
|
||||||
{ id: 'typebot1', name: 'Typebot #1', ownerId: 'test2', startBlock },
|
{ id: 'typebot1', name: 'Typebot #1', ownerId: 'test2', startBlock },
|
||||||
|
{
|
||||||
|
id: 'typebot2',
|
||||||
|
name: 'Typebot #2',
|
||||||
|
ownerId: 'test2',
|
||||||
|
startBlock,
|
||||||
|
blocks,
|
||||||
|
},
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -1,104 +0,0 @@
|
|||||||
describe('SignIn page', () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
cy.signOut()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('can continue with Google', () => {
|
|
||||||
cy.visit('/signin')
|
|
||||||
const username = Cypress.env('GOOGLE_USER')
|
|
||||||
const password = Cypress.env('GOOGLE_PW')
|
|
||||||
const loginUrl = Cypress.env('SITE_NAME')
|
|
||||||
const cookieName = Cypress.env('COOKIE_NAME')
|
|
||||||
exectueSocialLogin(
|
|
||||||
'GoogleSocialLogin',
|
|
||||||
username,
|
|
||||||
password,
|
|
||||||
loginUrl,
|
|
||||||
cookieName
|
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('can continue with GitHub', () => {
|
|
||||||
cy.visit('/signin')
|
|
||||||
const username = Cypress.env('GITHUB_USER')
|
|
||||||
const password = Cypress.env('GITHUB_PW')
|
|
||||||
const loginUrl = Cypress.env('SITE_NAME')
|
|
||||||
const cookieName = Cypress.env('COOKIE_NAME')
|
|
||||||
exectueSocialLogin(
|
|
||||||
'GitHubSocialLogin',
|
|
||||||
username,
|
|
||||||
password,
|
|
||||||
loginUrl,
|
|
||||||
cookieName
|
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('can continue with Facebook', () => {
|
|
||||||
cy.visit('/signin')
|
|
||||||
const username = Cypress.env('FACEBOOK_USER')
|
|
||||||
const password = Cypress.env('FACEBOOK_PW')
|
|
||||||
const loginUrl = Cypress.env('SITE_NAME')
|
|
||||||
const cookieName = Cypress.env('COOKIE_NAME')
|
|
||||||
exectueSocialLogin(
|
|
||||||
'FacebookSocialLogin',
|
|
||||||
username,
|
|
||||||
password,
|
|
||||||
loginUrl,
|
|
||||||
cookieName,
|
|
||||||
[
|
|
||||||
'button[data-testid="cookie-policy-dialog-manage-button"]',
|
|
||||||
'button[data-testid="cookie-policy-manage-dialog-accept-button"]',
|
|
||||||
]
|
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
// We don't test email sign in because disabling email sending is not straightforward
|
|
||||||
})
|
|
||||||
|
|
||||||
const exectueSocialLogin = (
|
|
||||||
task: 'FacebookSocialLogin' | 'GoogleSocialLogin' | 'GitHubSocialLogin',
|
|
||||||
username: string,
|
|
||||||
password: string,
|
|
||||||
loginUrl: string,
|
|
||||||
cookieName: string,
|
|
||||||
trackingConsentSelectors?: string[]
|
|
||||||
) => {
|
|
||||||
const selectorId =
|
|
||||||
task === 'FacebookSocialLogin'
|
|
||||||
? 'facebook'
|
|
||||||
: task === 'GoogleSocialLogin'
|
|
||||||
? 'google'
|
|
||||||
: 'github'
|
|
||||||
const socialLoginOptions = {
|
|
||||||
username,
|
|
||||||
password,
|
|
||||||
loginUrl,
|
|
||||||
headless: true,
|
|
||||||
logs: true,
|
|
||||||
isPopup: false,
|
|
||||||
loginSelector: `[data-testid="${selectorId}"]`,
|
|
||||||
postLoginSelector: `[data-testid="authenticated"]`,
|
|
||||||
trackingConsentSelectors,
|
|
||||||
}
|
|
||||||
|
|
||||||
cy.task(task, socialLoginOptions).then(({ cookies }: any) => {
|
|
||||||
const cookie = cookies
|
|
||||||
.filter((cookie: any) => cookie.name === cookieName)
|
|
||||||
.pop()
|
|
||||||
if (cookie) {
|
|
||||||
cy.setCookie(cookie.name, cookie.value, {
|
|
||||||
domain: cookie.domain,
|
|
||||||
expiry: cookie.expires,
|
|
||||||
httpOnly: cookie.httpOnly,
|
|
||||||
path: cookie.path,
|
|
||||||
secure: cookie.secure,
|
|
||||||
})
|
|
||||||
|
|
||||||
Cypress.Cookies.defaults({
|
|
||||||
preserve: cookieName,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
cy.visit('/typebots')
|
|
||||||
cy.findByRole('button', { name: 'Create a folder' }).should('exist')
|
|
||||||
})
|
|
||||||
}
|
|
@ -3,8 +3,10 @@ describe('BoardPage', () => {
|
|||||||
cy.task('seed')
|
cy.task('seed')
|
||||||
cy.signOut()
|
cy.signOut()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('steps should be droppable', () => {
|
it('steps should be droppable', () => {
|
||||||
cy.signIn('test2@gmail.com')
|
cy.signIn('test2@gmail.com')
|
||||||
cy.visit('/typebots/typebot1')
|
cy.visit('/typebots/typebot1')
|
||||||
|
// Can't find an easy way to implement this
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -29,11 +29,11 @@ describe('Dashboard page', () => {
|
|||||||
it('should be droppable', () => {
|
it('should be droppable', () => {
|
||||||
cy.signIn('test2@gmail.com')
|
cy.signIn('test2@gmail.com')
|
||||||
cy.visit('/typebots')
|
cy.visit('/typebots')
|
||||||
cy.findByTestId('typebot-button').mouseMoveBy(-100, 0, {
|
cy.findByTestId('typebot-button-typebot1').mouseMoveBy(-100, 0, {
|
||||||
delay: 120,
|
delay: 120,
|
||||||
})
|
})
|
||||||
cy.visit('/typebots/folders/folder1')
|
cy.visit('/typebots/folders/folder1')
|
||||||
cy.findByTestId('typebot-button').mouseMoveBy(-300, -100, {
|
cy.findByTestId('typebot-button-typebot1').mouseMoveBy(-300, -100, {
|
||||||
delay: 120,
|
delay: 120,
|
||||||
})
|
})
|
||||||
cy.visit('/typebots')
|
cy.visit('/typebots')
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
"isolatedModules": false,
|
"isolatedModules": false,
|
||||||
"allowJs": true,
|
"allowJs": true,
|
||||||
"noEmit": true,
|
"noEmit": true,
|
||||||
"downlevelIteration": true
|
"downlevelIteration": true,
|
||||||
|
"jsx": "react"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
"name": "builder",
|
"name": "builder",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "next dev",
|
"dev": "next dev -p 3000",
|
||||||
"build": "next build",
|
"build": "next build",
|
||||||
"start": "next start",
|
"start": "next start",
|
||||||
"lint": "next lint",
|
"lint": "next lint",
|
||||||
|
11
package.json
11
package.json
@ -6,14 +6,11 @@
|
|||||||
"apps/*"
|
"apps/*"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"builder": "yarn workspace builder",
|
"docker:up": "docker-compose up -d",
|
||||||
"viewer": "yarn workspace viewer",
|
|
||||||
"db": "yarn workspace db",
|
|
||||||
"bot-engine": "yarn workspace bot-engine",
|
|
||||||
"db:up": "docker-compose up -d && yarn db prisma db push",
|
|
||||||
"db:nuke": "docker-compose down --volumes --remove-orphans",
|
"db:nuke": "docker-compose down --volumes --remove-orphans",
|
||||||
|
"dev": "dotenv -e .env yarn docker:up && dotenv -e .env turbo run dev --parallel",
|
||||||
"build": "dotenv -e .env turbo run build",
|
"build": "dotenv -e .env turbo run build",
|
||||||
"dev": "dotenv -e .env yarn db:up && turbo run dev --parallel",
|
"test": "dotenv -e .env turbo run dev test",
|
||||||
"lint": "turbo run lint"
|
"lint": "turbo run lint"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@ -33,7 +30,7 @@
|
|||||||
},
|
},
|
||||||
"test": {
|
"test": {
|
||||||
"dependsOn": [
|
"dependsOn": [
|
||||||
"^build"
|
"^dev"
|
||||||
],
|
],
|
||||||
"outputs": []
|
"outputs": []
|
||||||
},
|
},
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
"@prisma/client": "latest"
|
"@prisma/client": "latest"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"dev": "yarn prisma db push",
|
||||||
"build": "prisma generate && prisma migrate deploy"
|
"build": "prisma generate && prisma migrate deploy"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user