Files
HiveGrid-Wireframes/03 Quellen und Referenzen/hivegrid-cloud/apps/web/app/components/screens/privacy/PrivacyInterimPages.test.ts
T

96 lines
4.8 KiB
TypeScript

// @vitest-environment node
import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
import { describe, expect, it } from "vitest";
const privacyScreenDir = path.dirname(fileURLToPath(import.meta.url));
function source(file: string): string {
return fs.readFileSync(path.join(privacyScreenDir, file), "utf8");
}
describe("AK-P21 privacy interim screen contracts", () => {
const screens = ["PrivacyHubPage.tsx", "GdprExportJobsPage.tsx", "TenantDeletionPage.tsx", "SubprocessorsPage.tsx", "AvvPage.tsx"];
it.each(screens)("%s separates loading, error, empty, and ready states", (file) => {
const content = source(file);
expect(content).toContain('vm.status === "idle" || vm.status === "loading"');
expect(content).toContain('vm.status === "error"');
expect(content).toContain('vm.status === "empty"');
expect(content).toContain("actions.onRetry");
expect(content).toContain("settings.privacy.states.retry");
});
it.each(screens)("%s stays app-chrome-free and uses synchronized UI components", (file) => {
const content = source(file);
expect(content).toContain('from "~/ui/components/');
expect(content).not.toContain("DefaultPageLayout");
expect(content).not.toContain("EditPageLayout");
expect(content).not.toContain("Sidebar");
});
// Either the screen writes its own <h1>, or it composes the shared PageHeader, which renders it.
it.each(screens)("%s exposes a semantic main heading", (file) => {
const content = source(file);
const usesSharedHeader = content.includes("<PageHeader") && content.includes("shared/PageShell");
expect(usesSharedHeader || (content.includes("<h1") && content.includes("</h1>"))).toBe(true);
});
// AGENTS.md DoD B9 — every privacy screen below the hub must offer a
// breadcrumb back to it, and must take the target as a prop instead of
// reaching into router data itself (DoD A5).
it.each(["GdprExportJobsPage.tsx", "TenantDeletionPage.tsx", "SubprocessorsPage.tsx", "AvvPage.tsx"])("%s carries a breadcrumb back to the privacy hub", (file) => {
const content = source(file);
expect(content).toContain("<PrivacyBreadcrumbs hubHref={hubHref}");
expect(content).toContain("hubHref: string;");
expect(content).not.toContain("useLoaderData");
});
it("renders the breadcrumb trail from the hub title to the current screen", () => {
const breadcrumbs = source("PrivacyBreadcrumbs.tsx");
expect(breadcrumbs).toContain('t("settings.privacy.title")');
expect(breadcrumbs).toContain("{t(titleKey)}");
expect(breadcrumbs).toContain("<Link to={hubHref}>");
expect(breadcrumbs).toContain("Breadcrumbs.Divider");
});
it("keeps the established self-service form contract on the hub", () => {
const hub = source("PrivacyHubPage.tsx");
expect(hub).toContain('uiId="ui.settings.privacy.page"');
expect(hub).toContain('data-ui-id="ui.settings.privacy.export.form"');
expect(hub).toContain('data-ui-id="ui.settings.privacy.delete.form"');
expect(hub).toContain('data-ui-id="ui.settings.privacy.reactivate.form"');
expect(hub).toContain('name="intent" value="export"');
expect(hub).toContain('name="intent" value="delete"');
expect(hub).toContain('name="intent" value="reactivate"');
expect(hub).toContain('name="confirmation"');
expect(hub).toContain('name="csrf"');
});
it("builds the deletion wizard as a real ~/ui Dialog with stepper and slug confirm gate", () => {
const wizard = source("TenantDeletionWizardDialog.tsx");
expect(wizard).toContain('from "~/ui/components/Dialog"');
expect(wizard).toContain("<Dialog.Content");
expect(wizard).toContain("StepperHorizontal");
expect(wizard).toContain("slugConfirm !== tenantSlug");
expect(wizard).toContain('data-ui-id="ui.settings.privacy.deletion.wizard.submit"');
expect(wizard).not.toContain("DefaultPageLayout");
// AD-27: no legacy provider wording in the billing step.
expect(wizard).not.toMatch(/stripe/iu);
});
it("exposes stable selectors for the privacy admin actions", () => {
expect(source("GdprExportJobsPage.tsx")).toContain('data-ui-id="ui.settings.privacy.exportJobs.download"');
expect(source("GdprExportJobsPage.tsx")).toContain('data-ui-id="ui.settings.privacy.exportJobs.startTenant"');
expect(source("TenantDeletionPage.tsx")).toContain('data-ui-id="ui.settings.privacy.deletion.open"');
expect(source("TenantDeletionPage.tsx")).toContain('data-ui-id="ui.settings.privacy.deletion.cancelConfirm"');
expect(source("SubprocessorsPage.tsx")).toContain('data-ui-id="ui.settings.privacy.subprocessors.exportCsv"');
expect(source("AvvPage.tsx")).toContain('data-ui-id="ui.settings.privacy.avv.acceptConfirm"');
});
it.each(screens)("%s avoids raw anchor markup", (file) => {
expect(source(file)).not.toContain("<a ");
});
});