58 lines
2.2 KiB
TypeScript
58 lines
2.2 KiB
TypeScript
// @vitest-environment jsdom
|
|
// AK-P21 — INTERIM visual baseline (AD-28). Re-baseline is mandatory when
|
|
// David's final D-P21 Subframe optics replace the interim privacy screens.
|
|
import "@testing-library/jest-dom/vitest";
|
|
import React from "react";
|
|
import { render } from "@testing-library/react";
|
|
import { describe, expect, it, vi } from "vitest";
|
|
|
|
import { AK_P21_INTERIM_VISUAL_SCREENS, AkP21InterimVisualFixture } from "./ak-p21-interim.visual-fixture";
|
|
|
|
vi.mock("react-i18next", () => ({
|
|
useTranslation: () => ({
|
|
t: (key: string, values?: Record<string, unknown>) => (values ? `${key}:${Object.values(values).join("/")}` : key),
|
|
i18n: { language: "de" },
|
|
}),
|
|
}));
|
|
|
|
vi.mock("~/locale/format", () => ({
|
|
useLocaleFormatters: () => ({
|
|
number: (value: number) => String(value),
|
|
currency: (value: number, currency: string) => `${value.toFixed(2)} ${currency}`,
|
|
currencyFromCents: (value: number, currency: string) => `${(value / 100).toFixed(2)} ${currency}`,
|
|
date: (value: string) => value,
|
|
dateTime: (value: string) => value,
|
|
}),
|
|
}));
|
|
|
|
vi.mock("react-router", async () => {
|
|
const actual = await vi.importActual<typeof import("react-router")>("react-router");
|
|
return {
|
|
...actual,
|
|
Form: ({ children, ...props }: React.ComponentProps<"form">) => <form {...props}>{children}</form>,
|
|
// The baseline renders the screens without a router provider; the
|
|
// breadcrumb Link only needs to contribute its href to the snapshot.
|
|
Link: ({ to, children, ...props }: { to: string } & React.ComponentProps<"a">) => (
|
|
<a href={to} {...props}>
|
|
{children}
|
|
</a>
|
|
),
|
|
};
|
|
});
|
|
|
|
describe("AK-P21 interim visual baseline", () => {
|
|
it("renders representative ready states for all five privacy ~/ui screens", () => {
|
|
const { container } = render(
|
|
<main data-ui-id="ui.akP21.interim.visualBaseline">
|
|
{AK_P21_INTERIM_VISUAL_SCREENS.map((screen) => (
|
|
<AkP21InterimVisualFixture key={screen} screen={screen} />
|
|
))}
|
|
</main>
|
|
);
|
|
|
|
expect(container.querySelectorAll("[data-ui-id$='.page']")).toHaveLength(5);
|
|
const stableMarkup = container.innerHTML.replace(/<svg\b[^>]*>[\s\S]*?<\/svg>/gu, '<svg data-visual-icon="true"></svg>');
|
|
expect(stableMarkup).toMatchSnapshot();
|
|
});
|
|
});
|