Skip to content

Audit per-file branch-coverage outliers and consider raising the 50% gate #1271

@cliffhall

Description

@cliffhall

Background

#1245 landed Vitest unit-test infrastructure with the following per-file gate in `clients/web/vite.config.ts`:

```
lines: 90
statements: 85
functions: 80
branches: 50
```

The branch threshold is intentionally relaxed because Mantine portal and `useMediaQuery` branches are not exercisable under happy-dom. In practice the global branch coverage is already ~95%, so 50% per file gives a lot of headroom — substantive business-logic branches could go untested without CI noticing.

Surfaced in the @claude review on PR #1269: #1269 (comment) (item #6).

Scope

  • Generate the per-file branch-coverage report from `npm run test:coverage` and identify files at or near the 50% floor.
  • For each outlier, classify the uncovered branches:
    • Inherent (happy-dom limitation): portal mount points, `useMediaQuery` fallbacks, SSR-only paths. These stay uncovered.
    • Coverable (business logic): missing test cases for real branches. Add tests.
  • Once the coverable branches are covered, raise the per-file branch threshold to a value that catches future regressions — likely 70–75% — and update the AGENTS.md description to match.

Acceptance criteria

  • No file in scope sits below the new threshold purely because of a missing business-logic test.
  • `vite.config.ts` per-file `branches` raised; CI green on v2/main.
  • AGENTS.md "Always test new or modified code" section updated to reflect the new gate.

Out of scope

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    v2Issues and PRs for v2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions