2
0

feat(editor): Code step

This commit is contained in:
Baptiste Arnaud
2022-03-07 17:39:57 +01:00
parent b2784f19fd
commit e3e07ddd4d
13 changed files with 239 additions and 16 deletions

View File

@ -0,0 +1,101 @@
{
"id": "ckz8hnw7m10833no1ar12eov20",
"createdAt": "2022-02-04T14:14:21.394Z",
"updatedAt": "2022-02-04T14:14:21.394Z",
"name": "My typebot",
"ownerId": "ckz6t9iep0006k31a22j05fwq",
"publishedTypebotId": null,
"folderId": null,
"blocks": [
{
"id": "tdN9VXcdBWpuh6Gpaz3w4u",
"steps": [
{
"id": "cVRL5EuVruTK31SAaVCvNE",
"type": "start",
"label": "Start",
"blockId": "tdN9VXcdBWpuh6Gpaz3w4u",
"outgoingEdgeId": "jqZYCYGxaL8svJbM2h1QAn"
}
],
"title": "Start",
"graphCoordinates": { "x": 0, "y": 0 }
},
{
"id": "vymPUjL9AcWpkg9PkUXovk",
"graphCoordinates": { "x": 685, "y": 194 },
"title": "Block #1",
"steps": [
{
"id": "sa8WhnrMyMjYCBMeozfYRoi",
"blockId": "vymPUjL9AcWpkg9PkUXovk",
"type": "Code",
"options": { "name": "Code snippet" }
}
]
},
{
"id": "rEJ3PhFQc7diJ23jdoF6w7",
"graphCoordinates": { "x": 294, "y": 201 },
"title": "Block #2",
"steps": [
{
"id": "s7QRApVZmVFZgS53CNruBRz",
"blockId": "rEJ3PhFQc7diJ23jdoF6w7",
"type": "choice input",
"options": { "buttonLabel": "Send", "isMultipleChoice": false },
"items": [
{
"id": "5rWR3enRg6jZyFhtmgbPYo",
"stepId": "s7QRApVZmVFZgS53CNruBRz",
"type": 0,
"content": "Trigger code",
"outgoingEdgeId": "6aVDkPMEsadze2vf4mLiYt"
}
]
}
]
}
],
"variables": [],
"edges": [
{
"from": {
"blockId": "tdN9VXcdBWpuh6Gpaz3w4u",
"stepId": "cVRL5EuVruTK31SAaVCvNE"
},
"to": { "blockId": "rEJ3PhFQc7diJ23jdoF6w7" },
"id": "jqZYCYGxaL8svJbM2h1QAn"
},
{
"from": {
"blockId": "rEJ3PhFQc7diJ23jdoF6w7",
"stepId": "s7QRApVZmVFZgS53CNruBRz",
"itemId": "5rWR3enRg6jZyFhtmgbPYo"
},
"to": { "blockId": "vymPUjL9AcWpkg9PkUXovk" },
"id": "6aVDkPMEsadze2vf4mLiYt"
}
],
"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 },
"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
}

View File

@ -0,0 +1,29 @@
import test, { expect } from '@playwright/test'
import path from 'path'
import { typebotViewer } from '../../services/selectorUtils'
import { importTypebotInDatabase } from '../../services/database'
import { generate } from 'short-uuid'
const typebotId = generate()
test.describe('Code step', () => {
test('code should trigger', async ({ page }) => {
await importTypebotInDatabase(
path.join(__dirname, '../../fixtures/typebots/logic/code.json'),
{
id: typebotId,
}
)
await page.goto(`/typebots/${typebotId}/edit`)
await page.click('text=Configure...')
await page.fill(
'div[role="textbox"]',
'window.location.href = "https://www.google.com"'
)
await page.click('text=Preview')
await typebotViewer(page).locator('text=Trigger code').click()
await expect(page).toHaveURL('https://www.google.com')
})
})