From eee9ba1c138f0c88c772ea284a5a97a46cb9412c Mon Sep 17 00:00:00 2001 From: Jeppe B <2jepp9350@gmail.com> Date: Sun, 2 Aug 2026 12:24:36 +0200 Subject: [PATCH] Fix localized forbidden assertions in full E2E (#243) Use the stable localized forbidden-page contract in customer, subuser, and superuser denial tests while retaining the protected-action and zero-request assertions. --- tests/e2e/subuser-management.spec.ts | 9 ++++++--- tests/e2e/superuser-customer-rules.spec.ts | 4 +++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/tests/e2e/subuser-management.spec.ts b/tests/e2e/subuser-management.spec.ts index 77208548..c8605f83 100644 --- a/tests/e2e/subuser-management.spec.ts +++ b/tests/e2e/subuser-management.spec.ts @@ -1571,7 +1571,9 @@ test("customer user without own-subuser permissions cannot access the chauffør await mockManagementApi(page, { userPermissions: ["user"] }); await page.goto("/user/subusers"); - await expect(page.getByRole("heading", { name: "403 Forbidden" }).first()).toBeVisible(); + const forbidden = page.getByTestId("restricted-forbidden"); + await expect(forbidden).toBeVisible(); + await expect(forbidden.getByRole("heading", { name: "403" })).toBeVisible(); await expect(page.getByRole("button", { name: /Invit.*chauff/i })).toHaveCount(0); }); @@ -1923,6 +1925,7 @@ test("subusers without SUBUSERS_LIST cannot access the chauffør page", async ({ await page.goto("/user/subusers"); - await expect(page.getByRole("heading", { name: "403 Forbidden" }).first()).toBeVisible(); - await expect(page.getByRole("heading", { name: "You do not have permission to view this page." })).toBeVisible(); + const forbidden = page.getByTestId("restricted-forbidden"); + await expect(forbidden).toBeVisible(); + await expect(forbidden.getByRole("heading", { name: "403" })).toBeVisible(); }); diff --git a/tests/e2e/superuser-customer-rules.spec.ts b/tests/e2e/superuser-customer-rules.spec.ts index 2a17d80c..6397b298 100644 --- a/tests/e2e/superuser-customer-rules.spec.ts +++ b/tests/e2e/superuser-customer-rules.spec.ts @@ -201,7 +201,9 @@ test.describe("Superuser customer rule product restrictions", () => { const deniedPage = await page.context().newPage(); const deniedApi = await setup(deniedPage, ["superuser"]); await deniedPage.goto("/superuser/customer-rules", { waitUntil: "domcontentloaded" }); - await expect(deniedPage.getByText("403 Forbidden", { exact: true }).first()).toBeVisible(); + const forbidden = deniedPage.getByTestId("restricted-forbidden"); + await expect(forbidden).toBeVisible(); + await expect(forbidden.getByRole("heading", { name: "403" })).toBeVisible(); expect(deniedApi.getRequests()).toBe(0); await deniedPage.close(); });