test(frontend): cover every lib wrapper and restore the coverage ratchet

↗ view on GitHub · Amal · 2026-08-04 · 5719a6c9

WHY THIS MATTERS
The frontend gates src/app/lib/** with global coverage floors that, by
policy (docs/frontend-testing.md), only ever go up. Recent PRs bent that:
new lib code landed with partial tests (folderDeleteState at 69% branches,
the Ollama additions to modelAvailability untested) and PR #284 then
lowered the branch floor from 96 to 80 to get CI green - the exact move
the ratchet exists to prevent. A lowered floor silently licenses the next
regression too.

WHAT IS A COVERAGE RATCHET
A ratchet is a no-regression floor, not a target: CI fails if coverage
drops below the last measured level, and whenever tests are added the
floor is raised to just under the new measurement in the same PR. It
converts test debt into an explicit, reviewable decision instead of a
gradual drift.

HOW THIS PR CLOSES THE GAP
- mikeApi.ts: a table-driven it.each suite asserts route, HTTP method,
  JSON body, and auth header for every remaining thin endpoint wrapper
  (~50: MCP connectors, project/library folders and documents, document
  versions, chats, workflows incl. share/open-source). These wrappers are
  one-liners whose only failure modes are a wrong route or a camelCase
  key that should be snake_case - mistakes TypeScript cannot catch, so
  each case pins exactly those three things. Wrappers that unwrap an
  envelope (getOllamaModels, getCourtlistenerOpinions) or return blobs
  (exportChatData, exportTabularReviewsData) get explicit tests.
- folderDeleteState.ts: covers the failed-delete path (back to idle so
  the dialog allows retry), stale start/failed actions for a folder no
  longer pending, and cancel being a no-op mid-delete.
- modelAvailability.ts: covers the Ollama branches - prefix-based
  provider resolution, always-available (local models need no API key),
  label, and group mapping.

Measured after: 99.69% statements / 98.53% branches / 100% functions /
100% lines (was 80 / 92.68 / 56.92 / 79.09). Floors move to 97/96/98/98 -
~2 points under measured, per the config's stated policy, restoring the
branch floor to its pre-#284 level of 96 and raising the other three far
above their old values. docs/frontend-testing.md's coverage table, floor
numbers, and TODO list are updated to match.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Repository open-legal-products/mike
Author Amal <mamalanand3@gmail.com>
Authored
Parents 8313af19
Stats 5 files changed , +656 , -34
Part of Add a Word add-in for chat and tracked rewrites

Capture this commit into my fork

Download a Markdown prompt that tells Claude how to port this exact commit into your working tree. Run it via claude -p < capture-commit-5719a6c9.md from inside the repo you want the change in.

⬇ Download capture-commit-5719a6c9.md