test: cover every line and function of the SPA - #139
Merged
Conversation
Coverage was 38.14% of lines across 44 tests. It is now 100% of lines and
100% of functions across 266.
Tooling
- @vitest/coverage-v8, configured in vite.config.js over src/**/*.{js,jsx},
excluding main.jsx (which only mounts the app) and the test files.
- npm run test:coverage.
Tests
- apiClient.js had no tests at all and is the file most worth having them:
the 401 refresh-and-retry, the shared in-flight refresh that stops two
simultaneous 401s from replaying the same rotating token and revoking every
session, the cold-start backoff for Azure's Free tier, error mapping, and
each Auth/Category/Todo call's verb, path and body.
- App.jsx: the silent sign-in on load and each way it can fail, the
waking-the-server note, sign-in, register, Google, sign-out, sign-out
everywhere, and the mid-session revocation that drops back to the form.
- KanbanBoard, Lane, TaskCard, CategoryManager: lane bucketing, the category
filter and its fallback when the selected category is deleted, drag and
drop, the tap-to-move control touch devices need, editing, and deletion.
- useTodos and useCategories: optimistic update, reconcile, and the reload
that reverts a failed one.
- GoogleButton, ColorPicker, DateField, AuthForm, TodoForm, ThemeToggle,
colors: the remaining branches, including theming and the offline paths.
Two conventions the suite depends on, both because jsdom is not a browser,
are written up in the README so they are not rediscovered the hard way:
fireEvent.pointerDown drops clientX/clientY on jsdom's fallback event and
feeds NaN into the colour wheel, so those tests dispatch a MouseEvent named
pointerdown; and nothing has a size in jsdom, so components that measure
themselves get an explicit getBoundingClientRect.
Thirteen branches remain uncovered. All are guards that cannot be taken as
the code stands — a ref checked for null on the element the same render
creates, a ternary on a non-zero constant, a null check behind a caller that
already tested the value. They are worth keeping and not worth contorting a
test to reach, so branch coverage reads 96.51%.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019h7znwAftvs36vD4YwKMRf
Contributor
|
Azure Static Web Apps: Your stage site is ready! Visit it here: https://salmon-field-054249810-139.centralus.7.azurestaticapps.net |
…n-muubr7-frontend
Contributor
|
Azure Static Web Apps: Your stage site is ready! Visit it here: https://salmon-field-054249810-139.centralus.7.azurestaticapps.net |
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.
Raises SPA coverage from 38.14% of lines to 100% of lines and 100% of functions, and the suite from 44 tests to 266. All green.
Tooling
@vitest/coverage-v8, configured invite.config.jsoversrc/**/*.{js,jsx}, excludingmain.jsx(which only mounts the app) and the test files.npm run test:coverage.Tests
apiClient.jshad no tests at all and is the file most worth having them: the 401 refresh-and-retry, the shared in-flight refresh that stops two simultaneous 401s from replaying the same rotating token and revoking every session, the cold-start backoff for Azure's Free tier, error mapping, and each Auth/Category/Todo call's verb, path and body.App.jsx— the silent sign-in on load and each way it can fail, the waking-the-server note, sign-in, register, Google, sign-out, sign-out everywhere, and the mid-session revocation that drops back to the form.KanbanBoard,Lane,TaskCard,CategoryManager— lane bucketing, the category filter and its fallback when the selected category is deleted, drag and drop, the tap-to-move control touch devices need, editing, and deletion.useTodos,useCategories— optimistic update, reconcile, and the reload that reverts a failed one.GoogleButton,ColorPicker,DateField,AuthForm,TodoForm,ThemeToggle,colors— the remaining branches, including theming and the offline paths.No application source changed — this is test files plus
vite.config.js,package.json,.gitignoreandREADME.md.Two jsdom conventions the suite depends on
Both are written up in the README so they are not rediscovered the hard way:
PointerEvent, andfireEvent.pointerDownsilently dropsclientX/clientYon its fallback event — which feedsNaNinto the colour wheel's maths and makes a broken assertion look like a passing one.ColorPicker.test.jsxdispatches aMouseEventnamedpointerdowninstead, which carries the coordinates and still reaches React's handler.getBoundingClientRectin the tests that care.What is not covered
Thirteen branches, all guards that cannot be taken as the code stands — a ref checked for null on the element the same render creates,
WHEEL_RADIUS ? … : 0on a non-zero constant, aformatDatenull check behind a caller that already tested the value. They are worth keeping as guards and not worth contorting a test to reach, so the branch figure reads 96.51% rather than 100%.Verification
npm test— 19 files, 266 tests, 0 failures.npm audit— 0 vulnerabilities.🤖 Generated with Claude Code
https://claude.ai/code/session_019h7znwAftvs36vD4YwKMRf
Generated by Claude Code