From 601ddf3c070d152a81bfd2df86a57d1ceaef700b Mon Sep 17 00:00:00 2001 From: Baptiste Arnaud Date: Wed, 16 Apr 2025 21:59:36 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=91=EF=B8=8F=20Fix=20edge=20case=20whe?= =?UTF-8?q?n=20calling=20link=20to=20typebot=20after=20input?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/test/assets/typebots/linkTypebots/1.json | 12 ++++++++++-- apps/viewer/src/test/typebotLink.spec.ts | 2 ++ packages/bot-engine/src/walkFlowForward.ts | 4 +++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/apps/viewer/src/test/assets/typebots/linkTypebots/1.json b/apps/viewer/src/test/assets/typebots/linkTypebots/1.json index 6598e49fc..9a63a8278 100644 --- a/apps/viewer/src/test/assets/typebots/linkTypebots/1.json +++ b/apps/viewer/src/test/assets/typebots/linkTypebots/1.json @@ -16,6 +16,14 @@ "title": "Group #1", "graphCoordinates": { "x": 363, "y": 199 }, "blocks": [ + { + "id": "py3nbq24fal5hgvzlejibzkd", + "type": "text", + "content": { + "richText": [{ "type": "p", "children": [{ "text": "Hey!" }] }] + } + }, + { "id": "r26l9tdez17sgx4xiwku15mk", "type": "text input" }, { "id": "y3ptzm07xpl272zhokvjoqa4", "type": "Typebot link", @@ -36,8 +44,8 @@ }, { "id": "vs65r7x7budygdfg9vhxcq7m", - "graphCoordinates": { "x": -8, "y": 458 }, "title": "Group #2", + "graphCoordinates": { "x": -8, "y": 458 }, "blocks": [ { "id": "t4u8h07eq17f6oqmsydcqyaj", @@ -84,7 +92,7 @@ } }, "createdAt": "2022-03-08T15:58:49.720Z", - "updatedAt": "2022-03-08T16:07:18.899Z", + "updatedAt": "2025-04-16T19:56:24.043Z", "icon": null, "folderId": null, "publicId": "cl0ibhi7s0018n21aarlmg0cm-public", diff --git a/apps/viewer/src/test/typebotLink.spec.ts b/apps/viewer/src/test/typebotLink.spec.ts index b2fab39fc..df1f37d14 100644 --- a/apps/viewer/src/test/typebotLink.spec.ts +++ b/apps/viewer/src/test/typebotLink.spec.ts @@ -31,6 +31,8 @@ test.beforeAll(async () => { test("should work as expected", async ({ page }) => { await page.goto(`/${typebotId}-public`); + await page.getByPlaceholder("Type your answer...").fill("Start"); + await page.getByPlaceholder("Type your answer...").press("Enter"); await expect(page.getByText("First test message")).toBeVisible(); await page.getByPlaceholder("Type your answer...").fill("Hello there!"); await page.getByPlaceholder("Type your answer...").press("Enter"); diff --git a/packages/bot-engine/src/walkFlowForward.ts b/packages/bot-engine/src/walkFlowForward.ts index 8c1141661..4928615e9 100644 --- a/packages/bot-engine/src/walkFlowForward.ts +++ b/packages/bot-engine/src/walkFlowForward.ts @@ -68,9 +68,11 @@ export const walkFlowForward = async ( let nextEdge: { id: string; isOffDefaultPath: boolean } | undefined = startingPoint.type === "nextEdge" ? startingPoint.nextEdge : undefined; + let i = -1; do { + i += 1; const nextGroupResponse = - startingPoint.type === "group" && !nextEdge + i === 0 && startingPoint.type === "group" && !nextEdge ? { group: startingPoint.group, newSessionState,