Track HiveGrid Cloud planning reference
This commit is contained in:
1 parent
b3d5ea6764
commit
e341c5938a
5784 files changed
+1104929
-3
No files matched your search
@@ -0,0 +1,98 @@
|
||||
import { expect, test } from "./utils/test";
|
||||
import { expectNoCriticalA11yViolations } from "./utils/axe";
|
||||
import { getTenantCredentials, loginAsTenantUser, tenantRolesAndPermissionsPath } from "./utils/auth";
|
||||
import { compactMobileViewport, expectNoHorizontalOverflow, narrowMobileViewport } from "./utils/mobile";
|
||||
import { escapeRegExp, interceptCurrentRoutePost, postDataIncludesField, 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 mobile a11y", () => {
|
||||
test.use({ isMobile: true, hasTouch: true });
|
||||
|
||||
test.beforeEach(() => {
|
||||
skipOrFailWhenE2eInputsMissing(
|
||||
["E2E_TENANT_EMAIL", "E2E_TENANT_PASSWORD", "E2E_TENANT_DASHBOARD_PATH"],
|
||||
"Tenant roles and permissions mobile E2E inputs not configured"
|
||||
);
|
||||
if (!rolesAndPermissionsPath) {
|
||||
skipOrFailWhenE2eFixtureMissing("Tenant roles and permissions path could not be derived; set E2E_TENANT_ROLES_AND_PERMISSIONS_PATH");
|
||||
}
|
||||
});
|
||||
|
||||
for (const viewport of [narrowMobileViewport, compactMobileViewport]) {
|
||||
test(`keeps users, roles, and permissions usable at ${viewport.width}px`, async ({ page }) => {
|
||||
await page.setViewportSize(viewport);
|
||||
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('[data-ui-id="ui.settings.rolesAndPermissions.users"] table').first()).toBeVisible();
|
||||
|
||||
const firstRoleToggle = page.locator('[data-ui-id="ui.settings.rolesAndPermissions.users.roleToggle"]').first();
|
||||
if ((await firstRoleToggle.count()) > 0) {
|
||||
await expect(firstRoleToggle).toHaveAccessibleName(/assign|unassign|zuweisen|entziehen/i);
|
||||
}
|
||||
await expectNoHorizontalOverflow(page);
|
||||
await expectNoCriticalA11yViolations(page);
|
||||
|
||||
// The tab bar collapses to a <select> below md (TabsVertical), so the tab
|
||||
// <a> links are hidden on mobile. Navigate the sub-pages directly to verify
|
||||
// each is usable at this viewport (what this test asserts).
|
||||
await page.goto(rolesPath, { waitUntil: "domcontentloaded" });
|
||||
await expect(page).toHaveURL(new RegExp(`${escapeRegExp(rolesPath)}(?:[?#].*)?$`, "u"));
|
||||
await expect(page.locator('[data-ui-id="ui.settings.rolesAndPermissions.roles"] table').first()).toBeVisible();
|
||||
// The "new role" control is permission-gated and may not render for this
|
||||
// fixture; assert it only when present (matches the desktop spec's scope).
|
||||
const rolesNew = page.locator('[data-ui-id="ui.settings.rolesAndPermissions.roles.new"]').first();
|
||||
if ((await rolesNew.count()) > 0) {
|
||||
await expect(rolesNew).toBeVisible();
|
||||
}
|
||||
await expectNoHorizontalOverflow(page);
|
||||
await expectNoCriticalA11yViolations(page);
|
||||
|
||||
await page.goto(permissionsPath, { waitUntil: "domcontentloaded" });
|
||||
await expect(page).toHaveURL(new RegExp(`${escapeRegExp(permissionsPath)}(?:[?#].*)?$`, "u"));
|
||||
await expect(page.locator('[data-ui-id="ui.settings.rolesAndPermissions.permissions"] table').first()).toBeVisible();
|
||||
await expect(page.locator('[data-ui-id="ui.settings.rolesAndPermissions.permissions.table"]').first()).toBeVisible();
|
||||
await expectNoHorizontalOverflow(page);
|
||||
await expectNoCriticalA11yViolations(page);
|
||||
});
|
||||
}
|
||||
|
||||
test("submits the mobile role toggle contract without mutating fixture data", async ({ page }) => {
|
||||
await page.setViewportSize(narrowMobileViewport);
|
||||
await loginAsTenantUser(page, credentials!);
|
||||
|
||||
const usersPath = `${rolesAndPermissionsPath}/users`;
|
||||
const response = await page.goto(usersPath, { waitUntil: "domcontentloaded" });
|
||||
await skipIfUnavailable(page, response, `Tenant roles and permissions users path ${usersPath}`);
|
||||
|
||||
const roleToggle = page.locator('[data-ui-id="ui.settings.rolesAndPermissions.users.roleToggle"]:not([disabled])').first();
|
||||
if ((await roleToggle.count()) === 0 || !(await roleToggle.isVisible())) {
|
||||
skipOrFailWhenE2eFixtureMissing("Tenant roles fixture has no enabled role toggle for mobile contract coverage");
|
||||
}
|
||||
|
||||
await expect(roleToggle).toHaveAccessibleName(/assign|unassign|zuweisen|entziehen/i);
|
||||
const submitted = await interceptCurrentRoutePost(page, { status: 204 });
|
||||
await roleToggle.tap();
|
||||
|
||||
await expect.poll(() => submitted.value, { message: "role toggle POST payload was captured" }).not.toBeNull();
|
||||
expect(postDataIncludesField(submitted.value, "action", /^edit$/u)).toBe(true);
|
||||
expect(postDataIncludesField(submitted.value, "user-id", /.+/u)).toBe(true);
|
||||
expect(postDataIncludesField(submitted.value, "role-id", /.+/u)).toBe(true);
|
||||
expect(postDataIncludesField(submitted.value, "add", /^(true|false)$/u)).toBe(true);
|
||||
expect(postDataIncludesField(submitted.value, "csrf", /.+/u)).toBe(true);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user