Skip to content

Commit

Permalink
perf(e2e): ⚡️ Migrate to Playwright
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Jan 28, 2022
1 parent c5aaa32 commit 73f277f
Show file tree
Hide file tree
Showing 145 changed files with 3,104 additions and 2,346 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,6 @@ STRIPE_WEBHOOK_SECRET=

# (Optional) Used for GIF search
NEXT_PUBLIC_GIPHY_API_KEY=

# (Optional) for e2e tests
GOOGLE_REFRESH_TOKEN_TEST=
26 changes: 26 additions & 0 deletions apps/builder/.github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Playwright Tests
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
jobs:
test:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '14.x'
- name: Install dependencies
run: npm ci
- name: Install Playwright
run: npx playwright install --with-deps
- name: Run Playwright tests
run: npx playwright test
- uses: actions/upload-artifact@v2
if: always()
with:
name: playwright-test-results
path: test-results/
9 changes: 8 additions & 1 deletion apps/builder/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
cypress/videos
cypress/screenshots
cypress/downloads
cypress/downloads
node_modules/
test-results/
playwright-report/

authenticatedState.json

.env
11 changes: 11 additions & 0 deletions apps/builder/assets/icons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -286,3 +286,14 @@ export const WebhookIcon = (props: IconProps) => (
<polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"></polygon>
</Icon>
)

export const GripIcon = (props: IconProps) => (
<Icon viewBox="0 0 24 24" {...featherIconsBaseProps} {...props}>
<circle cx="12" cy="9" r="1"></circle>
<circle cx="19" cy="9" r="1"></circle>
<circle cx="5" cy="9" r="1"></circle>
<circle cx="12" cy="15" r="1"></circle>
<circle cx="19" cy="15" r="1"></circle>
<circle cx="5" cy="15" r="1"></circle>
</Icon>
)
3 changes: 3 additions & 0 deletions apps/builder/assets/styles/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.grabbing * {
cursor: grabbing !important;
}
6 changes: 3 additions & 3 deletions apps/builder/components/board/Board.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Flex } from '@chakra-ui/react'
import React from 'react'
import Graph from './graph/Graph'
import { DndContext } from 'contexts/DndContext'
import { StepDndContext } from 'contexts/StepDndContext'
import { StepTypesList } from './StepTypesList'
import { PreviewDrawer } from './preview/PreviewDrawer'
import { RightPanel, useEditor } from 'contexts/EditorContext'
Expand All @@ -12,14 +12,14 @@ export const Board = () => {
const { rightPanel } = useEditor()
return (
<Flex flex="1" pos="relative" bgColor="gray.50" h="full">
<DndContext>
<StepDndContext>
<StepTypesList />
<GraphProvider>
<Graph flex="1" />
<BoardMenuButton pos="absolute" right="40px" top="20px" />
{rightPanel === RightPanel.PREVIEW && <PreviewDrawer />}
</GraphProvider>
</DndContext>
</StepDndContext>
</Flex>
)
}
4 changes: 2 additions & 2 deletions apps/builder/components/board/StepTypesList/StepCard.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Flex, HStack, StackProps, Text } from '@chakra-ui/react'
import { StepType, DraggableStepType } from 'models'
import { useDnd } from 'contexts/DndContext'
import { useStepDnd } from 'contexts/StepDndContext'
import React, { useEffect, useState } from 'react'
import { StepIcon } from './StepIcon'
import { StepTypeLabel } from './StepTypeLabel'
Expand All @@ -12,7 +12,7 @@ export const StepCard = ({
type: DraggableStepType
onMouseDown: (e: React.MouseEvent, type: DraggableStepType) => void
}) => {
const { draggedStepType } = useDnd()
const { draggedStepType } = useStepDnd()
const [isMouseDown, setIsMouseDown] = useState(false)

useEffect(() => {
Expand Down
4 changes: 2 additions & 2 deletions apps/builder/components/board/StepTypesList/StepTypesList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ import {
IntegrationStepType,
LogicStepType,
} from 'models'
import { useDnd } from 'contexts/DndContext'
import { useStepDnd } from 'contexts/StepDndContext'
import React, { useState } from 'react'
import { StepCard, StepCardOverlay } from './StepCard'

export const StepTypesList = () => {
const { setDraggedStepType, draggedStepType } = useDnd()
const { setDraggedStepType, draggedStepType } = useStepDnd()
const [position, setPosition] = useState({
x: 0,
y: 0,
Expand Down
6 changes: 3 additions & 3 deletions apps/builder/components/board/graph/BlockNode/BlockNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
import React, { useEffect, useMemo, useState } from 'react'
import { Block } from 'models'
import { useGraph } from 'contexts/GraphContext'
import { useDnd } from 'contexts/DndContext'
import { useStepDnd } from 'contexts/StepDndContext'
import { StepsList } from './StepsList'
import { filterTable, isDefined } from 'utils'
import { useTypebot } from 'contexts/TypebotContext/TypebotContext'
Expand All @@ -22,8 +22,8 @@ type Props = {
export const BlockNode = ({ block }: Props) => {
const { connectingIds, setConnectingIds, previewingEdgeId } = useGraph()
const { typebot, updateBlock } = useTypebot()
const { setMouseOverBlockId } = useDnd()
const { draggedStep, draggedStepType } = useDnd()
const { setMouseOverBlockId } = useStepDnd()
const { draggedStep, draggedStepType } = useStepDnd()
const [isMouseDown, setIsMouseDown] = useState(false)
const [isConnecting, setIsConnecting] = useState(false)
const isPreviewing = useMemo(() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Flex, Portal, Stack, Text, useEventListener } from '@chakra-ui/react'
import { useDnd } from 'contexts/DndContext'
import { useStepDnd } from 'contexts/StepDndContext'
import { Coordinates } from 'contexts/GraphContext'
import { useTypebot } from 'contexts/TypebotContext'
import { ChoiceInputStep, ChoiceItem } from 'models'
Expand All @@ -19,7 +19,7 @@ export const ChoiceItemsList = ({ step }: ChoiceItemsListProps) => {
mouseOverBlockId,
setDraggedChoiceItem,
setMouseOverBlockId,
} = useDnd()
} = useStepDnd()
const showSortPlaceholders = useMemo(
() => mouseOverBlockId === step.blockId && draggedChoiceItem,
[draggedChoiceItem, mouseOverBlockId, step.blockId]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export const VideoUploadContent = ({ content, onSubmit }: Props) => {
placeholder="Paste the video link..."
initialValue={content?.url ?? ''}
onChange={handleUrlChange}
delay={100}
/>
<Text fontSize="sm" color="gray.400" textAlign="center">
Works with Youtube, Vimeo and others
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,12 @@ export const ChoiceInputSettingsBody = ({
/>
{options?.isMultipleChoice && (
<Stack>
<FormLabel mb="0" htmlFor="send">
<FormLabel mb="0" htmlFor="button">
Button label:
</FormLabel>
<DebouncedInput
id="send"
id="button"
initialValue={options?.buttonLabel ?? 'Send'}
delay={100}
onChange={handleButtonLabelChange}
/>
</Stack>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export const ComparisonItem = ({
/>
{item.comparisonOperator !== ComparisonOperators.IS_SET && (
<InputWithVariableButton
delay={100}
initialValue={item.value ?? ''}
onChange={handleChangeValue}
placeholder="Type a value..."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const ConditionSettingsBody = ({

return (
<TableList<Comparison>
initialItems={options.comparisons}
onItemsChange={handleComparisonsChange}
Item={ComparisonItem}
ComponentBetweenItems={() => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ export const DateInputSettingsBody = ({
<DebouncedInput
id="from"
initialValue={options.labels.from}
delay={100}
onChange={handleFromChange}
/>
</Stack>
Expand All @@ -62,7 +61,6 @@ export const DateInputSettingsBody = ({
<DebouncedInput
id="to"
initialValue={options.labels.to}
delay={100}
onChange={handleToChange}
/>
</Stack>
Expand All @@ -74,7 +72,6 @@ export const DateInputSettingsBody = ({
<DebouncedInput
id="button"
initialValue={options.labels.button}
delay={100}
onChange={handleButtonLabelChange}
/>
</Stack>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export const EmailInputSettingsBody = ({
<DebouncedInput
id="placeholder"
initialValue={options.labels.placeholder}
delay={100}
onChange={handlePlaceholderChange}
/>
</Stack>
Expand All @@ -40,7 +39,6 @@ export const EmailInputSettingsBody = ({
<DebouncedInput
id="button"
initialValue={options.labels.button}
delay={100}
onChange={handleButtonLabelChange}
/>
</Stack>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ export const GoogleAnalyticsSettings = ({
id="tracking-id"
initialValue={options?.trackingId ?? ''}
placeholder="G-123456..."
delay={100}
onChange={handleTrackingIdChange}
/>
</Stack>
Expand All @@ -63,7 +62,6 @@ export const GoogleAnalyticsSettings = ({
id="category"
initialValue={options?.category ?? ''}
placeholder="Example: Typebot"
delay={100}
onChange={handleCategoryChange}
/>
</Stack>
Expand All @@ -75,7 +73,6 @@ export const GoogleAnalyticsSettings = ({
id="action"
initialValue={options?.action ?? ''}
placeholder="Example: Submit email"
delay={100}
onChange={handleActionChange}
/>
</Stack>
Expand All @@ -98,7 +95,6 @@ export const GoogleAnalyticsSettings = ({
id="label"
initialValue={options?.label ?? ''}
placeholder="Example: Campaign Z"
delay={100}
onChange={handleLabelChange}
/>
</Stack>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ const ActionOptions = ({
case GoogleSheetsAction.INSERT_ROW:
return (
<TableList<Cell>
initialItems={options.cellsToInsert}
initialItems={options.cellsToInsert ?? { byId: {}, allIds: [] }}
onItemsChange={handleInsertColumnsChange}
Item={UpdatingCellItem}
addLabel="Add a value"
Expand All @@ -167,7 +167,7 @@ const ActionOptions = ({
/>
<Text>Cells to update</Text>
<TableList<Cell>
initialItems={options.cellsToUpsert}
initialItems={options.cellsToUpsert ?? { byId: {}, allIds: [] }}
onItemsChange={handleUpsertColumnsChange}
Item={UpdatingCellItem}
addLabel="Add a value"
Expand All @@ -186,7 +186,7 @@ const ActionOptions = ({
/>
<Text>Cells to extract</Text>
<TableList<ExtractingCell>
initialItems={options.cellsToExtract}
initialItems={options.cellsToExtract ?? { byId: {}, allIds: [] }}
onItemsChange={handleExtractingCellsChange}
Item={ExtractingCellItem}
addLabel="Add a value"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ export const SheetsDropdown = ({
selectedItem={currentSheet?.name}
items={(sheets ?? []).map((s) => s.name)}
onValueChange={handleSpreadsheetSelect}
placeholder={isLoading ? 'Loading...' : 'Select the sheet'}
isDisabled={isLoading}
placeholder={'Select the sheet'}
isLoading={isLoading}
/>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ export const SpreadsheetsDropdown = ({
selectedItem={currentSpreadsheet?.name}
items={(spreadsheets ?? []).map((s) => s.name)}
onValueChange={handleSpreadsheetSelect}
placeholder={isLoading ? 'Loading...' : 'Search for spreadsheet'}
isDisabled={isLoading}
placeholder={'Search for spreadsheet'}
isLoading={isLoading}
/>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export const NumberInputSettingsBody = ({
<DebouncedInput
id="placeholder"
initialValue={options.labels.placeholder}
delay={100}
onChange={handlePlaceholderChange}
/>
</Stack>
Expand All @@ -48,7 +47,6 @@ export const NumberInputSettingsBody = ({
<DebouncedInput
id="button"
initialValue={options?.labels?.button ?? 'Send'}
delay={100}
onChange={handleButtonLabelChange}
/>
</Stack>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export const PhoneNumberSettingsBody = ({
<DebouncedInput
id="placeholder"
initialValue={options.labels.placeholder}
delay={100}
onChange={handlePlaceholderChange}
/>
</Stack>
Expand All @@ -40,7 +39,6 @@ export const PhoneNumberSettingsBody = ({
<DebouncedInput
id="button"
initialValue={options.labels.button}
delay={100}
onChange={handleButtonLabelChange}
/>
</Stack>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { FormLabel, Stack } from '@chakra-ui/react'
import { DebouncedInput } from 'components/shared/DebouncedInput'
import { SwitchWithLabel } from 'components/shared/SwitchWithLabel'
import { InputWithVariableButton } from 'components/shared/TextboxWithVariableButton'
import { RedirectOptions } from 'models'
import React from 'react'

Expand All @@ -21,11 +22,10 @@ export const RedirectSettings = ({ options, onOptionsChange }: Props) => {
<FormLabel mb="0" htmlFor="tracking-id">
Url:
</FormLabel>
<DebouncedInput
<InputWithVariableButton
id="tracking-id"
initialValue={options.url ?? ''}
placeholder="Type a URL..."
delay={100}
onChange={handleUrlChange}
/>
</Stack>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export const SetVariableSettingsBody = ({
<DebouncedTextarea
id="expression"
initialValue={options.expressionToEvaluate ?? ''}
delay={100}
onChange={handleExpressionChange}
/>
</Stack>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export const TextInputSettingsBody = ({
<DebouncedInput
id="placeholder"
initialValue={options.labels.placeholder}
delay={100}
onChange={handlePlaceholderChange}
/>
</Stack>
Expand All @@ -49,7 +48,6 @@ export const TextInputSettingsBody = ({
<DebouncedInput
id="button"
initialValue={options.labels.button}
delay={100}
onChange={handleButtonLabelChange}
/>
</Stack>
Expand Down
Loading

2 comments on commit 73f277f

@vercel
Copy link

@vercel vercel bot commented on 73f277f Jan 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

builder-v2 – ./apps/builder

next.typebot.io
builder-v2-typebot-io.vercel.app
builder-v2-git-main-typebot-io.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 73f277f Jan 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

viewer-v2 – ./apps/viewer

typebot-io.vercel.app
viewer-v2-git-main-typebot-io.vercel.app
viewer-v2-typebot-io.vercel.app

Please sign in to comment.