Repository navigation
test(frontend): add axios adapter backend stub and cover App and map data loading - #574
Merged
Merged
Conversation
…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>
|
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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'sbackendaxios 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).mswdevDependency 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'spage.routecovers the e2e need..gitignore:/.vitest(failure screenshots).No production code changed. Tile requests are avoided by mocking
TileLayerin these tests (they are image loads, not axios calls).Coverage
Whole project: 76.7% lines, 56.0% branches (was 46.8%).
App.tsx100%,LeafletWorldMap.tsx94.7% lines,LeafletLayers.tsx80% lines.Apprenders 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)
tscclean, eslint clean.🤖 Generated with Claude Code