Skip to content

test: regression coverage for broker-protection root scoping and element-hiding selectors - #2997

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/regression-test-coverage-0d35
Draft

cursor[bot] wants to merge 1 commit into
mainfrom
cursor/regression-test-coverage-0d35

Conversation

@cursor

@cursor cursor Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Asana Task/Github Issue: Weekly test-coverage automation

Description

Adds targeted unit tests for two recent injected-feature changes that had integration coverage but no fast unit-level regression guards:

  1. Broker Protection selectRootElement (fix(broker-protection): preserve matched CAPTCHA context #2976) — scopes CAPTCHA actions to the profile row that best matches user data. Wrong scoping would solve the wrong captcha on multi-record pages.
  2. Element hiding querySelectorFor (Element hiding: Improve performance by taking advantage of browser selector indexing #2977) — only wraps comma-separated selector lists in :is() so single selectors stay indexable. Re-wrapping singles would regress the performance fix.

Extracted selector helpers into element-hiding-selectors.js so they can be unit-tested without pulling in the full feature module.

Risky behavior now covered

  • Profile-match parent selects the highest-scoring DOM row, not the first match
  • Missing/unsupported parent config returns PirError instead of silently using the wrong root
  • Single selectors are passed through unchanged; multi-selector rules still use forgiving :is() wrapping

Test files added/updated

  • injected/unit-test/select-root-element.spec.js (new)
  • injected/unit-test/element-hiding-selectors.spec.js (new)
  • injected/src/features/element-hiding-selectors.js (extracted, no behavior change)
  • scripts/check-strict-core.js (register new module)

Why these tests materially reduce regression risk

  • selectRootElement is shared by CAPTCHA and click actions; integration tests are slow and don't exhaust scoring edge cases
  • querySelectorFor is a one-line perf optimization easy to undo during refactors; unit tests lock the single-vs-list contract

Testing Steps

  • cd injected && npm run test-unit -- --filter="selectRootElement|element-hiding selector" (8 specs, 0 failures)
  • npm run tsc && npm run tsc-strict-core

Checklist

  • I have tested this change locally
  • I have tested this change locally in all supported browsers
  • This change will be visible to users
  • I have added automated tests that cover this change
  • I have ensured the change is gated by config
  • This change was covered by a ship review
  • This change was covered by a tech design
  • Any dependent config has been merged
Open in Web View Automation 

…element-hiding selectors

Add unit tests for selectRootElement (profile-match CAPTCHA scoping from #2976)
and querySelectorFor (selector-indexing optimization from #2977). Extract
element-hiding selector helpers into a small module for direct unit testing.
@github-actions github-actions Bot added the semver-patch Bug fix / internal — no release needed label Aug 31, 2026
@github-actions

Copy link
Copy Markdown
Contributor

[Beta] Generated file diff

Time updated: Mon, 31 Aug 2026 08:12:08 GMT

Android
    - android/contentScope.js

File has changed

Apple
    - apple/contentScope.js

File has changed

Chrome-mv3
    - chrome-mv3/inject.js

File has changed

Firefox
    - firefox/inject.js

File has changed

Integration
    - integration/contentScope.js

File has changed

Windows
    - windows/contentScope.js

File has changed

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

semver-patch Bug fix / internal — no release needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant