From 009e18dcf396087b202307c2d97cbefc8715344e Mon Sep 17 00:00:00 2001 From: Baptiste Arnaud Date: Wed, 7 May 2025 08:21:29 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20Add=20client=20side=20action=20e2e?= =?UTF-8?q?=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/test/assets/typebots/setVariable.json | 70 +++++++++++++++++++ apps/viewer/src/test/setVariable.spec.ts | 15 ++++ 2 files changed, 85 insertions(+) create mode 100644 apps/viewer/src/test/assets/typebots/setVariable.json create mode 100644 apps/viewer/src/test/setVariable.spec.ts diff --git a/apps/viewer/src/test/assets/typebots/setVariable.json b/apps/viewer/src/test/assets/typebots/setVariable.json new file mode 100644 index 000000000..de49789ae --- /dev/null +++ b/apps/viewer/src/test/assets/typebots/setVariable.json @@ -0,0 +1,70 @@ +{ + "version": "6.1", + "id": "cmadjs01m0001f63rw64lwp1z", + "name": "My typebot", + "events": [ + { + "id": "lhnsbzt5yzoevcsbj1ysfquu", + "graphCoordinates": { "x": 0, "y": 0 }, + "type": "start", + "outgoingEdgeId": "s4r3grxnxmvczspz49uxqc7q" + } + ], + "groups": [ + { + "id": "aa1fpxpe8eeov325fm07q9yq", + "graphCoordinates": { "x": 250, "y": 75 }, + "title": "Group #1", + "blocks": [ + { + "id": "argl00xpck0rrluny8jnwbw3", + "type": "Set variable", + "options": { + "isExecutedOnClient": true, + "isCode": true, + "expressionToEvaluate": "document.location.port", + "variableId": "vggtwtqnbcynlw0b0f52dc6kw" + } + }, + { + "id": "kouofwhknpq3knimbhuk91r0", + "type": "text", + "content": { + "richText": [ + { "type": "p", "children": [{ "text": "{{Location}}" }] } + ] + } + } + ] + } + ], + "edges": [ + { + "from": { "eventId": "lhnsbzt5yzoevcsbj1ysfquu" }, + "to": { "groupId": "aa1fpxpe8eeov325fm07q9yq" }, + "id": "s4r3grxnxmvczspz49uxqc7q" + } + ], + "variables": [ + { + "id": "vggtwtqnbcynlw0b0f52dc6kw", + "name": "Location", + "isSessionVariable": true + } + ], + "theme": {}, + "selectedThemeTemplateId": null, + "settings": {}, + "createdAt": "2025-05-07T06:18:32.890Z", + "updatedAt": "2025-05-07T06:19:09.980Z", + "icon": null, + "folderId": null, + "publicId": null, + "customDomain": null, + "workspaceId": "proWorkspace", + "resultsTablePreferences": null, + "isArchived": false, + "isClosed": false, + "whatsAppCredentialsId": null, + "riskLevel": null +} diff --git a/apps/viewer/src/test/setVariable.spec.ts b/apps/viewer/src/test/setVariable.spec.ts new file mode 100644 index 000000000..e63e53338 --- /dev/null +++ b/apps/viewer/src/test/setVariable.spec.ts @@ -0,0 +1,15 @@ +import test, { expect } from "@playwright/test"; +import { createId } from "@typebot.io/lib/createId"; +import { importTypebotInDatabase } from "@typebot.io/playwright/databaseActions"; +import { getTestAsset } from "./utils/playwright"; + +test("client side exec should work", async ({ page }) => { + const typebotId = createId(); + await importTypebotInDatabase(getTestAsset("typebots/setVariable.json"), { + id: typebotId, + publicId: `${typebotId}-public`, + }); + await page.goto(`/${typebotId}-public`); + + await expect(page.getByText("3001")).toBeVisible(); +});