2
0

feat(engine): Link typebot step

This commit is contained in:
Baptiste Arnaud
2022-03-09 15:12:00 +01:00
parent 1bcc8aee10
commit 7e61ab19eb
61 changed files with 1272 additions and 245 deletions

View File

@ -0,0 +1,102 @@
{
"id": "cl0j7q9el0032b51al3rx6jo7",
"createdAt": "2022-03-09T07:01:25.917Z",
"updatedAt": "2022-03-09T07:01:25.917Z",
"name": "My typebot",
"ownerId": "cl0cfi60r0000381a2bft9yis",
"publishedTypebotId": null,
"folderId": null,
"blocks": [
{
"id": "jPVDjQ5go4ZxmGCmApbcQf",
"steps": [
{
"id": "nrCKsAYzbCogJanfxUavUV",
"type": "start",
"label": "Start",
"blockId": "jPVDjQ5go4ZxmGCmApbcQf",
"outgoingEdgeId": "8MazLBx8HbfKeYLADQkA3z"
}
],
"title": "Start",
"graphCoordinates": { "x": 0, "y": 0 }
},
{
"id": "nyD3H7h6tEZqDmGwGciGV4",
"graphCoordinates": { "x": 428, "y": 168 },
"title": "Block #1",
"steps": [
{
"id": "s8Pz7fPg4niG1JcvBS3CwAs",
"blockId": "nyD3H7h6tEZqDmGwGciGV4",
"type": "Typebot link",
"options": {}
}
]
},
{
"id": "jMbvgRQfXUaXg37LRNqRaJ",
"graphCoordinates": { "x": 423, "y": 386 },
"title": "Hello",
"steps": [
{
"id": "scE368YFYn9cWU1RkQDFLUW",
"blockId": "jMbvgRQfXUaXg37LRNqRaJ",
"type": "text",
"content": {
"html": "<div>Hello world</div>",
"richText": [
{ "type": "p", "children": [{ "text": "Hello world" }] }
],
"plainText": "Hello world"
}
},
{
"id": "sem1do43KTkuvf49eqWcMgc",
"blockId": "jMbvgRQfXUaXg37LRNqRaJ",
"type": "text input",
"options": {
"isLong": false,
"labels": { "button": "Send", "placeholder": "Type your answer..." }
}
}
]
}
],
"variables": [],
"edges": [
{
"from": {
"blockId": "jPVDjQ5go4ZxmGCmApbcQf",
"stepId": "nrCKsAYzbCogJanfxUavUV"
},
"to": { "blockId": "nyD3H7h6tEZqDmGwGciGV4" },
"id": "8MazLBx8HbfKeYLADQkA3z"
}
],
"theme": {
"chat": {
"inputs": {
"color": "#303235",
"backgroundColor": "#FFFFFF",
"placeholderColor": "#9095A0"
},
"buttons": { "color": "#FFFFFF", "backgroundColor": "#0042DA" },
"hostBubbles": { "color": "#303235", "backgroundColor": "#F7F8FF" },
"guestBubbles": { "color": "#FFFFFF", "backgroundColor": "#FF8E21" }
},
"general": { "font": "Open Sans", "background": { "type": "None" } }
},
"settings": {
"general": {
"isBrandingEnabled": true,
"isNewResultOnRefreshEnabled": false
},
"metadata": {
"description": "Build beautiful conversational forms and embed them directly in your applications without a line of code. Triple your response rate and collect answers that has more value compared to a traditional form."
},
"typingEmulation": { "speed": 300, "enabled": true, "maxDelay": 1.5 }
},
"publicId": null,
"customDomain": null
}

View File

@ -0,0 +1,105 @@
{
"id": "cl0iecee90042961arm5kb0f0",
"createdAt": "2022-03-08T17:18:50.337Z",
"updatedAt": "2022-03-08T21:05:28.825Z",
"name": "Another typebot",
"ownerId": "cl0cfi60r0000381a2bft9yis",
"publishedTypebotId": null,
"folderId": null,
"blocks": [
{
"id": "p4ByLVoKiDRyRoPHKmcTfw",
"steps": [
{
"id": "rw6smEWEJzHKbiVKLUKFvZ",
"type": "start",
"label": "Start",
"blockId": "p4ByLVoKiDRyRoPHKmcTfw",
"outgoingEdgeId": "1z3pfiatTUHbraD2uSoA3E"
}
],
"title": "Start",
"graphCoordinates": { "x": 0, "y": 0 }
},
{
"id": "bg4QEJseUsTP496H27j5k2",
"steps": [
{
"id": "s8ZeBL9p5za77eBmdKECLYq",
"type": "text input",
"blockId": "bg4QEJseUsTP496H27j5k2",
"options": {
"isLong": false,
"labels": { "button": "Send", "placeholder": "Type your answer..." }
},
"outgoingEdgeId": "aEBnubX4EMx4Cse6xPAR1m"
}
],
"title": "Block #1",
"graphCoordinates": { "x": 366, "y": 191 }
},
{
"id": "uhqCZSNbsYVFxop7Gc8xvn",
"steps": [
{
"id": "smyHyeS6yaFaHHU44BNmN4n",
"type": "text",
"blockId": "uhqCZSNbsYVFxop7Gc8xvn",
"content": {
"html": "<div>Second block</div>",
"richText": [
{ "type": "p", "children": [{ "text": "Second block" }] }
],
"plainText": "Second block"
}
}
],
"title": "Block #2",
"graphCoordinates": { "x": 793, "y": 99 }
}
],
"variables": [],
"edges": [
{
"id": "1z3pfiatTUHbraD2uSoA3E",
"to": { "blockId": "bg4QEJseUsTP496H27j5k2" },
"from": {
"stepId": "rw6smEWEJzHKbiVKLUKFvZ",
"blockId": "p4ByLVoKiDRyRoPHKmcTfw"
}
},
{
"id": "aEBnubX4EMx4Cse6xPAR1m",
"to": { "blockId": "uhqCZSNbsYVFxop7Gc8xvn" },
"from": {
"stepId": "s8ZeBL9p5za77eBmdKECLYq",
"blockId": "bg4QEJseUsTP496H27j5k2"
}
}
],
"theme": {
"chat": {
"inputs": {
"color": "#303235",
"backgroundColor": "#FFFFFF",
"placeholderColor": "#9095A0"
},
"buttons": { "color": "#FFFFFF", "backgroundColor": "#0042DA" },
"hostBubbles": { "color": "#303235", "backgroundColor": "#F7F8FF" },
"guestBubbles": { "color": "#FFFFFF", "backgroundColor": "#FF8E21" }
},
"general": { "font": "Open Sans", "background": { "type": "None" } }
},
"settings": {
"general": {
"isBrandingEnabled": true,
"isNewResultOnRefreshEnabled": false
},
"metadata": {
"description": "Build beautiful conversational forms and embed them directly in your applications without a line of code. Triple your response rate and collect answers that has more value compared to a traditional form."
},
"typingEmulation": { "speed": 300, "enabled": true, "maxDelay": 1.5 }
},
"publicId": null,
"customDomain": null
}

View File

@ -169,8 +169,8 @@ const parseTestTypebot = (partialTypebot: Partial<Typebot>): Typebot => ({
theme: defaultTheme,
settings: defaultSettings,
publicId: null,
updatedAt: new Date(),
createdAt: new Date(),
updatedAt: new Date().toISOString(),
createdAt: new Date().toISOString(),
publishedTypebotId: null,
customDomain: null,
variables: [{ id: 'var1', name: 'var1' }],

View File

@ -80,7 +80,7 @@ test.describe.parallel('Image bubble step', () => {
await page.click('text=Click to edit...')
await page.click('text=Giphy')
await page.click('img >> nth=3')
await page.click('img >> nth=3', { force: true })
await expect(page.locator('img[alt="Step image"]')).toHaveAttribute(
'src',
new RegExp('giphy.com/media', 'gm')

View File

@ -0,0 +1,62 @@
import test, { expect } from '@playwright/test'
import { typebotViewer } from '../../services/selectorUtils'
import { generate } from 'short-uuid'
import { importTypebotInDatabase } from '../../services/database'
import path from 'path'
test('should be configurable', async ({ page }) => {
const typebotId = generate()
const linkedTypebotId = generate()
await importTypebotInDatabase(
path.join(__dirname, '../../fixtures/typebots/logic/linkTypebots/1.json'),
{ id: typebotId }
)
await importTypebotInDatabase(
path.join(__dirname, '../../fixtures/typebots/logic/linkTypebots/2.json'),
{ id: linkedTypebotId }
)
await page.goto(`/typebots/${typebotId}/edit`)
await page.click('text=Configure...')
await page.click('input[placeholder="Select a typebot"]')
await page.click('text=Another typebot')
await expect(page.locator('input[value="Another typebot"]')).toBeVisible()
await page.click('[aria-label="Navigate to typebot"]')
await expect(page).toHaveURL(
`/typebots/${linkedTypebotId}/edit?parentId=${typebotId}`
)
await page.click('[aria-label="Navigate back"]')
await expect(page).toHaveURL(`/typebots/${typebotId}/edit`)
await page.click('text=Jump in Another typebot')
await expect(page.locator('input[value="Another typebot"]')).toBeVisible()
await page.click('input[placeholder="Select a block"]')
await page.click('text=Block #2')
await page.click('text=Preview')
await expect(typebotViewer(page).locator('text=Second block')).toBeVisible()
await page.click('[aria-label="Close"]')
await page.click('text=Jump to Block #2 in Another typebot')
await page.click('input[value="Block #2"]', { clickCount: 3 })
await page.press('input[value="Block #2"]', 'Backspace')
await page.click('button >> text=Start')
await page.click('text=Preview')
await typebotViewer(page).locator('input').fill('Hello there!')
await typebotViewer(page).locator('input').press('Enter')
await expect(typebotViewer(page).locator('text=Hello there!')).toBeVisible()
await page.click('[aria-label="Close"]')
await page.click('text=Jump to Start in Another typebot')
await page.click('input[value="Another typebot"]', { clickCount: 3 })
await page.press('input[value="Another typebot"]', 'Backspace')
await page.click('button >> text=My typebot')
await page.click('input[placeholder="Select a block"]', {
clickCount: 3,
})
await page.press('input[placeholder="Select a block"]', 'Backspace')
await page.click('button >> text=Hello')
await page.click('text=Preview')
await expect(typebotViewer(page).locator('text=Hello world')).toBeVisible()
})

View File

@ -43,7 +43,7 @@ test.describe.parallel('Settings page', () => {
await page.click('button:has-text("Typing emulation")')
await page.fill('[data-testid="speed"] input', '350')
await page.fill('[data-testid="max-delay"] input', '1.5')
await page.uncheck(':nth-match(input[type="checkbox"], 2)', {
await page.uncheck('input[type="checkbox"] >> nth=-1', {
force: true,
})
await expect(page.locator('[data-testid="speed"]')).toBeHidden()