Skip to content

test: cover every line and function of the SPA - #139

Merged
bgard68 merged 2 commits into
frontendfrom
claude/new-session-muubr7-frontend
Aug 25, 2026
Merged

test: cover every line and function of the SPA#139
bgard68 merged 2 commits into
frontendfrom
claude/new-session-muubr7-frontend

Conversation

@bgard68

@bgard68 bgard68 commented Aug 25, 2026

Copy link
Copy Markdown
Owner

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.

Heads up: merging this to frontend triggers .github/workflows/deploy.yml, which builds, runs the test gate, and deploys to Azure Static Web Apps.

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, 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, .gitignore and README.md.

Two jsdom conventions the suite depends on

Both are written up in the README so they are not rediscovered the hard way:

  • Pointer coordinates. jsdom has no PointerEvent, and fireEvent.pointerDown silently drops clientX/clientY on its fallback event — which feeds NaN into the colour wheel's maths and makes a broken assertion look like a passing one. ColorPicker.test.jsx dispatches a MouseEvent named pointerdown instead, which carries the coordinates and still reaches React's handler.
  • Layout. Nothing has a size in jsdom, so components that measure themselves (the colour wheel, the Google button) get an explicit getBoundingClientRect in 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 ? … : 0 on a non-zero constant, a formatDate null 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

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
@github-actions

Copy link
Copy Markdown
Contributor

Azure Static Web Apps: Your stage site is ready! Visit it here: https://salmon-field-054249810-139.centralus.7.azurestaticapps.net

@github-actions

Copy link
Copy Markdown
Contributor

Azure Static Web Apps: Your stage site is ready! Visit it here: https://salmon-field-054249810-139.centralus.7.azurestaticapps.net

@bgard68
bgard68 merged commit dfbba45 into frontend Aug 25, 2026
8 checks passed
@bgard68
bgard68 deleted the claude/new-session-muubr7-frontend branch August 25, 2026 05:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants