Repository navigation
test: reach 100% unit test coverage by deleting dead code, and enforce it - #1655
Merged
joshunrau merged 9 commits intoOct 5, 2026
Merged
Conversation
createMemoryConnection kept the replica set in a local, so onApplicationShutdown never saw it and every test run left a mongod and its temp dbPath behind until the process exited. Closes DouglasNeuroInformatics#1651 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- export worker: expandData only builds successful entries, so the failure branch and its type go - users: GroupsService.findById throws on a miss, so the null check after it never ran - mail: passwordSource decides password inheritance once, which removes the impossible null-saved fallbacks and the empty-plaintext branch in encryptPassword - instrument records: the export worker only acknowledges INIT with success, so the check and the test pinning a failure it cannot send go Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each removal is backed by the types, every caller, or the library contract:
- dialogs without a Dialog.Trigger: Radix only calls onOpenChange(false), so `if (!open)` goes
- fallbacks on values the schema or the query makes non-null (`?? []`, `?? {}`, `?? ''`)
- guards repeating an earlier guard: the bulk mapping resolve behind a disabled button, the
login page submit after its colour check, the group reseed the per-group key already performs
- branches the data cannot take: the PERSONAL_INFO `else if` on a two-value enum, an exhaustive
switch default, zod 4's never-produced `int` type name, a trimmed value compared to '\n'
- EmailTemplateEditor is read-only when given no onChange, so the default-template dialog no
longer passes a no-op handler
- mail settings read the flattened field errors of the four fields that can fail
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- the scalar and series submit handlers are only ever given to content rendered once the instrument is DONE, so they now take that instrument instead of re-checking the status - the series renderer's status and step matches are exhaustive, so `.otherwise(() => null)` becomes `.exhaustive()` and the compiler holds the guarantee - inside isSubjectWithPersonalInfo the date of birth and sex are non-null, so their null arms go - the zod error map test for an affix-less issue describes a hand-raised issue, not a defect Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…instruments Both callers return early for a unilingual instrument and throw for any other non-array language, so the string branch never ran. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…le-level map staticAssets is a const Map created at module load, so it can never be falsy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Only vitest and worker threads reject the target; the `pnpm dev` main thread resolves it through swc-node. Links the it.fails case to DouglasNeuroInformatics#1653. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The root vitest config sets a 100% threshold on every metric, CI's unit step runs `pnpm test:coverage`, and AGENTS.md, the testing strategy, odc-done, odc-testing and the playbooks name it as the gate. Code no test can reach is to be proved dead and deleted, never ignored or excluded. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The generic --open test only reached the darwin arm of openInBrowser when the suite ran on a Mac, so on CI's Linux runner that branch was uncovered and the 100% gate failed. Every arm is now pinned by its own test, and AGENTS.md describes cli.test.ts and the need to pin the platform. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Follow-up to #1632, which raised unit coverage to about 99.8% and was merged before this work landed. This PR takes every metric to 100% and makes 100% the gate locally and in CI.
The denominators shrink because the gap was not untested code. It was code no input can reach, so it was deleted.
Dead code removed
Each location was proved dead from the types, every caller, or the library contract, then deleted or restructured so the impossible state cannot be written. Where a deletion relies on a type guarantee,
tscconfirms it.Dialog.Trigger. Radix only ever callsonOpenChange(false)for these (checked against@radix-ui/react-dialog), soif (!open)goes. Affected: the instrument preview, admin instruments, instrument repos, admin users and group manage.?? []on auseSuspenseQueryresult;?? {}and?? ''on schema-required fields;if (records)on a required array.MapStepresolving behind a disabled button;ManageGroupFormreseed that its per-groupkeyalready performs (the key site now says so);users.service's null check after afindByIdthat throws.else ifon a two-value enum (zod skips superRefine when the base parse fails);default;inttype name (z.int().def.typeis'number');.trim()med value compared to'\n';split()results checked for falsiness.SeriesInstrumentRenderer's.otherwise(() => null)arms after exhaustive status and step matches are now.exhaustive(), so the compiler holds the guarantee.DONE, so they now take that instrument instead of re-checking the status.EmailTemplateEditoris read-only when given noonChange, replacing a no-op handler;passwordSource), instead of guarding impossible null fallbacks at two call sites.expandDatanever produces a failure entry, and the worker only ever acknowledgesINITwith success. Both checks, the unused types and the test pinning an impossible failure are gone.getTargetLanguageis narrowed to multilingual instruments, and the service worker no longer checks a module-levelconst Mapfor falsiness.Bug fixed
#1651: the in-memory replica set is now stored and stopped in
onApplicationShutdown, with a unit test. That is whatapps/api/AGENTS.mdalready claimed happened.Enforcement
vitest.config.tssetscoverage.thresholds: { 100: true }.pnpm test:coverage.AGENTS.mdhard rule says code no test can reach is proved dead and deleted, never ignored or excluded.coverage.excludestays reserved for non-code.odc-done,odc-testing,testing-strategy.md(new §Coverage) and the playbooks now namepnpm test:coverage. They also note that a scoped coverage run needs--coverage.thresholds.100=false.Verification
pnpm lint: green (34/34 tasks).pnpm test:coverage: green at 100% on all four metrics, 4,392 tests passing plus 5it.fails.pnpm test:e2e: 277/277 passed.One deletion was wrong at first, and a unit test caught it before commit: the login-page colour check also feeds the live preview, where invalid colours do occur. It was restored, and only the post-guard submit copy was removed.
Exception: no new
testing/spec. The removals change no reachable behaviour, the #1651 fix has no browser-visible effect, and the existing suite passes unchanged.Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com