This repository was archived by the owner on Jul 30, 2026. It is now read-only.
tests: extract onAfterSend + implement sent-copy.test.ts - #112
Merged
Conversation
Pulls the onAfterSend listener body out of background.ts into a new handleAfterSend function in src/background/sent-copy.ts. notifyError, isPGEncrypted, and getOrCreateLocalFolder are injected so the swap logic can be unit-tested without standing up the whole background script. Implements all 8 it.todo placeholders in tests/sent-copy.test.ts plus one extra for the 'no local folder' path. Test report: 59 -> 68 passing (+9), 82 -> 74 todo. Refs #105.
This was referenced May 16, 2026
# Conflicts: # src/background/background.ts
rubenhensen
marked this pull request as ready for review
May 16, 2026 14:03
rubenhensen
approved these changes
May 16, 2026
rubenhensen
left a comment
Contributor
There was a problem hiding this comment.
LGTM. Clean extraction of handleAfterSend with dep injection. Tests cover happy path, failure path, no-local-folder path. finally cleanup preserved.
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Follow-up to #110 (PR 2 of 5 per the plan on #105).
Summary
onAfterSendlistener body intohandleAfterSendinsrc/background/sent-copy.ts.notifyError,isPGEncrypted, andgetOrCreateLocalFolderare injected so the swap logic is testable without standing up the whole background script.it.todoplaceholders intests/sent-copy.test.ts, plus a 9th case for the "no local folder available" path that the original code already handled but had no coverage for.No behavior change. The
finallycleanup that PR #109 introduced (cleanupComposeTab + clearInFlightUpload + persist*) is preserved verbatim, with tests pinning both the happy path and the failure path.Test report
Before: 59 passing, 82 todo.
After: 68 passing, 74 todo. (+9 tests; -8 todos)
Reviewer quickstart
```
git fetch origin && git checkout tests/sent-copy && npm install && npm test
```
Refs #105.