mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-16 07:13:29 +00:00
Builds out the foundation for end-to-end tests against the production
build: Playwright with desktop + mobile projects, axe-core for WCAG
2.1 AA gating, and a GitHub Actions workflow that caches the browser
download and uploads the HTML report on failure.
What lands now (public surfaces only — no DB seed required):
e2e/version.spec.ts /api/version returns shape, no auth
e2e/auth-redirect.spec.ts proxy gate bounces / → /auth/login etc.
e2e/login.spec.ts login form renders + autoComplete hints
+ invalid-credential error surfaces
e2e/locale-switch.spec.ts DE/EN cookie switch, no raw i18n keys
leak into the DOM
e2e/a11y.spec.ts axe-core fails on serious or critical
WCAG 2.1 A/AA violations on /auth/login
The four authenticated flow specs from the v1.4.1 plan
(quick-entry, doctor-report, settings-roundtrip, test-buttons,
onboarding) need a seeded test user; they're tracked as a follow-up
because the seeding pipeline + WebAuthn polyfill they require warrant
their own PR. The smoke specs above cover the proxy, the login surface,
the version healthcheck endpoint, and the locale machinery — i.e.
every path a v1.4.X regression could realistically break without
deeper UAT.
CI workflow (.github/workflows/e2e.yml):
- postgres:16-alpine service container
- prisma migrate deploy seeds an empty schema
- playwright install --with-deps chromium (cached)
- next build, then `playwright test` against `next start`
- playwright-report uploaded as an artifact on failure
Quality gates:
- pnpm typecheck — clean
- pnpm test — 658/658 pass (vitest excludes e2e/**)
- pnpm lint — 0 errors
54 lines
1.8 KiB
TypeScript
54 lines
1.8 KiB
TypeScript
import { expect, test } from "@playwright/test";
|
|
|
|
/**
|
|
* Smoke checks on the login surface — must render, must wire the
|
|
* password-manager autofill hints (autoComplete="username" /
|
|
* "current-password"), must let the user submit.
|
|
*
|
|
* These do NOT log in (no DB seed required); the password-flow
|
|
* roundtrip is exercised by the integration test in
|
|
* tests/integration/auth-flow.test.ts.
|
|
*/
|
|
test.describe("login page", () => {
|
|
test("renders username + password inputs with the right autoComplete", async ({
|
|
page,
|
|
}) => {
|
|
await page.goto("/auth/login");
|
|
|
|
const username = page.getByLabel(/username|benutzername/i).first();
|
|
await expect(username).toBeVisible();
|
|
await expect(username).toHaveAttribute("autoComplete", /username|email/);
|
|
|
|
const password = page.locator('input[type="password"]').first();
|
|
await expect(password).toBeVisible();
|
|
await expect(password).toHaveAttribute("autoComplete", "current-password");
|
|
});
|
|
|
|
test("rejects an obviously-wrong credential pair", async ({ page }) => {
|
|
await page.goto("/auth/login");
|
|
|
|
await page
|
|
.getByLabel(/username|benutzername/i)
|
|
.first()
|
|
.fill("nobody-here");
|
|
await page.locator('input[type="password"]').first().fill("not-the-pw");
|
|
|
|
// Intercept the API call so the test does not depend on a real
|
|
// backend rejecting the credentials. The login form's error
|
|
// surfacing is what we actually want to prove here.
|
|
await page.route("**/api/auth/login", (route) =>
|
|
route.fulfill({
|
|
status: 401,
|
|
contentType: "application/json",
|
|
body: JSON.stringify({ error: "Invalid credentials" }),
|
|
}),
|
|
);
|
|
|
|
await page.getByRole("button", { name: /login|anmelden|sign in/i }).click();
|
|
|
|
await expect(
|
|
page.getByText(/invalid credentials|ungültig|falsch/i),
|
|
).toBeVisible({ timeout: 5_000 });
|
|
});
|
|
});
|