test(extension): cover background.js message routing and options.js session UI#7497
Conversation
…ession UI background.js (the service-worker onMessage router) and options.js (the options-page controller) had no unit tests, unlike auth.js and content.js. A regression in either -- background.js returning false instead of true and silently breaking every async response, or refreshSettings() misclassifying an expired session as valid -- would only surface by manually loading the unpacked extension. Add extension-background.test.ts and extension-options.test.ts using the vm Script/createContext technique extension-content.test.ts established. Both files statically import from auth.js, which a plain vm Script cannot execute, so the import line is stripped and the handlers/auth helpers are injected as context globals (the host Error is shared so 'error instanceof Error' matches the single-realm extension). Covers background.js's pull-context/logout dispatch, its Error-vs-stringified error mapping, and the unrecognized/nullish return false paths; and options.js's refreshSettings() three display branches, the conditional token-store submit path, and the logout error-recovery fallback. Closes JSONbored#7461
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7497 +/- ##
==========================================
- Coverage 91.41% 91.40% -0.02%
==========================================
Files 717 717
Lines 73035 73035
Branches 21635 21638 +3
==========================================
- Hits 66765 66754 -11
- Misses 5227 5234 +7
- Partials 1043 1047 +4
Flags with carried forward coverage won't be shown. Click here to find out more. |
|
Tip ✅ LoopOver review result - approve/merge recommendedReview updated: 2026-07-20 13:22:57 UTC
Review summary Nits — 5 non-blocking
Decision drivers
Context & advisory signals — never blocks the verdict
Linked issue satisfactionAddressed Review context
Contributor next steps
Signal definitions
🧪 Chat with LoopOverAsk LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.
Full command reference: https://loopover.ai/docs/loopover-commands 🧪 Experimental — new and may change. 🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.
|
test(extension): cover background.js message routing and options.js session UI
background.js (the service-worker onMessage router) and options.js (the
options-page controller) had no unit tests, unlike auth.js and content.js.
A regression in either -- background.js returning false instead of true and
silently breaking every async response, or refreshSettings() misclassifying an
expired session as valid -- would only surface by manually loading the unpacked
extension.
Add extension-background.test.ts and extension-options.test.ts using the vm
Script/createContext technique extension-content.test.ts established. Both files
statically import from auth.js, which a plain vm Script cannot execute, so the
import line is stripped and the handlers/auth helpers are injected as context
globals (the host Error is shared so 'error instanceof Error' matches the
single-realm extension). Covers background.js's pull-context/logout dispatch,
its Error-vs-stringified error mapping, and the unrecognized/nullish return
false paths; and options.js's refreshSettings() three display branches, the
conditional token-store submit path, and the logout error-recovery fallback.
Closes #7461