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

Skip to content

Cover lib/selector-hide-rule directly; bump global ratchet#147

Merged
twschiller merged 1 commit into
mainfrom
coverage/selector-hide-rule-tests
Jun 5, 2026
Merged

Cover lib/selector-hide-rule directly; bump global ratchet#147
twschiller merged 1 commit into
mainfrom
coverage/selector-hide-rule-tests

Conversation

@twschiller

Copy link
Copy Markdown
Contributor

Summary

Brings `src/lib/selector-hide-rule.ts` from 89.13% → 100% statements, 77.77% → 100% branches, and 88.88% → 100% lines. The factory was previously covered only transitively through the 6 rules built on it (`chat-widget-hide`, `cookie-banner-hide`, `comments-redact`, `footer-redact`, `newsletter-modal-hide`, `reviews-redact`); a direct test file pins its own contracts so a regression here can't silently break the union.

What the tests cover

  • Constructor validation — throws when `hideLabel` is omitted and `removeEntirely` is false; doesn't throw when `removeEntirely` is true or when `hideLabel` is set.
  • `selectorsFor` URL composition — `alwaysOnSelectors` only when no site rules match; matching site-rule patterns merge in; non-matching patterns drop out; multiple matches all contribute.
  • `scan` branches — empty-selectors short-circuit; `candidateFilter` narrows; placeholder-element skip; inside-placeholder skip; `REVEALED_ATTR` skip for this rule but not for other rules; `REVEALED_ATTR` ancestor skip; `HIDDEN_ATTR` skip; outermost-match dedupe.
  • `removeEntirely` — sets `display: none !important` + `HIDDEN_ATTR` + no placeholder.
  • Rule shape — `teardown` present iff `watchSubtrees`; `topFrameOnly` propagates.

Ratchet

Global thresholds 68/63/67/68 → 69/64/67/68 to lock in the gain (`src/lib` overall: 95.19% → 96.11% statements, 91.32% → 94.97% branches).

Test plan

  • `bun run preflight` passes
  • `selector-hide-rule.ts` shows 100/100/100/100 in the coverage report
  • Global threshold check passes at the new 69/64/67/68 floor

🤖 Generated with Claude Code

Brings src/lib/selector-hide-rule.ts from 89.13% to 100% statements,
77.77% to 100% branches, and 88.88% to 100% lines. The factory was
previously covered only transitively through the 6 rules built on it
(chat-widget, cookie-banner, comments-redact, footer-redact,
newsletter-modal-hide, reviews-redact); a direct test file pins its
own contracts so a regression here can't silently break the union.

Tests cover:
- constructor validation: throws when hideLabel is omitted and
  removeEntirely is false; doesn't throw otherwise.
- selectorsFor URL composition: alwaysOnSelectors only when no
  siteRules match; pattern-matched site rules merge in; non-matching
  patterns are dropped; multiple matches all contribute.
- scan branches: empty-selectors short-circuit; candidateFilter
  narrows the candidate set; placeholder-element skip; inside-
  placeholder skip; REVEALED_ATTR skip (self) but not for other
  rules; REVEALED_ATTR ancestor skip; HIDDEN_ATTR skip; outermost-
  match dedupe.
- removeEntirely: display:none + HIDDEN_ATTR + no placeholder.
- rule shape: teardown present iff watchSubtrees, topFrameOnly
  propagates.

Ratchet global thresholds 68/63/67/68 → 69/64/67/68.

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 2:57am

Request Review

@twschiller twschiller merged commit 210a06b into main Jun 5, 2026
7 checks passed
@twschiller twschiller deleted the coverage/selector-hide-rule-tests branch June 5, 2026 02:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant