Skip to content

test: cover background.js and popup.js (issue #17) - #134

Open
Olawoyin007 wants to merge 1 commit into
mainfrom
test/extension-coverage
Open

test: cover background.js and popup.js (issue #17)#134
Olawoyin007 wants to merge 1 commit into
mainfrom
test/extension-coverage

Conversation

@Olawoyin007

Copy link
Copy Markdown
Owner

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 /classify and /classify/batch proxy 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.exports guard (the same pattern already in core/classifier.js) so their functions are importable under Node. Browser behaviour is unchanged - the guards are typeof module checks, and the load-time init/polling only runs when there is no module (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 into core/classifier.js + platforms/* (the file header says so, and manifest.json doesn'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)

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
Olawoyin007 force-pushed the test/extension-coverage branch from bec0221 to 56ea0e6 Compare July 26, 2026 08:15
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.

Add integration tests for Chrome extension

1 participant