Add irrelevant-sections-redact tests; shared jsdom polyfills#141
Merged
Conversation
Brings irrelevant-sections-redact.ts from 15.67% to 91.79% statements (0% to 100% functions). Covers the apply-settle-classify lifecycle, every checkHideable skip reason (article/header/banner ancestors, position fixed/sticky, taller-than-viewport), ref dedupe (repeated refs, ancestor+descendant to outermost, unresolvable refs), empty page-tree short-circuit, AbortError + generic error swallowing, debounced scroll re-classification, and teardown discarding late classifier responses. LLM calls are mocked at the `llm-client` boundary (the rule talks to the background worker through chrome.runtime.connect; mocking the port-side function avoids needing chrome/fetch mocks). Two additional boundary mocks unbreak ts-jest's CJS transform: `nanoid` and `abort-utils` are pure-ESM, and `../lib/availability` is mocked to break the rules-barrel circular import that bites single-rule loads. Extract the jsdom shims (Element.checkVisibility, offsetWidth/Height) to src/__test-mocks__/jsdom-extras.ts wired via jest's `setupFiles` so future tests that touch page-tree pick them up automatically. Ratchet src/rules thresholds to lock in the gain (84/71/88/84 → 90/77/95/90). 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
irrelevant-sections-redact.tsfrom 15.67% → 91.79% statements (0% → 100% functions). The rule is now the last untested-rule item cleared from the ratchet comment.llm-clientboundary — the rule talks to the background worker throughchrome.runtime.connect, so mocking the port-side function avoids needing chrome/fetch mocks. Two additional boundary mocks unbreak ts-jest's CJS transform (nanoid,abort-utils) and a third (../lib/availability) breaks a rules-barrel circular import that bites single-rule loads.Element.checkVisibility,offsetWidth/Height) tosrc/__test-mocks__/jsdom-extras.tswired via Jest'ssetupFiles, so any future test that touchespage-treeor visibility-aware code picks them up automatically../src/rules/thresholds 84/71/88/84 → 90/77/95/90 to lock in the gain.What the tests cover
<article>/<header>/[role="banner"]descendants; skipsposition: fixed/position: sticky; skips elements taller than 70% viewport.AbortErrorswallowed; generic error swallowed.Test plan
bun run preflightpasses (lint + typecheck + knip + jest with coverage)./src/rules/threshold check passes at the new 90/77/95/90 floor🤖 Generated with Claude Code