Files
romm/frontend/e2e
Georges-Antoine Assi 9e5582230d Sign in once per role instead of per test
Every spec drove the login form, which is 15 UI logins to test something
login.spec.ts can cover on its own.

auth.setup.ts now runs first as its own project, logs each fixture user in
once and saves the session (cookies plus localStorage) to playwright/.auth/.
Specs pick an identity with `test.use({ storageState })` and start signed in.
That is preferred over building a context by hand, which would silently drop
the project's options -- baseURL, the blocked service worker, viewport.

login.spec.ts is the one place the form is exercised, on a deliberately
unauthenticated page, and it gained cover the suite never had: a rejected
password and the redirect for an anonymous visitor.

Suite: 33s -> ~19s, with 18 tests instead of 15. Verified three times against
the build and once against the dev server.
2026-07-26 14:08:37 -04:00
..

End-to-end tests (Playwright)

These drive a real running RomM instance, unlike the Vitest specs, which mount components in isolation. They exist to cover behaviour that only shows up in the assembled app. They live in e2e/ rather than src/ or test/ because Vitest's globs (src/**/*.{test,spec}.ts, test/**/*.{test,spec}.ts) would otherwise try to run them in jsdom.

Running tests

  1. Have the app up and reachable (default http://localhost:3000, override with E2E_BASE_URL), with a populated library — the specs pick the first ROM they find.

  2. Seed the two fixture users, from the repo root:

    uv run python .github/scripts/seed_e2e_users.py   # --remove to clean up afterwards
    
  3. Run, from frontend/:

    npm run test:e2e          # headless
    npm run test:e2e:ui       # interactive, for debugging a failure
    

Authentication

auth.setup.ts runs first as its own project, logs each fixture user in once and saves the session to playwright/.auth/ (gitignored). Specs pick an identity with test.use({ storageState: STORAGE_STATE.viewer }) and start signed in, so the form is driven twice per run rather than once per test.

login.spec.ts is the only spec that drives the form, using the default unauthenticated page. If auth breaks, diagnose there.