test: Vitest coverage infra + backfill to 85% coverage mandate - #56
Merged
Conversation
Adds Vitest + React Testing Library (replacing the node:test runner), a codecov.yml/GitHub workflow enforcing 85% project+patch coverage, and a local scripts/check-patch-coverage.mjs + /fix-patch-coverage command so patch-coverage gaps can be caught before pushing instead of failing CI. Backfills unit/component tests for the previously untested action layer, auth/session logic, proxy, and 16 components to bring real coverage from ~12% to 99.4% lines / 90.6% branches. Bundles the .github/workflows/ci.yml and codecov.yml workflow changes into this PR (rather than committing them straight to main per the usual CI-file convention) because they depend on the accompanying package.json/vitest.config.ts changes — landing them on main first would break main's CI until this PR merges down through development. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. ℹ️ You can also turn on project coverage checks and project coverage reporting on Pull Request comment Thanks for integrating Codecov - We've got you covered ☂️ |
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
node:testrunner. Server/action/lib tests run in plain Node (jose'sUint8Arraychecks break under jsdom's separate realm); component tests opt into jsdom per-file via a// @vitest-environment jsdomdocblock.codecov.yml+.github/workflows/codecov.ymlgating project and patch coverage at 85%, mirroring the Charon setup.ci.yml's test step now runsnpm run test:coverageso the 85% floor is enforced even before the Codecov GitHub App/secret are wired up on this repo.scripts/check-patch-coverage.mjs(npm run coverage:patch) — a dependency-free Node script that diffscoverage/lcov.infoagainst a git baseline to report patch coverage locally, plus.claude/commands/fix-patch-coverage.md(Hestia's equivalent of Charon's/fix-patch-coverage) to close gaps before pushing.chores,rewards,reminders,members,household,profile,auth),auth/session.ts,auth/current-user.ts,proxy.ts, and 16 components. Real coverage goes from ~12% to 99.4% lines / 90.6% branches / 100% functions.next/headers,next/cache, andnext/navigationmocked insrc/test/setup.ts—redirect()throwsError("NEXT_REDIRECT:<path>"), asserted on directly rather than mocked away.page.tsx/layout.tsxroute entrypoints,db/schema.ts,db/index.ts, andinstrumentation.tsare excluded from the coverage mandate (thin composition/declarative/bootstrap code, exercised bye2e/household-flow.spec.tsinstead) — same ignore list incodecov.yml,vitest.config.ts, and the patch-coverage script.Note on workflow files: this PR includes changes to
.github/workflows/ci.ymland adds.github/workflows/codecov.yml, rather than committing those straight tomainper the repo's usual convention. They depend on the accompanyingpackage.json/vitest.config.tschanges in this same PR — landing them onmainfirst would breakmain's CI until this merges down throughdevelopment. Flagging this explicitly since it's a deviation from the documented workflow-files-go-to-main rule.Still needed from a maintainer (can't be done from here): install the Codecov GitHub App on this repo and add a
CODECOV_TOKENrepository secret for.github/workflows/codecov.ymlto actually upload — until then, thecodecovjob will fail at the upload step (tests/coverage/build all still pass regardless).Test plan
npm run test:coverage— 172 tests pass, 99.41% lines / 90.61% branches / 100% functions / 99.09% statements (threshold: 85% lines)npm run lint— cleannpm run build— clean, TypeScript passesnode scripts/check-patch-coverage.mjs— manually verified it correctly flags an uncovered synthetic change and correctly reports clean when revertedCODECOV_TOKENsecret (maintainer action, see note above)🤖 Generated with Claude Code