60 lines
3.0 KiB
TypeScript
60 lines
3.0 KiB
TypeScript
import { expect, test } from "./utils/test";
|
|
import { expectNoCriticalA11yViolations } from "./utils/axe";
|
|
import { getTenantCredentials, loginAsTenantUser, tenantSettingsAuditExportPath } from "./utils/auth";
|
|
import { compactMobileViewport, expectNoHorizontalOverflow, narrowMobileViewport } from "./utils/mobile";
|
|
import { escapeRegExp, skipIfUnavailable } from "./utils/navigation";
|
|
import { skipOrFailWhenE2eFixtureMissing, skipOrFailWhenE2eInputsMissing } from "./utils/readiness";
|
|
|
|
const credentials = getTenantCredentials();
|
|
const dashboardPath = process.env.E2E_TENANT_DASHBOARD_PATH;
|
|
const auditExportPath = process.env.E2E_TENANT_AUDIT_EXPORT_PATH ?? (dashboardPath ? tenantSettingsAuditExportPath(dashboardPath) : undefined);
|
|
|
|
test.describe("tenant audit export mobile a11y", () => {
|
|
test.use({ isMobile: true, hasTouch: true });
|
|
|
|
test.beforeEach(() => {
|
|
skipOrFailWhenE2eInputsMissing(["E2E_TENANT_EMAIL", "E2E_TENANT_PASSWORD", "E2E_TENANT_DASHBOARD_PATH"], "Tenant audit export E2E inputs not configured");
|
|
if (!auditExportPath) {
|
|
skipOrFailWhenE2eFixtureMissing("Tenant audit export path could not be derived; set E2E_TENANT_AUDIT_EXPORT_PATH");
|
|
}
|
|
});
|
|
|
|
for (const viewport of [narrowMobileViewport, compactMobileViewport]) {
|
|
test(`keeps compliance export filters usable at ${viewport.width}px`, async ({ page }) => {
|
|
await page.setViewportSize(viewport);
|
|
await loginAsTenantUser(page, credentials!);
|
|
|
|
const response = await page.goto(auditExportPath!, { waitUntil: "domcontentloaded" });
|
|
await skipIfUnavailable(page, response, `Tenant audit export path ${auditExportPath}`);
|
|
await expect(page).toHaveURL(new RegExp(`${escapeRegExp(auditExportPath!)}(?:[?#].*)?$`, "u"));
|
|
|
|
const auditExport = page.locator('[data-ui-id="ui.audit.export"]').first();
|
|
const form = auditExport.locator('[data-ui-id="ui.audit.export.form"]').first();
|
|
const from = form.locator('input[name="from"]');
|
|
const to = form.locator('input[name="to"]');
|
|
const regulatoryScope = form.locator('select[name="regulatoryScope"]');
|
|
const actorType = form.locator('select[name="actorType"]');
|
|
const outcome = form.locator('select[name="outcome"]');
|
|
|
|
await expect(auditExport).toBeVisible();
|
|
await expect(form).toBeVisible();
|
|
await expect(from).toBeVisible();
|
|
await expect(to).toBeVisible();
|
|
await expect(regulatoryScope).toBeAttached();
|
|
await expect(actorType).toBeAttached();
|
|
await expect(outcome).toBeAttached();
|
|
await expect(form.locator('[data-ui-id="ui.audit.export.csv"]')).toBeVisible();
|
|
await expect(form.locator('[data-ui-id="ui.audit.export.pdf"]')).toBeVisible();
|
|
|
|
await from.fill("2026-01-01");
|
|
await to.fill("2026-01-31");
|
|
await regulatoryScope.selectOption("soc2", { force: true });
|
|
await actorType.selectOption("user", { force: true });
|
|
await outcome.selectOption("success", { force: true });
|
|
|
|
await expectNoHorizontalOverflow(page);
|
|
await expectNoCriticalA11yViolations(page);
|
|
});
|
|
}
|
|
});
|