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.
This commit is contained in:
Jeppe B
2026-08-02 12:24:36 +02:00
committed by GitHub
parent aaecffbdfa
commit eee9ba1c13
2 changed files with 9 additions and 4 deletions
+6 -3
View File
@@ -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();
});
+3 -1
View File
@@ -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();
});