From 2f674b96d2fb89fe11bc27ff6eff66373ae1fe79 Mon Sep 17 00:00:00 2001 From: Baptiste Arnaud Date: Tue, 17 Mar 2026 14:49:59 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=9A=20Fix=20e2e=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/viewer/src/test/cards.spec.ts | 2 +- apps/viewer/src/test/transcript.spec.ts | 38 +++---------------- .../bot-engine/src/computeResultTranscript.ts | 30 +++++++++++---- 3 files changed, 29 insertions(+), 41 deletions(-) diff --git a/apps/viewer/src/test/cards.spec.ts b/apps/viewer/src/test/cards.spec.ts index 7adc10625..6c7b6c77a 100644 --- a/apps/viewer/src/test/cards.spec.ts +++ b/apps/viewer/src/test/cards.spec.ts @@ -17,7 +17,7 @@ test("should work as expected", async ({ page }) => { await page.getByRole("button", { name: "Previous slide" }).click(); await expect(page.getByRole("heading", { name: "Paris" })).toBeVisible(); await page.getByRole("button", { name: "More info" }).nth(0).click(); - await expect(page.getByRole("img", { name: "Attached image" })).toBeVisible(); + await expect(page.getByRole("img", { name: "Title 1" })).toBeVisible(); await expect(page.getByRole("heading", { name: "Title 1" })).toBeVisible(); await expect(page.getByText("Desc 1")).toBeVisible(); await expect(page.getByRole("heading", { name: "Title 2" })).toBeVisible(); diff --git a/apps/viewer/src/test/transcript.spec.ts b/apps/viewer/src/test/transcript.spec.ts index d8b40de22..6685584cf 100644 --- a/apps/viewer/src/test/transcript.spec.ts +++ b/apps/viewer/src/test/transcript.spec.ts @@ -24,38 +24,12 @@ test("Transcript set variable should be correctly computed", async ({ await page.getByPlaceholder("Type your answer...").fill("hey 3"); await page.getByLabel("Send").click(); await expect( - page.getByTestId("guest-bubble").getByText("hey 3"), - ).toBeVisible(); - await expect( - page.getByText('Assistant: "How are you? You said "'), - ).toBeVisible(); - await expect( - page.getByText('Assistant: "How are you? You said hey"'), - ).toBeVisible(); - await expect( - page.getByText('Assistant: "How are you? You said hey 2"'), - ).toBeVisible(); - await expect( - page.getByText('Assistant: "Let me think..."', { exact: true }).nth(0), - ).toBeVisible(); - await expect( - page.getByText('Assistant: "Let me think..."', { exact: true }).nth(1), - ).toBeVisible(); - await expect( - page.getByText('Assistant: "Let me think..."', { exact: true }).nth(2), - ).toBeVisible(); - await expect( - page.getByText('Assistant: "How are you? You said "', { exact: true }), - ).toBeVisible(); - await expect( - page.getByText('Assistant: "How are you? You said hey"', { exact: true }), - ).toBeVisible(); - await expect( - page.getByText('Assistant: "How are you? You said hey 2"', { exact: true }), - ).toBeVisible(); - await expect(page.getByText('User: "hey"', { exact: true })).toBeVisible(); - await expect(page.getByText('User: "hey 2"', { exact: true })).toBeVisible(); - await expect(page.getByText('User: "hey 3"', { exact: true })).toBeVisible(); + page.getByText( + 'Assistant: "Let me think..."Assistant: "How are you? You said "User: "hey"', + ), + ).toHaveText( + 'Assistant: "Let me think..."Assistant: "How are you? You said "User: "hey"Assistant: "Let me think..."Assistant: "How are you? You said hey"User: "hey 2"Assistant: "Let me think..."Assistant: "How are you? You said hey 2"User: "hey 3"', + ); }); test("Transcript set variable should work in loop example", async ({ diff --git a/packages/bot-engine/src/computeResultTranscript.ts b/packages/bot-engine/src/computeResultTranscript.ts index 73b103005..2be0cae88 100644 --- a/packages/bot-engine/src/computeResultTranscript.ts +++ b/packages/bot-engine/src/computeResultTranscript.ts @@ -197,13 +197,7 @@ const executeGroup = ({ const { answers, setVariableHistory, visitedEdges } = queues; for (const block of nextGroup.group.blocks.slice(nextGroup.blockIndex ?? 0)) { - if ( - currentBlockId && - block.id === currentBlockId && - !answers.peek() && - !setVariableHistory.peek() && - !visitedEdges.peek() - ) + if (currentBlockId && block.id === currentBlockId && !answers.peek()) return currentTranscript; const typebot = typebotsQueue[0]?.typebot; @@ -218,6 +212,7 @@ const executeGroup = ({ } let nextEdgeId = block.outgoingEdgeId; + let nextReturnEdgeId = returnEdgeId; // ──────────────────────────────────────────────────────────── Bubble blocks if (isBubbleBlock(block)) { @@ -406,6 +401,25 @@ const executeGroup = ({ blockId: block.options.blockId, }, }); + const currentBlockIndex = nextGroup.group.blocks.findIndex( + (b) => b.id === block.id, + ); + const nextBlockInGroup = nextGroup.group.blocks.at(currentBlockIndex + 1); + if (nextBlockInGroup) { + const returnVirtualEdgeId = createVirtualEdgeId({ + groupId: nextGroup.group.id, + blockId: nextBlockInGroup.id, + }); + typebotsQueue[0].typebot.edges.push({ + id: returnVirtualEdgeId, + from: { blockId: block.id }, + to: { + groupId: nextGroup.group.id, + blockId: nextBlockInGroup.id, + }, + }); + nextReturnEdgeId = returnVirtualEdgeId; + } nextEdgeId = virtualId; } else if (block.type === LogicBlockType.RETURN && returnEdgeId) { nextEdgeId = returnEdgeId; @@ -473,7 +487,7 @@ const executeGroup = ({ currentBlockId, sessionStore, userMessageIndex, - returnEdgeId, + returnEdgeId: nextReturnEdgeId, debug, }); }