mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-09 21:10:59 +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
35 lines
1.2 KiB
TypeScript
35 lines
1.2 KiB
TypeScript
import { expect, test } from "@playwright/test";
|
|
|
|
/**
|
|
* The proxy at src/proxy.ts is the single gate enforcing auth on every
|
|
* non-public path. A regression that accidentally adds a route to
|
|
* PUBLIC_PATHS, or breaks the redirect, would expose unauthenticated
|
|
* surfaces. Verify a few representative routes round-trip to /auth/login.
|
|
*/
|
|
test.describe("proxy auth gate", () => {
|
|
for (const path of [
|
|
"/",
|
|
"/dashboard",
|
|
"/medications",
|
|
"/admin",
|
|
"/insights",
|
|
]) {
|
|
test(`${path} redirects to /auth/login when no session`, async ({
|
|
page,
|
|
}) => {
|
|
const response = await page.goto(path, { waitUntil: "domcontentloaded" });
|
|
expect(response).not.toBeNull();
|
|
// Either the proxy hands back a 307/308, or the navigation lands
|
|
// at /auth/login after redirect; both are acceptable proof.
|
|
expect(page.url()).toMatch(/\/auth\/login(\?|$)/);
|
|
});
|
|
}
|
|
|
|
test("public paths are reachable without a session", async ({ page }) => {
|
|
// /auth/login is in PUBLIC_PATHS — must be served, not bounced anywhere.
|
|
await page.goto("/auth/login");
|
|
expect(page.url()).toMatch(/\/auth\/login(\?|$)/);
|
|
await expect(page.locator("body")).toBeVisible();
|
|
});
|
|
});
|