// AK-P21 — smoke for the privacy interim screens (AD-28): hub, export jobs, // tenant deletion, subprocessors, AVV. Non-mutating: dialogs are opened and // closed again, no export is started and no deletion is requested. Admin // sub-areas are permission-gated; the smoke only visits sections whose entry // cards the hub actually shows for the test user. import { expect, test, type Page } from "./utils/test"; import { getTenantCredentials, loginAsTenantUser } from "./utils/auth"; import { expectNoCriticalA11yViolations } from "./utils/axe"; import { compactMobileViewport, expectNoHorizontalOverflow } from "./utils/mobile"; import { skipOrFailWhenE2eFixtureMissing, skipOrFailWhenE2eInputsMissing } from "./utils/readiness"; const credentials = getTenantCredentials(); const dashboardPath = process.env.E2E_TENANT_DASHBOARD_PATH ?? "/app/dashboard"; const privacyPath = process.env.E2E_TENANT_PRIVACY_PATH ?? tenantPath("settings/profile/data"); const SECTION_PAGES = { export: "ui.settings.privacy.exportJobs.page", deletion: "ui.settings.privacy.deletion.page", subprocessors: "ui.settings.privacy.subprocessors.page", avv: "ui.settings.privacy.avv.page", } as const; type SectionKey = keyof typeof SECTION_PAGES; const SECTION_PATHS: Record = { export: tenantPath("settings/compliance/data-export"), deletion: tenantPath("settings/compliance/tenant-deletion"), subprocessors: tenantPath("settings/compliance/subprocessors"), avv: tenantPath("settings/compliance/avv"), }; test.describe("AK-P21 privacy interim smoke", () => { test("renders the privacy hub with self-service controls", async ({ page }) => { requireTenantLoginInputs("Privacy hub smoke inputs not configured"); await loginAsTenantUser(page, credentials!); const response = await page.goto(privacyPath, { waitUntil: "domcontentloaded" }); expect(response?.ok(), `Privacy hub returned ${response?.status() ?? "no response"}`).toBe(true); await expect(page.locator('[data-ui-id="ui.settings.privacy.page"]').first()).toBeVisible(); await expect(page.locator('[data-ui-id="ui.settings.privacy.export.form"]').first()).toBeVisible(); const deleteForm = page.locator('[data-ui-id="ui.settings.privacy.delete.form"]').first(); const reactivateForm = page.locator('[data-ui-id="ui.settings.privacy.reactivate.form"]').first(); await expect.poll(async () => (await deleteForm.count()) + (await reactivateForm.count())).toBeGreaterThan(0); await expectNoHorizontalOverflow(page); await expectNoCriticalA11yViolations(page); }); test("opens the permission-gated admin sections from the hub", async ({ page }) => { requireTenantLoginInputs("Privacy sections smoke inputs not configured"); await loginAsTenantUser(page, credentials!); for (const section of Object.keys(SECTION_PAGES) as SectionKey[]) { const visible = await visitSectionFromHub(page, section); if (!visible) continue; await expect( page.locator(`[data-ui-id="${SECTION_PAGES[section]}"], [data-ui-id="ui.settings.privacy.${sectionUiKey(section)}.empty"]`).first() ).toBeVisible(); await expectNoHorizontalOverflow(page); await expectNoCriticalA11yViolations(page); } }); test("opens and closes the export start dialog without mutating data", async ({ page }) => { requireTenantLoginInputs("Privacy export smoke inputs not configured"); await loginAsTenantUser(page, credentials!); const visible = await visitSectionFromHub(page, "export"); if (!visible) { skipOrFailWhenE2eFixtureMissing("Export section is not visible for the test user"); } const start = page.locator('[data-ui-id="ui.settings.privacy.exportJobs.startUser"], [data-ui-id="ui.settings.privacy.exportJobs.startEmpty"]').first(); if ((await start.count()) > 0 && (await start.isEnabled())) { await start.click(); await expect(page.locator('[data-ui-id="ui.settings.privacy.exportJobs.startDialog"]')).toBeVisible(); await page.keyboard.press("Escape"); await expect(page.locator('[data-ui-id="ui.settings.privacy.exportJobs.startDialog"]')).toBeHidden(); } }); test("opens and closes the tenant deletion wizard without submitting", async ({ page }) => { requireTenantLoginInputs("Privacy deletion smoke inputs not configured"); await loginAsTenantUser(page, credentials!); const visible = await visitSectionFromHub(page, "deletion"); if (!visible) { skipOrFailWhenE2eFixtureMissing("Deletion section is not visible for the test user"); } const open = page.locator('[data-ui-id="ui.settings.privacy.deletion.open"]'); if ((await open.count()) > 0 && (await open.isVisible()) && (await open.isEnabled())) { await open.click(); await expect(page.locator('[data-ui-id="ui.settings.privacy.deletion.wizard"]')).toBeVisible(); await page.keyboard.press("Escape"); await expect(page.locator('[data-ui-id="ui.settings.privacy.deletion.wizard"]')).toBeHidden(); } else { // A pending request shows the grace banner with the cancel action instead. await expect(page.locator('[data-ui-id="ui.settings.privacy.deletion.grace"]')).toBeVisible(); } }); }); test.describe("AK-P21 privacy compact mobile smoke", () => { test.use({ viewport: compactMobileViewport, isMobile: true, hasTouch: true }); test("keeps the privacy hub and visible sections readable at 320px", async ({ page }) => { requireTenantLoginInputs("Privacy compact mobile inputs not configured"); await loginAsTenantUser(page, credentials!); const response = await page.goto(privacyPath, { waitUntil: "domcontentloaded" }); expect(response?.ok(), `Privacy hub returned ${response?.status() ?? "no response"}`).toBe(true); await expect(page.locator('[data-ui-id="ui.settings.privacy.page"]').first()).toBeVisible(); await expectNoHorizontalOverflow(page); await expectNoCriticalA11yViolations(page); for (const section of Object.keys(SECTION_PAGES) as SectionKey[]) { const visible = await visitSectionFromHub(page, section); if (!visible) continue; await expectNoHorizontalOverflow(page); await expectNoCriticalA11yViolations(page); } }); }); function sectionUiKey(section: SectionKey): string { return section === "export" ? "exportJobs" : section; } async function visitSectionFromHub(page: Page, section: SectionKey): Promise { const response = await page.goto(privacyPath, { waitUntil: "domcontentloaded" }); expect(response?.ok(), `Privacy hub returned ${response?.status() ?? "no response"}`).toBe(true); const openButton = page.locator(`[data-ui-id="ui.settings.privacy.sections.${section}.open"]`); if ((await openButton.count()) === 0) return false; await Promise.all([page.waitForURL((url) => url.pathname === SECTION_PATHS[section]), openButton.click()]); const pageUiId = SECTION_PAGES[section]; const emptyUiId = pageUiId.replace(/\.page$/u, ".empty"); await expect(page.locator(`[data-ui-id="${pageUiId}"], [data-ui-id="${emptyUiId}"]`).first()).toBeVisible(); return true; } function requireTenantLoginInputs(reason: string): void { skipOrFailWhenE2eInputsMissing(["E2E_TENANT_EMAIL", "E2E_TENANT_PASSWORD", "E2E_TENANT_DASHBOARD_PATH"], reason); } function tenantPath(path: string): string { const normalizedDashboard = dashboardPath.startsWith("/") ? dashboardPath : `/${dashboardPath}`; const marker = "/dashboard"; const tenantBase = normalizedDashboard.endsWith(marker) ? normalizedDashboard.slice(0, -marker.length) : "/app"; return `${tenantBase}/${path}`; }