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,56 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
import { expectNoCriticalA11yViolations } from "./utils/axe";
|
||||
|
||||
test.describe("login page a11y", () => {
|
||||
test("/login has no critical or serious axe violations", async ({ page }) => {
|
||||
await page.goto("/login", { waitUntil: "domcontentloaded" });
|
||||
await expectNoCriticalA11yViolations(page);
|
||||
});
|
||||
|
||||
test("/login supports keyboard navigation through inputs", async ({ page }) => {
|
||||
await page.goto("/login", { waitUntil: "domcontentloaded" });
|
||||
|
||||
// Walk the focus chain via Tab and assert we land on a form control at
|
||||
// least once. We don't hard-pin which element is first focusable because
|
||||
// headers / skip-links may legitimately precede the form, but a
|
||||
// reachable input is the minimum bar.
|
||||
const maxTabs = 12;
|
||||
let landedOnInput = false;
|
||||
|
||||
for (let i = 0; i < maxTabs; i += 1) {
|
||||
await page.keyboard.press("Tab");
|
||||
const tag = await page.evaluate(() => {
|
||||
const el = document.activeElement as HTMLElement | null;
|
||||
return el ? el.tagName.toLowerCase() : null;
|
||||
});
|
||||
if (tag === "input" || tag === "button" || tag === "textarea" || tag === "select") {
|
||||
landedOnInput = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
expect(
|
||||
landedOnInput,
|
||||
`Could not reach a form control via Tab within ${maxTabs} presses`,
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
test("failed login validation exposes accessible field errors", async ({ page }) => {
|
||||
await page.goto("/login", { waitUntil: "domcontentloaded" });
|
||||
|
||||
await page.locator('input[name="email"], input#email, input[type="email"]').first().fill("not-an-email");
|
||||
await page.locator('input[name="password"], input#password, input[type="password"]').first().fill("x");
|
||||
await page.locator('button[type="submit"]').first().click();
|
||||
|
||||
await expect(page.locator("#email-error")).toHaveRole("alert");
|
||||
await expect(page.locator("#email-error")).toHaveText("Invalid email");
|
||||
await expect(page.locator("#password-error")).toHaveRole("alert");
|
||||
await expect(page.locator("#password-error")).toHaveText("Invalid password");
|
||||
await expect(page.getByRole("alert")).toHaveCount(2);
|
||||
await expect(page.locator('input[name="email"]')).toHaveValue("not-an-email");
|
||||
await expect(page.locator('input[name="email"]')).toHaveAttribute("aria-invalid", "true");
|
||||
await expect(page.locator('input[name="email"]')).toHaveAttribute("aria-describedby", "email-error");
|
||||
await expect(page.locator('input[name="password"]')).toHaveAttribute("aria-invalid", "true");
|
||||
await expect(page.locator('input[name="password"]')).toHaveAttribute("aria-describedby", "password-error");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user