You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Follow-up to #105. The unit-test sweep landed in PRs #110–#115 and brought the suite from 21 passed / 108 todo to 126 passed / 22 todo. The remaining 22 placeholders all sit inside two listener closures that aren't testable in their current shape — they need a production refactor (deps injection), not just test authoring, so they were intentionally split out.
Remaining todos (22)
tests/crypto-popup.test.ts — 19 todos
Cover handleEncrypt / handleDecrypt in src/pages/yivi-popup/yivi-popup.ts:
Cover handleBeforeSend's keepAlive closure body in src/background/background.ts:
encryption-failure path
popup-cancel path
plaintext-leak guard
Suggested approach
Both closures currently capture module-scoped singletons (pg-js SDK, browser.* namespaces, DOM globals) directly. To make them testable:
Lift the closures to top-level functions that take their dependencies as parameters (SDK client, runtime, storage, DOM root, etc.).
Listener bodies become thin call sites that pass the live deps in — no behavior change.
Tests instantiate the function with mocked deps from the existing tests/helpers/browser-mock.ts harness plus a small pg-js mock.
The PR #110 harness already covers most of browser.*. The new lift is the pg-js client and a DOM mock for the popup tests.
Verification
After refactor: npm test should reach ~148 passing / 0 todo.
npm run typecheck stays green.
npm run build:dev still produces a working extension.
Manual smoke-test the encrypt + decrypt happy paths in Thunderbird, since the closures are the live encryption/decryption code paths.
Risk
This touches the production code that PR #68's persistence fix lives in. The lift must keep the existing guards intact (composeTabs.has() check, persistence on toggle, keepAlive semantics on onBeforeSend). The state-lifecycle tests added in #110 should pin those, but a manual smoke-test through Thunderbird before merge is still warranted.
Background
Follow-up to #105. The unit-test sweep landed in PRs #110–#115 and brought the suite from
21 passed / 108 todoto126 passed / 22 todo. The remaining 22 placeholders all sit inside two listener closures that aren't testable in their current shape — they need a production refactor (deps injection), not just test authoring, so they were intentionally split out.Remaining todos (22)
tests/crypto-popup.test.ts— 19 todosCover
handleEncrypt/handleDecryptinsrc/pages/yivi-popup/yivi-popup.ts:tests/encryption-flow.test.ts— 3 todosCover
handleBeforeSend'skeepAliveclosure body insrc/background/background.ts:Suggested approach
Both closures currently capture module-scoped singletons (
pg-jsSDK,browser.*namespaces, DOM globals) directly. To make them testable:tests/helpers/browser-mock.tsharness plus a smallpg-jsmock.The PR #110 harness already covers most of
browser.*. The new lift is the pg-js client and a DOM mock for the popup tests.Verification
npm testshould reach ~148 passing / 0 todo.npm run typecheckstays green.npm run build:devstill produces a working extension.Risk
This touches the production code that PR #68's persistence fix lives in. The lift must keep the existing guards intact (
composeTabs.has()check, persistence on toggle,keepAlivesemantics ononBeforeSend). The state-lifecycle tests added in #110 should pin those, but a manual smoke-test through Thunderbird before merge is still warranted.Out of scope
Follow-up to #105.