Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add irrelevant-sections-redact tests; shared jsdom polyfills#141

Merged
twschiller merged 1 commit into
mainfrom
coverage/irrelevant-sections-redact-tests
Jun 5, 2026
Merged

Add irrelevant-sections-redact tests; shared jsdom polyfills#141
twschiller merged 1 commit into
mainfrom
coverage/irrelevant-sections-redact-tests

Conversation

@twschiller

Copy link
Copy Markdown
Contributor

Summary

  • Brings irrelevant-sections-redact.ts from 15.67% → 91.79% statements (0% → 100% functions). The rule is now the last untested-rule item cleared from the ratchet comment.
  • Mocks LLM calls at the llm-client boundary — the rule talks to the background worker through chrome.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.
  • Extracts jsdom shims (Element.checkVisibility, offsetWidth/Height) to src/__test-mocks__/jsdom-extras.ts wired via Jest's setupFiles, so any future test that touches page-tree or visibility-aware code picks them up automatically.
  • Ratchets ./src/rules/ thresholds 84/71/88/84 → 90/77/95/90 to lock in the gain.

What the tests cover

  • Lifecycle: apply → waitForSettle → classify → DOM mutation; teardown discards late responses; scroll triggers debounced reclassify; scroll burst coalesces.
  • Response processing: refs resolve to elements; summary surfaces in placeholder label; default label when summary missing; placeholder height capped.
  • Dedupe: repeated refs in one response; ancestor + descendant collapse to outermost; unresolvable refs skipped.
  • Hideability protections: skips <article> / <header> / [role="banner"] descendants; skips position: fixed / position: sticky; skips elements taller than 70% viewport.
  • Errors: empty page tree short-circuits before LLM call; AbortError swallowed; generic error swallowed.

Test plan

  • bun run preflight passes (lint + typecheck + knip + jest with coverage)
  • Coverage summary shows ~83% statements / 74% branches / 85% functions
  • ./src/rules/ threshold check passes at the new 90/77/95/90 floor

🤖 Generated with Claude Code

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]>
@vercel

vercel Bot commented Jun 5, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agent-browser-shield-demo-site Ready Ready Preview, Comment Jun 5, 2026 1:32am

Request Review

@twschiller twschiller merged commit bbcf8ef into main Jun 5, 2026
7 checks passed
@twschiller twschiller deleted the coverage/irrelevant-sections-redact-tests branch June 5, 2026 01:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant