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.
Replaces the global-setup warm-up. The warm-up existed to absorb Vite's
on-demand compilation and its "optimized dependencies changed. reloading"
force-reload; serving a static build means neither happens, so the workaround
is unnecessary rather than merely cheaper.
`vite preview` inherits `server.proxy` (`proxy: preview?.proxy ?? server.proxy`),
so /api and /ws still reach the backend -- an earlier comment claiming preview
ignores the proxy was wrong. Build is ~5s and the suite drops from ~3.7min to
~35s. Local runs stay on the dev server so a change is picked up without a
rebuild; `CI=1 npm run test:e2e` opts into the CI path.
Repetition against the build then exposed two races the dev server had been
masking, both real bugs in the specs rather than infrastructure:
* Assertions ran before `/permissions/me` hydrated the grants store, so an
admin's menu was read pre-hydration and looked like a permissions bug.
`gotoHydrated()` now waits for that response and for the app bar to render,
and the presence assertions use `expect.poll` instead of a one-shot read.
* The PWA service worker precaches ~9MB, re-installed on every fresh context
and caching between runs. Blocked via `serviceWorkers: "block"`.
Six consecutive runs against the build: 15/15, no flakes, ~33s each.
They exist to stand up a disposable instance for the Playwright suite, so
they belong with the workflow that runs them rather than in backend/tools/
next to the library-generation utilities.
Their sys.path bootstrap now points at backend/ explicitly (it relied on
being one level below it), the workflow invokes them from the repo root
instead of backend/, and .github/scripts/** joins the workflow's path
filters so editing a seeder still triggers the suite.
Adds .github/workflows/e2e.yml: MariaDB + Valkey services, migrations, an
offline library scan, the fixture users, the backend, then Playwright --
whose webServer starts the Vite dev server. DEV_PORT (5000) is both what
main.py binds and what Vite's /api proxy targets, so neither side needs
configuring. Report and test-results upload as an artifact on failure.
`tools/seed_e2e_library.py` scans backend/romm_test/library with an empty
metadata_sources list, so CI never reaches out to a provider. It exits
non-zero on an empty library rather than leaving a confusing Playwright
timeout later.
Also fixes the flakiness that a CI-shaped rehearsal exposed. Root cause was
not slowness: the Vite dev server force-reloads the page when it discovers a
new dependency to pre-bundle, wiping the half-filled login form so the submit
never lands. Defences are a passive warm-up pass in global-setup.ts (absorb
the reload before anything depends on the page, then compile the routes under
test) and a retry in login(). Two smaller real bugs fell out of the same
investigation: `button[type="submit"]` matched two elements, because the
collapsed reset-password form has its own, and the warm-up's best-effort
`.catch()` calls inherited a 120s timeout, making setup take 8 minutes.
Verified from a cold Vite cache against a throwaway database and the fixture
library: 15/15 pass, no flakes, 2.7 minutes.
The #3954 fix is about what a read-only user can SEE, which the Vitest
specs can't reach: visibility depends on grants the backend resolves and
`useCan` projects. These drive a real instance instead.
frontend/e2e/rom-actions.spec.ts ⋯ menu items + divider collapse
frontend/e2e/profile-role.spec.ts no self-editable role control
frontend/e2e/game-media-files.spec.ts Media/Files upload + delete
Every spec asserts both sides -- absent for `e2e_viewer`, present for
`e2e_admin` -- so it can't pass against a page that failed to render, and
notices a fix that over-hides. Verified by reverting the fix: 8 of 15 fail,
and the 6 admin-side guards stay green.
`backend/tools/seed_e2e_users.py` seeds the two fixture users idempotently.
Specs live in e2e/ so Vitest's src/** and test/** globs skip them, and
tsconfig now covers them so they're typechecked.
Not wired into CI: that needs a backend, a database and a library fixture
in the runner.