import { expect, test } from "@playwright/experimental-ct-react"; import AxeBuilder from "@axe-core/playwright"; import { P26bInteractionsInterimVisualFixture, P26bInterimVisualFixture as VisualFixture, type P26bInterimVisualScreen, } from "../../apps/web/app/components/screens/customer-portal/p26b-interim.visual-fixture"; const VISUAL_SCREENS = ["interactions", "lifecycle", "admin", "service-inbox"] as const satisfies readonly P26bInterimVisualScreen[]; const ADMIN_AREAS = [ { tab: "Nutzer", screenshot: "va-p26b-customer-portal-admin-users.png" }, { tab: "Freigaben", screenshot: "va-p26b-customer-portal-admin-releases.png" }, { tab: "Domain & Mail", screenshot: "va-p26b-customer-portal-admin-domain-mail.png" }, ] as const; test.describe("VA-P26b customer portal interim UI pixel baselines", () => { for (const screen of VISUAL_SCREENS) { test(`${screen} stays visually stable in light mode`, async ({ mount, page }) => { const component = await mount(
); await page.evaluate(async () => { await document.fonts.ready; }); await expect(component.locator(`[data-ui-id="${screenUiId(screen)}"]`)).toHaveCount(1); if (screen === "interactions") { await expect(component).toContainText("baustelle.jpg"); await expect(component).toContainText("Reklamation melden"); } if (screen === "admin") await expect(component).toContainText("Einrichtung auf einen Blick"); await expect(component).toHaveScreenshot(`va-p26b-customer-portal-${screen}.png`); }); } for (const area of ADMIN_AREAS) { test(`admin ${area.tab} area stays visually stable in light mode`, async ({ mount, page }) => { const component = await mount(
); await page.evaluate(async () => { await document.fonts.ready; }); await component.getByRole("tab", { name: area.tab }).click(); await expect(component.getByRole("tabpanel")).toBeVisible(); await expect(component).toHaveScreenshot(area.screenshot); }); } test("expanded admin basic settings stay visually stable in light mode", async ({ mount, page }) => { const component = await mount(
); await page.evaluate(async () => { await document.fonts.ready; }); await component.getByRole("button", { name: "Grundeinstellungen bearbeiten" }).click(); await expect(component.getByText("Grundeinstellungen", { exact: true })).toBeVisible(); await expect(component).toHaveScreenshot("va-p26b-customer-portal-admin-basic-settings.png"); }); test("admin areas remain usable without horizontal overflow on mobile", async ({ mount, page }) => { await page.setViewportSize({ width: 390, height: 844 }); const component = await mount(
); for (const name of ["Übersicht", "Nutzer", "Freigaben", "Domain & Mail"]) { await component.getByRole("tab", { name }).click(); expect(await component.evaluate((element) => element.scrollWidth - element.clientWidth)).toBeLessThanOrEqual(1); } }); test("complaint action stays named during the post-submit loading state", async ({ mount, page }) => { const component = await mount(
); const interactions = component.locator('[data-ui-id="ui.customerPortal.projectInteractions"]'); const complaintButton = interactions.getByRole("button", { name: "Reklamation senden" }); await expect(interactions.getByText("Deine Reklamation wurde gespeichert und das Projektteam informiert.")).toBeVisible(); await expect(complaintButton).toBeDisabled(); await expect(complaintButton).toHaveAttribute("aria-label", "Reklamation senden"); const results = await new AxeBuilder({ page }).include('[data-ui-id="ui.customerPortal.projectInteractions"]').withRules(["button-name"]).analyze(); expect(results.violations).toEqual([]); }); }); function screenUiId(screen: (typeof VISUAL_SCREENS)[number]): string { if (screen === "interactions") return "ui.customerPortal.projectInteractions"; if (screen === "lifecycle") return "ui.customerPortal.lifecycle"; if (screen === "admin") return "ui.customerPortal.admin"; return "ui.customerPortal.serviceInbox"; }