Cover rule-engine reconciliation paths; bump global ratchet#142
Merged
Conversation
Brings rule-engine.ts from 65.85% to 100% statements (56.25% to 100% functions, 57.69% to 100% branches). The previous test only exercised the initial-apply path; this extends it with the reconciliation paths that fire when storage, enforcement, or availability change: - storage flip on → rule.apply called - storage flip off → revealAll + rule.teardown called - no-op when state didn't change - enforcement off → all rules tear down - enforcement on → all rules re-apply - availability flip true ↔ false routes through the same reconcile - document.body missing skips both initial apply and reconcile To drive the listeners directly, mock `../availability` and `../placeholder` (preserving the real placeholder module's other exports via jest.requireActual). Subscriber listeners are pulled out of the mock's `mock.calls` so tests can invoke them with arbitrary snapshots. Ratchet global thresholds 62/58/58/61 → 65/60/61/65 to lock in the src/lib gain. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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
src/lib/rule-engine.tsfrom 65.85% → 100% statements (56.25% → 100% functions, 57.69% → 100% branches). The previous test only exercised the initial-apply path; this extends it with the reconciliation paths that fire when storage, enforcement, or availability change.src/liboverall: 87.98% → 90.38% statements).What the new tests cover
start()skips initial apply; later state changes also skip reconcile (theabout:blank/about:srcdociframe edge case).Mock additions
jest.mock("../availability", …)— captured the subscription listener so tests can drive availability changes directly.jest.mock("../placeholder", …)— preserves the real module's other exports viajest.requireActualand stubsrevealAllfor assertion.Test plan
bun run preflightpasses (lint + typecheck + knip + jest with coverage)rule-engine.tsshows 100/100/100/100 in the coverage report🤖 Generated with Claude Code