feat(engine): ✨ Link typebot step
This commit is contained in:
74
apps/viewer/playwright/fixtures/typebots/linkTypebots/1.json
Normal file
74
apps/viewer/playwright/fixtures/typebots/linkTypebots/1.json
Normal file
@ -0,0 +1,74 @@
|
||||
{
|
||||
"id": "cl0ibhi7s0018n21aarlmg0cm",
|
||||
"createdAt": "2022-03-08T15:58:49.720Z",
|
||||
"updatedAt": "2022-03-08T16:07:18.899Z",
|
||||
"name": "My typebot",
|
||||
"ownerId": "cl0cfi60r0000381a2bft9yis",
|
||||
"publishedTypebotId": null,
|
||||
"folderId": null,
|
||||
"blocks": [
|
||||
{
|
||||
"id": "1qQrnsLzRim1LqCrhbj1MW",
|
||||
"steps": [
|
||||
{
|
||||
"id": "8srsGhdBJK8v88Xo1RRS4C",
|
||||
"type": "start",
|
||||
"label": "Start",
|
||||
"blockId": "1qQrnsLzRim1LqCrhbj1MW",
|
||||
"outgoingEdgeId": "ovUHhwr6THMhqtn8QbkjtA"
|
||||
}
|
||||
],
|
||||
"title": "Start",
|
||||
"graphCoordinates": { "x": 0, "y": 0 }
|
||||
},
|
||||
{
|
||||
"id": "wSR4VCcDNDTTsD9Szi2xH8",
|
||||
"steps": [
|
||||
{
|
||||
"id": "sw6nHJfkMsM4pxZxMBB6QqW",
|
||||
"type": "Typebot link",
|
||||
"blockId": "wSR4VCcDNDTTsD9Szi2xH8",
|
||||
"options": { "typebotId": "cl0ibhv8d0130n21aw8doxhj5" }
|
||||
}
|
||||
],
|
||||
"title": "Block #1",
|
||||
"graphCoordinates": { "x": 363, "y": 199 }
|
||||
}
|
||||
],
|
||||
"variables": [],
|
||||
"edges": [
|
||||
{
|
||||
"id": "ovUHhwr6THMhqtn8QbkjtA",
|
||||
"to": { "blockId": "wSR4VCcDNDTTsD9Szi2xH8" },
|
||||
"from": {
|
||||
"stepId": "8srsGhdBJK8v88Xo1RRS4C",
|
||||
"blockId": "1qQrnsLzRim1LqCrhbj1MW"
|
||||
}
|
||||
}
|
||||
],
|
||||
"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
|
||||
}
|
77
apps/viewer/playwright/fixtures/typebots/linkTypebots/2.json
Normal file
77
apps/viewer/playwright/fixtures/typebots/linkTypebots/2.json
Normal file
@ -0,0 +1,77 @@
|
||||
{
|
||||
"id": "cl0ibhv8d0130n21aw8doxhj5",
|
||||
"createdAt": "2022-03-08T15:59:06.589Z",
|
||||
"updatedAt": "2022-03-08T15:59:10.498Z",
|
||||
"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",
|
||||
"graphCoordinates": { "x": 366, "y": 191 },
|
||||
"title": "Block #1",
|
||||
"steps": [
|
||||
{
|
||||
"id": "s8ZeBL9p5za77eBmdKECLYq",
|
||||
"blockId": "bg4QEJseUsTP496H27j5k2",
|
||||
"type": "text input",
|
||||
"options": {
|
||||
"isLong": false,
|
||||
"labels": { "button": "Send", "placeholder": "Type your answer..." }
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"variables": [],
|
||||
"edges": [
|
||||
{
|
||||
"from": {
|
||||
"blockId": "p4ByLVoKiDRyRoPHKmcTfw",
|
||||
"stepId": "rw6smEWEJzHKbiVKLUKFvZ"
|
||||
},
|
||||
"to": { "blockId": "bg4QEJseUsTP496H27j5k2" },
|
||||
"id": "1z3pfiatTUHbraD2uSoA3E"
|
||||
}
|
||||
],
|
||||
"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
|
||||
}
|
18
apps/viewer/playwright/proUser.json
Normal file
18
apps/viewer/playwright/proUser.json
Normal file
@ -0,0 +1,18 @@
|
||||
{
|
||||
"cookies": [],
|
||||
"origins": [
|
||||
{
|
||||
"origin": "http://localhost:3000",
|
||||
"localStorage": [
|
||||
{
|
||||
"name": "authenticatedUser",
|
||||
"value": "{\"id\":\"proUser\",\"name\":\"Pro user\",\"email\":\"pro-user@email.com\",\"emailVerified\":null,\"image\":\"https://avatars.githubusercontent.com/u/16015833?v=4\",\"plan\":\"PRO\",\"stripeId\":null}"
|
||||
},
|
||||
{
|
||||
"name": "typebot-20-modal",
|
||||
"value": "hide"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
@ -13,9 +13,11 @@ const prisma = new PrismaClient()
|
||||
export const teardownDatabase = async () => {
|
||||
try {
|
||||
await prisma.user.delete({
|
||||
where: { id: 'user' },
|
||||
where: { id: 'proUser' },
|
||||
})
|
||||
} catch {}
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -24,7 +26,7 @@ export const setupDatabase = () => createUser()
|
||||
export const createUser = () =>
|
||||
prisma.user.create({
|
||||
data: {
|
||||
id: 'user',
|
||||
id: 'proUser',
|
||||
email: 'user@email.com',
|
||||
name: 'User',
|
||||
apiToken: 'userToken',
|
||||
@ -73,13 +75,13 @@ const parseTestTypebot = (partialTypebot: Partial<Typebot>): Typebot => ({
|
||||
id: partialTypebot.id ?? 'typebot',
|
||||
folderId: null,
|
||||
name: 'My typebot',
|
||||
ownerId: 'user',
|
||||
ownerId: 'proUser',
|
||||
theme: defaultTheme,
|
||||
settings: defaultSettings,
|
||||
publicId: partialTypebot.id + '-public',
|
||||
publishedTypebotId: null,
|
||||
updatedAt: new Date(),
|
||||
createdAt: new Date(),
|
||||
updatedAt: new Date().toISOString(),
|
||||
createdAt: new Date().toISOString(),
|
||||
customDomain: null,
|
||||
variables: [{ id: 'var1', name: 'var1' }],
|
||||
...partialTypebot,
|
||||
@ -135,7 +137,7 @@ export const importTypebotInDatabase = async (
|
||||
const typebot: any = {
|
||||
...JSON.parse(readFileSync(path).toString()),
|
||||
...updates,
|
||||
ownerId: 'user',
|
||||
ownerId: 'proUser',
|
||||
}
|
||||
await prisma.typebot.create({
|
||||
data: typebot,
|
||||
|
29
apps/viewer/playwright/tests/typebotLink.spec.ts
Normal file
29
apps/viewer/playwright/tests/typebotLink.spec.ts
Normal file
@ -0,0 +1,29 @@
|
||||
import test, { expect } from '@playwright/test'
|
||||
import path from 'path'
|
||||
import { importTypebotInDatabase } from '../services/database'
|
||||
import { typebotViewer } from '../services/selectorUtils'
|
||||
|
||||
test('should work as expected', async ({ page }) => {
|
||||
const typebotId = 'cl0ibhi7s0018n21aarlmg0cm'
|
||||
const linkedTypebotId = 'cl0ibhv8d0130n21aw8doxhj5'
|
||||
await importTypebotInDatabase(
|
||||
path.join(__dirname, '../fixtures/typebots/linkTypebots/1.json'),
|
||||
{ id: typebotId, publicId: `${typebotId}-public` }
|
||||
)
|
||||
await importTypebotInDatabase(
|
||||
path.join(__dirname, '../fixtures/typebots/linkTypebots/2.json'),
|
||||
{ id: linkedTypebotId, publicId: `${linkedTypebotId}-public` }
|
||||
)
|
||||
|
||||
await page.goto(`/${typebotId}-public`)
|
||||
await typebotViewer(page).locator('input').fill('Hello there!')
|
||||
await typebotViewer(page).locator('input').press('Enter')
|
||||
await page.waitForResponse(
|
||||
(resp) =>
|
||||
resp.request().url().includes(`/api/typebots/t/results`) &&
|
||||
resp.status() === 200 &&
|
||||
resp.request().method() === 'PUT'
|
||||
)
|
||||
await page.goto(`http://localhost:3000/typebots/${typebotId}/results`)
|
||||
await expect(page.locator('text=Hello there!')).toBeVisible()
|
||||
})
|
Reference in New Issue
Block a user