2
0

feat(engine): 🚸 Improve input variable behaviour (for loops)

This commit is contained in:
Baptiste Arnaud
2022-03-10 12:05:34 +01:00
parent 2c1f69439b
commit 91239779f7
10 changed files with 199 additions and 17 deletions

View File

@ -0,0 +1,119 @@
{
"id": "cl0kvckdk2754en1avz0i71k0",
"createdAt": "2022-03-10T10:50:23.912Z",
"updatedAt": "2022-03-10T10:50:23.912Z",
"name": "My typebot",
"ownerId": "cl0cfi60r0000381a2bft9yis",
"publishedTypebotId": null,
"folderId": null,
"blocks": [
{
"id": "cAvp3oQUNYcANvcEQEVSpD",
"steps": [
{
"id": "bAkhPioPM1uAda6K2aJzHD",
"type": "start",
"label": "Start",
"blockId": "cAvp3oQUNYcANvcEQEVSpD",
"outgoingEdgeId": "2V3HtAH5fSAm6fyYzCyotq"
}
],
"title": "Start",
"graphCoordinates": { "x": 0, "y": 0 }
},
{
"id": "8KLYVvRVGVHRQGJHHe2YPv",
"graphCoordinates": { "x": 362, "y": 96 },
"title": "Block #1",
"steps": [
{
"id": "s7QbNUSgojnka9v9LX7Tp7L",
"blockId": "8KLYVvRVGVHRQGJHHe2YPv",
"type": "Set variable",
"options": {
"variableId": "htYvG7crtdjpsZ6XKTh1PM",
"expressionToEvaluate": "Baptiste"
},
"outgoingEdgeId": "7kKfQWo6xFy97cTwV7B2w7"
}
]
},
{
"id": "4H8ucvLjTiQ7sAyB23Huka",
"graphCoordinates": { "x": 723, "y": 203 },
"title": "Block #2",
"steps": [
{
"id": "s4xoCc33mHyKv6hbVWd8MLo",
"blockId": "4H8ucvLjTiQ7sAyB23Huka",
"type": "text",
"content": {
"html": "<div>What&#x27;s your name?</div>",
"richText": [
{ "type": "p", "children": [{ "text": "What's your name?" }] }
],
"plainText": "What's your name?"
}
},
{
"id": "s5AjAPTMbUbhYxVTjSNwQuJ",
"blockId": "4H8ucvLjTiQ7sAyB23Huka",
"type": "text input",
"options": {
"isLong": false,
"labels": {
"button": "Send",
"placeholder": "Type your answer..."
},
"variableId": "htYvG7crtdjpsZ6XKTh1PM"
}
}
]
}
],
"variables": [{ "id": "htYvG7crtdjpsZ6XKTh1PM", "name": "Name" }],
"edges": [
{
"from": {
"blockId": "cAvp3oQUNYcANvcEQEVSpD",
"stepId": "bAkhPioPM1uAda6K2aJzHD"
},
"to": { "blockId": "8KLYVvRVGVHRQGJHHe2YPv" },
"id": "2V3HtAH5fSAm6fyYzCyotq"
},
{
"from": {
"blockId": "8KLYVvRVGVHRQGJHHe2YPv",
"stepId": "s7QbNUSgojnka9v9LX7Tp7L"
},
"to": { "blockId": "4H8ucvLjTiQ7sAyB23Huka" },
"id": "7kKfQWo6xFy97cTwV7B2w7"
}
],
"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,
"isInputPrefillEnabled": 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
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 394 KiB

View File

@ -1,4 +1,5 @@
import test, { expect } from '@playwright/test'
import { defaultTextInputOptions } from 'models'
import path from 'path'
import { generate } from 'short-uuid'
import { importTypebotInDatabase } from '../services/database'
@ -9,11 +10,12 @@ test.describe.parallel('Settings page', () => {
test('should reflect change in real-time', async ({ page }) => {
const typebotId = generate()
await importTypebotInDatabase(
path.join(__dirname, '../fixtures/typebots/theme.json'),
path.join(__dirname, '../fixtures/typebots/settings.json'),
{
id: typebotId,
}
)
await page.goto(`/typebots/${typebotId}/settings`)
await expect(
typebotViewer(page).locator('a:has-text("Made with Typebot")')
@ -23,10 +25,24 @@ test.describe.parallel('Settings page', () => {
await expect(
typebotViewer(page).locator('a:has-text("Made with Typebot")')
).toBeHidden()
await page.click('text=Create new session on page refresh')
await expect(
page.locator('input[type="checkbox"] >> nth=-1')
).toHaveAttribute('checked', '')
await expect(
typebotViewer(page).locator('input[value="Baptiste"]')
).toBeVisible()
await page.click('text=Prefill input')
await page.click('text=Theme')
await page.waitForTimeout(1000)
await page.click('text=Settings')
await expect(
typebotViewer(page).locator(
`input[placeholder="${defaultTextInputOptions.labels.placeholder}"]`
)
).toHaveValue('')
})
})
@ -34,7 +50,7 @@ test.describe.parallel('Settings page', () => {
test('should be fillable', async ({ page }) => {
const typebotId = generate()
await importTypebotInDatabase(
path.join(__dirname, '../fixtures/typebots/theme.json'),
path.join(__dirname, '../fixtures/typebots/settings.json'),
{
id: typebotId,
}
@ -57,7 +73,7 @@ test.describe.parallel('Settings page', () => {
const imageUrl = 'https://www.baptistearno.com/images/site-preview.png'
const typebotId = 'metadata-typebot'
await importTypebotInDatabase(
path.join(__dirname, '../fixtures/typebots/theme.json'),
path.join(__dirname, '../fixtures/typebots/settings.json'),
{
id: typebotId,
}
@ -101,7 +117,7 @@ test.describe.parallel('Settings page', () => {
test("can't remove branding", async ({ page }) => {
const typebotId = 'free-branding-typebot'
await importTypebotInDatabase(
path.join(__dirname, '../fixtures/typebots/theme.json'),
path.join(__dirname, '../fixtures/typebots/settings.json'),
{
id: typebotId,
}