64 lines
2.9 KiB
TypeScript
64 lines
2.9 KiB
TypeScript
import { expect, test } from "./utils/test";
|
|
import { expectNoCriticalA11yViolations } from "./utils/axe";
|
|
import { getTenantCredentials, loginAsTenantUser, tenantSettingsPoliciesPath } 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 policiesPath = process.env.E2E_TENANT_POLICIES_PATH ?? (dashboardPath ? tenantSettingsPoliciesPath(dashboardPath) : undefined);
|
|
|
|
const policyLinks = [
|
|
"settings/team",
|
|
"settings/team/roles",
|
|
"settings/billing",
|
|
"settings/profile/notifications",
|
|
"settings/compliance",
|
|
"settings/integrations/api",
|
|
] as const;
|
|
|
|
const policySections = ["membership", "roles", "billing", "notifications", "audit", "api"] as const;
|
|
|
|
test.describe("tenant governance settings mobile a11y", () => {
|
|
test.use({ isMobile: true, hasTouch: true });
|
|
|
|
test.beforeEach(() => {
|
|
skipOrFailWhenE2eInputsMissing(
|
|
["E2E_TENANT_EMAIL", "E2E_TENANT_PASSWORD", "E2E_TENANT_DASHBOARD_PATH"],
|
|
"Tenant governance settings mobile E2E inputs not configured"
|
|
);
|
|
if (!policiesPath) {
|
|
skipOrFailWhenE2eFixtureMissing("Tenant policies path could not be derived; set E2E_TENANT_POLICIES_PATH");
|
|
}
|
|
});
|
|
|
|
for (const viewport of [narrowMobileViewport, compactMobileViewport]) {
|
|
test(`keeps governance policy links usable at ${viewport.width}px`, async ({ page }) => {
|
|
await page.setViewportSize(viewport);
|
|
await loginAsTenantUser(page, credentials!);
|
|
|
|
const response = await page.goto(policiesPath!, { waitUntil: "domcontentloaded" });
|
|
await skipIfUnavailable(page, response, `Tenant policies path ${policiesPath}`);
|
|
await expect(page).toHaveURL(new RegExp(`${escapeRegExp(policiesPath!)}(?:[?#].*)?$`, "u"));
|
|
|
|
await expect(page.locator('[data-ui-id="ui.settings.policies.page"]').first()).toBeVisible();
|
|
await expect(page.getByRole("heading", { level: 1, name: /workspace|arbeitsbereich/iu })).toBeVisible();
|
|
|
|
const policiesPage = page.locator('[data-ui-id="ui.settings.policies.page"]').first();
|
|
for (const section of policySections) {
|
|
await expect(page.locator(`[data-ui-id="ui.settings.policies.section.${section}"]`).first()).toBeVisible();
|
|
}
|
|
// Scope link assertions to the policies content: the same hrefs also appear
|
|
// in the primary sidebar nav, which is collapsed (display:none) on mobile,
|
|
// so an unscoped `.first()` would resolve to the hidden nav link.
|
|
for (const path of policyLinks) {
|
|
await expect(policiesPage.locator(`a[href$="${path}"]`).first()).toBeVisible();
|
|
}
|
|
|
|
await expectNoHorizontalOverflow(page);
|
|
await expectNoCriticalA11yViolations(page);
|
|
});
|
|
}
|
|
});
|