2
0

refactor: ♻️ Rename step to block

This commit is contained in:
Baptiste Arnaud
2022-06-11 07:27:38 +02:00
parent 8751766d0e
commit 2df8338505
297 changed files with 4292 additions and 3989 deletions

View File

@ -2,9 +2,9 @@ import test, { expect } from '@playwright/test'
import {
createTypebots,
importTypebotInDatabase,
parseDefaultBlockWithStep,
parseDefaultGroupWithBlock,
} from '../services/database'
import { defaultTextInputOptions, InputStepType } from 'models'
import { defaultTextInputOptions, InputBlockType } from 'models'
import path from 'path'
import cuid from 'cuid'
import { typebotViewer } from '../services/selectorUtils'
@ -18,25 +18,26 @@ test.describe.parallel('Editor', () => {
},
])
await page.goto(`/typebots/${typebotId}/edit`)
await expect(page.locator("text='Start'")).toBeVisible()
await page.dragAndDrop('text=Button', '#editor-container', {
targetPosition: { x: 800, y: 400 },
})
await page.dragAndDrop(
'text=Text >> nth=0',
'[data-testid="block"] >> nth=1',
'[data-testid="group"] >> nth=1',
{
targetPosition: { x: 100, y: 50 },
}
)
await page.dragAndDrop(
'[data-testid="endpoint"]',
'[data-testid="block"] >> nth=1',
'[data-testid="group"] >> nth=1',
{ targetPosition: { x: 100, y: 10 } }
)
await expect(page.locator('[data-testid="edge"]')).toBeVisible()
await page.dragAndDrop(
'[data-testid="endpoint"]',
'[data-testid="step"] >> nth=1'
'[data-testid="group"] >> nth=1'
)
await expect(page.locator('[data-testid="edge"]')).toBeVisible()
await page.dragAndDrop('text=Date', '#editor-container', {
@ -44,7 +45,7 @@ test.describe.parallel('Editor', () => {
})
await page.dragAndDrop(
'[data-testid="endpoint"] >> nth=2',
'[data-testid="block"] >> nth=2',
'[data-testid="group"] >> nth=2',
{
targetPosition: { x: 100, y: 10 },
}
@ -60,7 +61,7 @@ test.describe.parallel('Editor', () => {
const total = await page.locator('[data-testid="edge"]').count()
expect(total).toBe(1)
})
test('Drag and drop steps and items should work', async ({ page }) => {
test('Drag and drop blocks and items should work', async ({ page }) => {
const typebotId = cuid()
await importTypebotInDatabase(
path.join(__dirname, '../fixtures/typebots/editor/buttonsDnd.json'),
@ -69,19 +70,19 @@ test.describe.parallel('Editor', () => {
}
)
// Steps dnd
// Blocks dnd
await page.goto(`/typebots/${typebotId}/edit`)
await expect(page.locator('[data-testid="step"] >> nth=1')).toHaveText(
await expect(page.locator('[data-testid="block"] >> nth=1')).toHaveText(
'Hello!'
)
await page.dragAndDrop('text=Hello', '[data-testid="step"] >> nth=3', {
await page.dragAndDrop('text=Hello', '[data-testid="block"] >> nth=3', {
targetPosition: { x: 100, y: 0 },
})
await expect(page.locator('[data-testid="step"] >> nth=2')).toHaveText(
await expect(page.locator('[data-testid="block"] >> nth=2')).toHaveText(
'Hello!'
)
await page.dragAndDrop('text=Hello', 'text=Block #2')
await expect(page.locator('[data-testid="step"] >> nth=3')).toHaveText(
await page.dragAndDrop('text=Hello', 'text=Group #2')
await expect(page.locator('[data-testid="block"] >> nth=3')).toHaveText(
'Hello!'
)
@ -106,25 +107,25 @@ test.describe.parallel('Editor', () => {
await createTypebots([
{
id: typebotId,
...parseDefaultBlockWithStep({
type: InputStepType.TEXT,
...parseDefaultGroupWithBlock({
type: InputBlockType.TEXT,
options: defaultTextInputOptions,
}),
},
])
await page.goto(`/typebots/${typebotId}/edit`)
await page.click('text=Block #1', { button: 'right' })
await page.click('text=Group #1', { button: 'right' })
await page.click('text=Duplicate')
await expect(page.locator('text="Block #1"')).toBeVisible()
await expect(page.locator('text="Block #1 copy"')).toBeVisible()
await page.click('text="Block #1"', { button: 'right' })
await expect(page.locator('text="Group #1"')).toBeVisible()
await expect(page.locator('text="Group #1 copy"')).toBeVisible()
await page.click('text="Group #1"', { button: 'right' })
await page.click('text=Delete')
await expect(page.locator('text="Block #1"')).toBeHidden()
await expect(page.locator('text="Group #1"')).toBeHidden()
await page.click('button[aria-label="Undo"]')
await expect(page.locator('text="Block #1"')).toBeVisible()
await expect(page.locator('text="Group #1"')).toBeVisible()
await page.click('button[aria-label="Redo"]')
await expect(page.locator('text="Block #1"')).toBeHidden()
await expect(page.locator('text="Group #1"')).toBeHidden()
})
test('Rename and icon change should work', async ({ page }) => {
@ -133,8 +134,8 @@ test.describe.parallel('Editor', () => {
{
id: typebotId,
name: 'My awesome typebot',
...parseDefaultBlockWithStep({
type: InputStepType.TEXT,
...parseDefaultGroupWithBlock({
type: InputBlockType.TEXT,
options: defaultTextInputOptions,
}),
},