From 9e080f271654febb8a83b8e785aa35e51955d21a Mon Sep 17 00:00:00 2001 From: Nathan Vasse Date: Mon, 27 Jul 2026 17:16:25 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=85(frontend)=20cover=20the=20homepage=20?= =?UTF-8?q?messages=20widget=20button?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The homepage shows the messages widget button when the widget is configured. A test ensures the loader init command is queued and the loader script is injected, so a config regression cannot silently remove the button. --- .../e2e/__tests__/app-drive/help-menu.spec.ts | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/frontend/apps/e2e/__tests__/app-drive/help-menu.spec.ts b/src/frontend/apps/e2e/__tests__/app-drive/help-menu.spec.ts index 1bee8c2b..8ef8b28f 100644 --- a/src/frontend/apps/e2e/__tests__/app-drive/help-menu.spec.ts +++ b/src/frontend/apps/e2e/__tests__/app-drive/help-menu.spec.ts @@ -139,6 +139,37 @@ test.describe("Help menu", () => { expect(openedUrls).toEqual([]); }); + test("shows the messages widget button on the homepage when configured", async ({ + page, + }) => { + const widgetPath = "https://widget.example.com/"; + await overrideHelpMenuConfig(page, HELP_MENU_CONFIG, { + FRONTEND_FEEDBACK_MESSAGES_WIDGET_API_URL: "https://widget.example.com/api/", + FRONTEND_FEEDBACK_MESSAGES_WIDGET_PATH: widgetPath, + FRONTEND_FEEDBACK_MESSAGES_WIDGET_CHANNEL: "drive", + }); + // Serve an empty loader script so the injected loader does not hit the + // network for real. + await page.route(`${widgetPath}loader.js`, (route) => + route.fulfill({ contentType: "application/javascript", body: "" }), + ); + // No login: the home page only renders for anonymous users, and it is + // where the widget button is shown. + await page.goto("/"); + + // The button loader queues an init call and injects its loader script. + await expect( + page.locator(`script[src="${widgetPath}loader.js"]`), + ).toHaveCount(1); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const widgetCalls = await page.evaluate(() => (window as any)._stmsg_widget); + expect(widgetCalls).toHaveLength(1); + expect(widgetCalls[0][0]).toBe("loader"); + expect(widgetCalls[0][1]).toBe("init"); + expect(widgetCalls[0][2].params.channel).toBe("drive"); + expect(widgetCalls[0][2].script).toBe(`${widgetPath}feedback.js`); + }); + test("does not render the help menu when the config is empty", async ({ page, }) => {