60 lines
3.3 KiB
TypeScript
60 lines
3.3 KiB
TypeScript
import { expect, test } from "./utils/test";
|
|
import { expectNoCriticalA11yViolations } from "./utils/axe";
|
|
import { getTenantCredentials, loginAsTenantUser, tenantRolesAndPermissionsPath } from "./utils/auth";
|
|
import { expectNoHorizontalOverflow } 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 rolesAndPermissionsPath =
|
|
process.env.E2E_TENANT_ROLES_AND_PERMISSIONS_PATH ?? (dashboardPath ? tenantRolesAndPermissionsPath(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) {
|
|
skipOrFailWhenE2eFixtureMissing("Tenant roles and permissions path could not be derived; set E2E_TENANT_ROLES_AND_PERMISSIONS_PATH");
|
|
}
|
|
});
|
|
|
|
test("renders users, roles, and permissions tabs 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}`);
|
|
|
|
const usersPath = `${rolesAndPermissionsPath}/users`;
|
|
const rolesPath = `${rolesAndPermissionsPath}/roles`;
|
|
const permissionsPath = `${rolesAndPermissionsPath}/permissions`;
|
|
|
|
await expect(page).toHaveURL(new RegExp(`${escapeRegExp(usersPath)}(?:[?#].*)?$`, "u"));
|
|
await expect(page.locator('[data-ui-id="ui.settings.rolesAndPermissions.page"]').first()).toBeVisible();
|
|
await expect(page.locator('[data-ui-id="ui.settings.rolesAndPermissions.tabs"]').first()).toBeVisible();
|
|
await expect(page.locator(`a[href$="${usersPath}"]`).first()).toBeVisible();
|
|
await expect(page.locator(`a[href$="${rolesPath}"]`).first()).toBeVisible();
|
|
await expect(page.locator(`a[href$="${permissionsPath}"]`).first()).toBeVisible();
|
|
|
|
await expect(page.locator('[data-ui-id="ui.settings.rolesAndPermissions.users"] table').first()).toBeVisible();
|
|
await expectNoHorizontalOverflow(page);
|
|
await expectNoCriticalA11yViolations(page);
|
|
|
|
await page.locator(`a[href$="${rolesPath}"]`).first().click();
|
|
await expect(page).toHaveURL(new RegExp(`${escapeRegExp(rolesPath)}(?:[?#].*)?$`, "u"));
|
|
await expect(page.locator('[data-ui-id="ui.settings.rolesAndPermissions.roles"] table').first()).toBeVisible();
|
|
await expectNoHorizontalOverflow(page);
|
|
await expectNoCriticalA11yViolations(page);
|
|
|
|
await page.locator(`a[href$="${permissionsPath}"]`).first().click();
|
|
await expect(page).toHaveURL(new RegExp(`${escapeRegExp(permissionsPath)}(?:[?#].*)?$`, "u"));
|
|
await expect(page.locator('[data-ui-id="ui.settings.rolesAndPermissions.permissions"] table').first()).toBeVisible();
|
|
await expectNoHorizontalOverflow(page);
|
|
await expectNoCriticalA11yViolations(page);
|
|
});
|
|
});
|