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,89 @@
|
||||
import { expect, test } from "./utils/test";
|
||||
import { expectNoCriticalA11yViolations } from "./utils/axe";
|
||||
import { getTenantCredentials, loginAsTenantUser, tenantSettingsProfilePath } from "./utils/auth";
|
||||
import { 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 profilePath = process.env.E2E_TENANT_SETTINGS_PROFILE_PATH ?? (dashboardPath ? tenantSettingsProfilePath(dashboardPath) : undefined);
|
||||
|
||||
test.describe("profile security mobile a11y", () => {
|
||||
test.use({ viewport: narrowMobileViewport, isMobile: true, hasTouch: true });
|
||||
|
||||
test.beforeEach(() => {
|
||||
skipOrFailWhenE2eInputsMissing(
|
||||
["E2E_TENANT_EMAIL", "E2E_TENANT_PASSWORD", "E2E_TENANT_DASHBOARD_PATH"],
|
||||
"Tenant profile security E2E inputs not configured"
|
||||
);
|
||||
if (!profilePath) {
|
||||
skipOrFailWhenE2eFixtureMissing("Tenant profile path could not be derived; set E2E_TENANT_SETTINGS_PROFILE_PATH");
|
||||
}
|
||||
});
|
||||
|
||||
test("renders security, MFA, session, and danger controls without mobile overflow or critical a11y violations", async ({ page }) => {
|
||||
await loginAsTenantUser(page, credentials!);
|
||||
|
||||
const response = await page.goto(profilePath!, { waitUntil: "domcontentloaded" });
|
||||
await skipIfUnavailable(page, response, `Tenant profile path ${profilePath}`);
|
||||
|
||||
await expect(page).toHaveURL(new RegExp(`${escapeRegExp(profilePath!)}(?:[?#].*)?$`, "u"));
|
||||
await expect(page.locator('[data-ui-id="ui.settings.profile.page"]').first()).toBeVisible();
|
||||
await expect(page.locator('[data-ui-id="ui.settings.profile.form"]').first()).toBeVisible();
|
||||
await expect(page.locator('[data-ui-id="ui.settings.profile.mfa.panel"]').first()).toBeVisible();
|
||||
await expect(page.locator('[data-ui-id="ui.settings.profile.mfa.status"]').first()).toBeVisible();
|
||||
await expect(page.locator('[data-ui-id="ui.settings.profile.mfa.toggle.form"]').first()).toBeVisible();
|
||||
await expect(page.locator('[data-ui-id="ui.settings.profile.password.form"]').first()).toBeVisible();
|
||||
await expect(page.locator('[data-ui-id="ui.settings.profile.session.panel"]').first()).toBeVisible();
|
||||
await expect(page.locator('[data-ui-id="ui.settings.profile.danger.delete"]').first()).toBeVisible();
|
||||
|
||||
await expectNoHorizontalOverflow(page);
|
||||
await expectNoCriticalA11yViolations(page);
|
||||
});
|
||||
|
||||
test("submits password change contract with csrf without mutating data", async ({ page }) => {
|
||||
await loginAsTenantUser(page, credentials!);
|
||||
|
||||
const response = await page.goto(profilePath!, { waitUntil: "domcontentloaded" });
|
||||
await skipIfUnavailable(page, response, `Tenant profile path ${profilePath}`);
|
||||
|
||||
const form = page.locator('[data-ui-id="ui.settings.profile.password.form"]').first();
|
||||
await expect(form).toBeVisible();
|
||||
await form.locator('[data-ui-id="ui.settings.profile.password.current"]').fill("current-password-for-contract");
|
||||
await form.locator('[data-ui-id="ui.settings.profile.password.new"]').fill("NewPassword123!");
|
||||
await form.locator('[data-ui-id="ui.settings.profile.password.confirm"]').fill("NewPassword123!");
|
||||
|
||||
const submitted = await interceptCurrentRoutePost(page, { status: 204 });
|
||||
await form.locator('[data-ui-id="ui.settings.profile.password.submit"]').click();
|
||||
|
||||
await expect.poll(() => submitted.value).not.toBeNull();
|
||||
expect(postDataIncludesField(submitted.value, "action", /^password$/u)).toBe(true);
|
||||
expect(postDataIncludesField(submitted.value, "csrf", /.+/u)).toBe(true);
|
||||
expect(postDataIncludesField(submitted.value, "passwordCurrent", /^current-password-for-contract$/u)).toBe(true);
|
||||
expect(postDataIncludesField(submitted.value, "passwordNew", /^NewPassword123!$/u)).toBe(true);
|
||||
expect(postDataIncludesField(submitted.value, "passwordNewConfirm", /^NewPassword123!$/u)).toBe(true);
|
||||
});
|
||||
|
||||
test("submits MFA toggle contract with csrf without changing enrollment state", async ({ page }) => {
|
||||
await loginAsTenantUser(page, credentials!);
|
||||
|
||||
const response = await page.goto(profilePath!, { waitUntil: "domcontentloaded" });
|
||||
await skipIfUnavailable(page, response, `Tenant profile path ${profilePath}`);
|
||||
|
||||
const form = page.locator('[data-ui-id="ui.settings.profile.mfa.toggle.form"]').first();
|
||||
if ((await form.count()) === 0) {
|
||||
skipOrFailWhenE2eFixtureMissing("Profile MFA toggle form is not visible for this fixture");
|
||||
}
|
||||
await expect(form).toBeVisible();
|
||||
await form.locator('[data-ui-id="ui.settings.profile.mfa.passwordCurrent"]').fill("current-password-for-contract");
|
||||
|
||||
const submitted = await interceptCurrentRoutePost(page, { status: 204 });
|
||||
await form.locator('[data-ui-id="ui.settings.profile.mfa.toggle.submit"]').click();
|
||||
|
||||
await expect.poll(() => submitted.value).not.toBeNull();
|
||||
expect(postDataIncludesField(submitted.value, "action", /^(startTotpEnrollment|disableTotpEnrollment)$/u)).toBe(true);
|
||||
expect(postDataIncludesField(submitted.value, "csrf", /.+/u)).toBe(true);
|
||||
expect(postDataIncludesField(submitted.value, "passwordCurrent", /^current-password-for-contract$/u)).toBe(true);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user