Track HiveGrid Cloud planning reference

This commit is contained in:
david committed 2026-06-26 20:48:01 +02:00
1 parent b3d5ea6764
commit e341c5938a
5784 files changed
+1104929 -3

No files matched your search

@@ -0,0 +1,145 @@
import { expect, test } from "@playwright/test";
import { expectNoCriticalA11yViolations } from "./utils/axe";
import { expectNoHorizontalOverflow, narrowMobileViewport } from "./utils/mobile";
import { escapeRegExp, interceptCurrentRoutePost, postDataIncludesField } from "./utils/navigation";
const forgotForm = '[data-ui-id="ui.auth.forgot.form"], form';
const forgotEmailInput = '[data-ui-id="ui.auth.forgot.email"], input[name="email"]';
const forgotResetButton = '[data-ui-id="ui.auth.forgot.submit"], button[name="mode"][value="reset"]';
const forgotMagicLinkButton = '[data-ui-id="ui.auth.forgot.magicLinkSubmit"], button[name="mode"][value="magic"]';
const resetForm = '[data-ui-id="ui.auth.reset.form"], form';
const resetEmailInput = '[data-ui-id="ui.auth.reset.email"], input[type="email"], input[name="email"], input#email';
const resetPasswordInput = '[data-ui-id="ui.auth.reset.password"], input[name="password"]';
const resetPasswordConfirmInput = '[data-ui-id="ui.auth.reset.passwordConfirm"], input[name="password-confirm"]';
const resetSubmitButton = '[data-ui-id="ui.auth.reset.submit"], button[type="submit"]';
test.describe("forgot-password page a11y", () => {
for (const route of ["/forgot-password", "/reset", "/auth/magic-link"]) {
test(`${route} has no critical or serious axe violations`, async ({ page }) => {
await page.goto(route, { waitUntil: "domcontentloaded" });
await expectNoCriticalA11yViolations(page);
});
}
test("submits reset and magic-link requests without account enumeration", async ({ page }) => {
await page.goto("/forgot-password", { waitUntil: "domcontentloaded" });
const form = page.locator(forgotForm).first();
const csrfInput = form.locator('input[name="csrf"]').first();
if ((await csrfInput.count()) > 0) {
await expect(csrfInput).not.toHaveValue("");
}
await form.locator(forgotEmailInput).fill("unknown-e2e-user@example.invalid");
await form.locator(forgotResetButton).click();
await expect(page.getByText(/if an account exists|wenn es ein konto/iu)).toBeVisible({ timeout: 5_000 });
await form.locator(forgotEmailInput).fill("unknown-e2e-magic@example.invalid");
await form.locator(forgotMagicLinkButton).click();
await expect(page.getByText(/if an account exists|wenn es ein konto/iu)).toBeVisible({ timeout: 5_000 });
});
test("submits reset-token form with csrf and token fields without mutating data", async ({ page }) => {
await page.goto("/reset?e=contract%40example.test&t=dummy-token", { waitUntil: "domcontentloaded" });
const form = page.locator(resetForm).first();
const csrfInput = form.locator('input[name="csrf"]').first();
const tokenInput = form.locator('input[name="verify-token"]').first();
const emailInput = form.locator(resetEmailInput).first();
const passwordInput = form.locator(resetPasswordInput).first();
const confirmInput = form.locator(resetPasswordConfirmInput).first();
const submit = form.locator(resetSubmitButton).first();
await expect(form).toBeVisible();
await expect(csrfInput).not.toHaveValue("");
await expect(tokenInput).toHaveValue("dummy-token");
await expect(emailInput).toHaveValue("contract@example.test");
await expect(passwordInput).toBeEditable();
await expect(confirmInput).toBeEditable();
await expect(submit).toBeEnabled();
let resolveSubmitted!: (formData: URLSearchParams) => void;
const submitted = new Promise<URLSearchParams>((resolve) => {
resolveSubmitted = resolve;
});
await page.route("**/*", async (route) => {
const request = route.request();
const requestUrl = new URL(request.url());
if (request.method() !== "POST" || requestUrl.pathname !== "/reset") {
await route.continue();
return;
}
resolveSubmitted(new URLSearchParams(request.postData() ?? ""));
await route.fulfill({
status: 204,
body: "",
});
});
await passwordInput.fill("LongEnough1!");
await confirmInput.fill("LongEnough1!");
await submit.click();
const formData = await submitted;
expect(formData.get("csrf") ?? "").not.toBe("");
expect(formData.get("verify-token")).toBe("dummy-token");
expect(formData.get("email")).toBe("contract@example.test");
expect(formData.get("password")).toBe("LongEnough1!");
expect(formData.get("password-confirm")).toBe("LongEnough1!");
});
test("shows an accessible error for an invalid reset token without losing context", async ({ page }) => {
await page.goto("/reset?e=contract%40example.test&t=dummy-token", { waitUntil: "domcontentloaded" });
const form = page.locator(resetForm).first();
await expect(form).toBeVisible();
await form.locator(resetPasswordInput).fill("LongEnough1!");
await form.locator(resetPasswordConfirmInput).fill("LongEnough1!");
await form.locator(resetSubmitButton).click();
await expect(page.getByRole("alert")).toContainText(/invalid or expired|ungültig|abgelaufen/i);
await expect(form.locator('input[name="verify-token"]')).toHaveValue("dummy-token");
await expect(form.locator(resetEmailInput)).toHaveValue("contract@example.test");
await expect(page).toHaveURL(/\/reset\?e=contract%40example\.test&t=dummy-token$/);
await expectNoCriticalA11yViolations(page);
});
});
test.describe("forgot-password mobile contract a11y", () => {
test.use({ viewport: narrowMobileViewport, isMobile: true, hasTouch: true });
test("posts reset and magic-link contracts on mobile without sending mail", async ({ page }) => {
for (const mode of [
{ button: forgotResetButton, email: "mobile-reset-contract@example.invalid", value: "reset" },
{ button: forgotMagicLinkButton, email: "mobile-magic-contract@example.invalid", value: "magic" },
] as const) {
await page.goto("/forgot-password", { waitUntil: "domcontentloaded" });
const form = page.locator(forgotForm).first();
const emailInput = form.locator(forgotEmailInput).first();
const submitButton = form.locator(mode.button).first();
await expect(form).toBeVisible();
await expect(emailInput).toBeVisible();
await expect(submitButton).toBeVisible();
await emailInput.fill(mode.email);
await expectNoHorizontalOverflow(page);
await expectNoCriticalA11yViolations(page);
const submitted = await interceptCurrentRoutePost(page, {
status: 200,
body: "<!doctype html><title>Forgot password intercepted</title>",
contentType: "text/html",
});
await submitButton.click();
await expect.poll(() => submitted.value, { timeout: 5_000 }).not.toBeNull();
expect(postDataIncludesField(submitted.value, "csrf", /.+/u)).toBe(true);
expect(postDataIncludesField(submitted.value, "email", new RegExp(`^${escapeRegExp(mode.email)}$`, "u"))).toBe(true);
expect(postDataIncludesField(submitted.value, "mode", new RegExp(`^${mode.value}$`, "u"))).toBe(true);
await page.unroute("**/*");
}
});
});