mirror of
https://github.com/rommapp/romm.git
synced 2026-12-06 07:54:18 +01:00
* chore(e2e): Update playwright #4772, smaller focus * chore(e2e) address greptile feedback * chore(e2e): Add Lighthouse and Axe * chore(e2e): replace the Lighthouse and axe projects with an axe check per page - Move PAGES and the page-opening wait into support/pages.ts, so loads.spec.ts and the new a11y.spec.ts share one list of every route. - a11y.spec.ts runs axe on each page as the least privileged role allowed on it, and login.spec.ts on the login page. Critical violations fail; every violation is attached to the report as JSON. Serious ones (mostly color contrast) still fire on several pages, so they stay report-only for now. - Drop the Lighthouse suite and its dependency tree, the separate axe project, the @smoke tag, the sitemap, and build:e2e. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix(e2e): wait for skeletons to clear before checking a page Addresses Greptile's review: openPage returned once the view mounted, so axe (and the load check) ran while seven data-backed pages still showed RSkeletonBlock placeholders. Wait until none are in the viewport; virtualized grids keep them below the fold. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Georges-Antoine Assi <contact@me.gantoine.com> Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
3.7 KiB
3.7 KiB
E2E suite rules
- Layout: tests go in
specs/and nothing else does, one folder per page named after its route name insrc/plugins/routeNames.ts(specs/rom/), each file named after what it checks. Specs that aren't about one page go in a folder named for their area, such asspecs/auth/. Setup projects go insetup/, fixtures and helpers insupport/, and every generated file under.output/, through the paths insupport/output.ts. - Every route is in
PAGESinsupport/pages.ts, keyed by route name, so a new route fails the typecheck until it gets an entry: a page to open, which must load for each role allowed on it with every response 2xx (and give a viewer the 404 page when its route is inROUTE_SCOPESbut notVIEWER_OPENS), or askipwith the reason.specs/a11y.spec.tsruns axe on the same pages. Tag each top-leveldescribeof a page's other specs with its route name,{ tag: "@page:rom" }. - Each variable has one home.
playwright.config.tsloadse2e/.envand readsE2E_BASE_URL;support/auth.tsreads the account variables intoACCOUNTS. Specs read neitherprocess.envnor.env: they takeACCOUNTS, or Playwright'sbaseURLfixture. A new variable gets a default that works against a seeded dev backend, and a line in.env.example. - One site, one URL. The suite tests whatever
E2E_BASE_URLserves. Unset, the config'swebServerstarts the app (the dev server locally, the static build in CI); that is the only server it starts. Don't add Docker or a second target. - Import
testandexpectfromsupport/test.ts, so the app-error guard applies. ESLint enforces it. - Prefer Playwright's own tools over custom scripts. Recording, debugging, reports and traces come from the Playwright CLI and the VS Code extension; document the native way in the README.
- Select by role and label (
getByRole,getByLabel), then by ARIA ordata-*attributes. A CSS class only where the app offers neither. - Recorded code is a draft. Before committing, give it real assertions, replace CSS-path and
nth()selectors with roles and labels, and run it. - Timeouts: don't add hard-coded ones that would outlive a debug session; the config sets every timeout to 0 when a debugger is attached. A test that genuinely needs longer calls
test.slow(), which leaves a debug session's 0 alone, asauth.setup.tsdoes. - Fail on the cause, not on a timeout.
- The automatic guard in
support/test.tsfails a test the moment an/apicall returns 5xx or the app throws. - When a helper waits for a response, accept any status, then check it and throw a message naming the method, path and status, as
gotoHydrated()does. Never filter onstatus() === 200insidewaitForResponse. - Retry only what's transient, with Playwright's own
retries: thesetupproject retries sign-in, which a dev-server reload can interrupt. - Don't paper over slowness with longer timeouts or
waitForTimeout; find the event to wait for. - Observe the app's own traffic; don't call the API from tests (ESLint enforces it).
- The automatic guard in
- Every run signs in afresh.
auth.setup.tssaves each account's session toe2e/.output/auth/for that run's specs. - Pick a theme with
colorScheme(page.emulateMedia()ortest.use()), never by writingsettings.theme: the app syncs UI settings to the account, so a written theme leaks into every later sign-in. The suite's stored theme is always "auto". login.spec.tsmust start signed out, via its explicit emptystorageState.- Lint rules for e2e live in
frontend/eslint.e2e.config.js, never inline ineslint.config.js. A rule that's wrong for tests gets a named exception there with a one-line reason and the narrowestfilesglob, not aneslint-disablecomment.