mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-17 15:42:24 +00:00
test(e2e): keep route mocks authoritative against the v1.18.6 service worker
The production build registers a service worker whose v1.18.6 data branch serves allowlisted GET /api/* reads network-first. A worker-originated fetch is not subject to Playwright's page.route interception, so the worker re-fetched the real (empty) backend and bypassed every per-spec route.fulfill — a just-created row never surfaced and read-after-write assertions failed. Block the worker in the test context so the route mocks are authoritative; the shipped offline cache is untouched for real users. Separately, the dashboard now batches chart series into /api/measurements/series-batch, a sub-path the **/api/measurements* glob does not match, so it fell through to the empty backend and each chart painted an empty preloaded slice; stub the endpoint with the same populated set.
This commit is contained in:
1 parent
9633d66eea
commit
3cf9a262ca
2 files changed
+54
No files matched your search
@@ -33,6 +33,17 @@ export default defineConfig({
|
||||
trace: "retain-on-failure",
|
||||
screenshot: "only-on-failure",
|
||||
video: "retain-on-failure",
|
||||
// v1.18.6 — block the service worker in the test context. The
|
||||
// production build registers `/sw.js`, whose v1.18.6 data branch
|
||||
// serves allowlisted `/api/*` GET reads network-first. A worker-
|
||||
// originated `fetch` is NOT subject to Playwright's `page.route`
|
||||
// interception, so the SW would re-fetch the real (empty) backend
|
||||
// and serve that — bypassing every per-spec `route.fulfill` mock and
|
||||
// breaking read-after-write assertions (a just-created row never
|
||||
// surfaced). Blocking the worker keeps the route mocks authoritative
|
||||
// without weakening the shipped SW behaviour. Real users keep the
|
||||
// offline data cache; only the test harness opts out.
|
||||
serviceWorkers: "block",
|
||||
// HealthLog ships dark mode as the default (Dracula theme) — `globals.css`
|
||||
// sets `color-scheme: dark` on the root and the `<ThemeProvider>` defaults
|
||||
// to "system". Playwright's stock context is `colorScheme: "light"`, which
|
||||
|
||||
Reference in new issue
Block a user