Files
HiveGrid-Wireframes/03 Quellen und Referenzen/hivegrid-cloud/tests/e2e/tenant-roles-permissions.desktop-a11y.spec.ts
T

67 lines
3.7 KiB
TypeScript

import { expect, test } from "./utils/test";
import { expectNoCriticalA11yViolations } from "./utils/axe";
import {
getTenantCredentials,
loginAsTenantUser,
tenantLegacyRolesAndPermissionsPath,
tenantRolesAndPermissionsPath,
tenantSettingsMembersPath,
} from "./utils/auth";
import { expectNoHorizontalOverflow } from "./utils/mobile";
import { escapeRegExp, skipIfUnavailable } from "./utils/navigation";
import { skipOrFailWhenE2eFixtureMissing, skipOrFailWhenE2eInputsMissing } from "./utils/readiness";
// R-P2b (D-P2 Admin RBAC): one merged "Rollen und Berechtigungen" tab (S02).
// The old users/permissions sub-tabs redirect (matrix → members, permissions →
// roles); the S01/S02 tab bar links members and roles.
const credentials = getTenantCredentials();
const dashboardPath = process.env.E2E_TENANT_DASHBOARD_PATH;
const rolesAndPermissionsPath = process.env.E2E_TENANT_ROLES_AND_PERMISSIONS_PATH ?? (dashboardPath ? tenantRolesAndPermissionsPath(dashboardPath) : undefined);
const legacyRolesAndPermissionsPath = dashboardPath ? tenantLegacyRolesAndPermissionsPath(dashboardPath) : undefined;
const membersPath = process.env.E2E_TENANT_MEMBERS_PATH ?? (dashboardPath ? tenantSettingsMembersPath(dashboardPath) : undefined);
test.describe("tenant roles and permissions desktop a11y", () => {
test.use({ viewport: { width: 1440, height: 900 } });
test.beforeEach(() => {
skipOrFailWhenE2eInputsMissing(
["E2E_TENANT_EMAIL", "E2E_TENANT_PASSWORD", "E2E_TENANT_DASHBOARD_PATH"],
"Tenant roles and permissions E2E inputs not configured"
);
if (!rolesAndPermissionsPath || !legacyRolesAndPermissionsPath || !membersPath) {
skipOrFailWhenE2eFixtureMissing("Tenant roles and permissions path could not be derived; set E2E_TENANT_ROLES_AND_PERMISSIONS_PATH");
}
});
test("renders the merged roles tab without desktop overflow or critical a11y violations", async ({ page }) => {
await loginAsTenantUser(page, credentials!);
const response = await page.goto(rolesAndPermissionsPath!, { waitUntil: "domcontentloaded" });
await skipIfUnavailable(page, response, `Tenant roles and permissions path ${rolesAndPermissionsPath}`);
// The helper resolves directly to the canonical Team-Hub roles tab.
await expect(page).toHaveURL(new RegExp(`${escapeRegExp(rolesAndPermissionsPath!)}(?:[?#].*)?$`, "u"));
await expect(page.locator('[data-ui-id="ui.settings.hub.team"]').first()).toBeVisible();
await expect(page.locator('[data-ui-id="ui.settings.rolesAndPermissions.roles"] table').first()).toBeVisible();
await expect(page.locator('[data-ui-id="ui.settings.rolesAndPermissions.roles.filter"]').first()).toBeVisible();
// S01/S02 tab bar: link back to the members tab.
await expect(page.locator('[data-ui-id="ui.settings.hub.team.tab.members"]').first()).toBeVisible();
await expectNoHorizontalOverflow(page);
await expectNoCriticalA11yViolations(page);
});
test("redirects the legacy users and permissions sub-tabs", async ({ page }) => {
await loginAsTenantUser(page, credentials!);
const usersResponse = await page.goto(`${legacyRolesAndPermissionsPath!}/users`, { waitUntil: "domcontentloaded" });
await skipIfUnavailable(page, usersResponse, `Tenant roles users path ${legacyRolesAndPermissionsPath}/users`);
// Matrix is superseded by the inline role dropdown in the members list (D01).
await expect(page).toHaveURL(new RegExp(`${escapeRegExp(membersPath!)}(?:[?#].*)?$`, "u"));
await page.goto(`${legacyRolesAndPermissionsPath!}/permissions`, { waitUntil: "domcontentloaded" });
await expect(page).toHaveURL(new RegExp(`${escapeRegExp(rolesAndPermissionsPath!)}(?:[?#].*)?$`, "u"));
});
});