Skip to content

test(frontend): add axios adapter backend stub and cover App and map data loading - #574

Merged
JuliusHenke merged 1 commit into
masterfrom
chore/frontend-flow-tests
Oct 10, 2026
Merged

JuliusHenke merged 1 commit into
masterfrom
chore/frontend-flow-tests

Conversation

@JuliusHenke

Copy link
Copy Markdown
Member

Summary

Fourth step of the frontend testing plan (follows #570, #571, #573). Introduces the backend stub and covers the app's data-loading flows.

  • src/test/mock-backend.ts: replaces the transport of the app's backend axios instance. Requests still pass through axios, nothing leaves the browser. Per-test routes (onGet/onPost, string or RegExp paths, handlers get the parsed body and captures), reply(status, data), networkError(), deferred() to control answer order, a request log, and a shared teardown that fails the test on unmocked requests. The stub has its own tests.
  • App.test.tsx: days then latest day requests, loading animation, connection failure with working Retry, map attribution, small and large screen layout.
  • LeafletWorldMap.test.tsx: loads and draws the latest day, no request without days, failure snackbar, and the stale response guard (verified to fail when the guard is removed).
  • Removes the msw devDependency added in chore(frontend): add Vitest with unit and browser-mode component projects #570; it was never used. The stub avoids a committed service worker file and extra supply-chain surface. Playwright's page.route covers the e2e need.
  • .gitignore: /.vitest (failure screenshots).

No production code changed. Tile requests are avoided by mocking TileLayer in these tests (they are image loads, not axios calls).

Coverage

Whole project: 76.7% lines, 56.0% branches (was 46.8%). App.tsx 100%, LeafletWorldMap.tsx 94.7% lines, LeafletLayers.tsx 80% lines. App renders most of the tree, so many components are partly covered already; dedicated tests for dialogs, settings and layers follow.

Deployment notes

None.

Dependency vetting

One devDependency removed (msw), nothing added. Lockfile shrinks by about 420 lines.

Verification (Node 24)

  • 130 tests pass (45 unit, 85 browser); full run about 8 s.
  • tsc clean, eslint clean.
  • Browser project was run outside the Claude Code sandbox, which blocks Chromium.

🤖 Generated with Claude Code

…data loading

Adds a mockBackend helper that replaces the transport of the app's axios
instance, with per-test routes, status and network-error replies, deferred
answers and a teardown that fails on unmocked requests. Covers App (loading,
retry, small/large layout, attribution) and LeafletWorldMap (day loading,
failure, stale response guard). Removes the unused msw devDependency.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@JuliusHenke JuliusHenke added enhancement New feature or request frontend labels Oct 10, 2026
@github-actions

Copy link
Copy Markdown

Visit the preview URL for this PR (updated for commit d1bb294):

https://tormap-36f44--pr574-chore-frontend-flow-nhk3jlwa.web.app

(expires Mon, 09 Nov 2026 14:32:28 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 0c1f71965de18e60b0e686b0d0356977fec090dc

@JuliusHenke
JuliusHenke merged commit c0a9d11 into master Oct 10, 2026
13 checks passed
@JuliusHenke
JuliusHenke deleted the chore/frontend-flow-tests branch October 10, 2026 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request frontend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant