test: cover background.js and popup.js (issue #17) - #134
Open
Olawoyin007 wants to merge 1 commit into
Open
Conversation
The extension logic layer had no tests: background.js (API proxy, health, corrections, batch enrichment, badge) and popup.js (settings load/save, status rendering, allowlist normalization). Added 17 + 12 Jest tests. Both files get a module.exports guard (same pattern as core/classifier.js) so their functions are importable under Node; browser behaviour is unchanged. content.js is not covered - it has been dead code since Phase 3.5. Jest 110 pass, pytest 97 pass.
Olawoyin007
force-pushed
the
test/extension-coverage
branch
from
July 26, 2026 08:15
bec0221 to
56ea0e6
Compare
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.
Closes #17.
Summary
The extension's logic layer had no test coverage. This adds it for the two untested JS surfaces:
background.js(17 tests): the/classifyand/classify/batchproxy calls, health-check fail-open, correction loading + server-field formatting, batch enrichment with user corrections, and the status badge (green ok / red!).popup.js(12 tests): settings load/save round-trip, connection-status rendering (Connected / Ollama down / server not running), correction count + pluralization, and allowlist add with@/u/handle normalization.Both files get a tiny
module.exportsguard (the same pattern already incore/classifier.js) so their functions are importable under Node. Browser behaviour is unchanged - the guards aretypeof modulechecks, and the load-time init/polling only runs when there is nomodule(i.e. in the browser).Note on
content.js: the issue lists it, but it has been dead code since Phase 3.5 - the content script was split intocore/classifier.js+platforms/*(the file header says so, andmanifest.jsondoesn't load it). So it is intentionally not covered.Testing
cd extension && npm test- 110 pass (81 existing + 17 + 12 new)pytest tests/ -q- 97 pass (server untouched)