Skip to content
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
rubenhensen merged 2 commits into
mainfrom
tests/sent-copy
May 16, 2026
Merged

tests: extract onAfterSend + implement sent-copy.test.ts#112
rubenhensen merged 2 commits into
mainfrom
tests/sent-copy

Conversation

@dobby-coder

@dobby-coder dobby-coder Bot commented May 16, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #110 (PR 2 of 5 per the plan on #105).

Summary

  • Extracts the onAfterSend listener body into handleAfterSend in src/background/sent-copy.ts. notifyError, isPGEncrypted, and getOrCreateLocalFolder are injected so the swap logic is testable without standing up the whole background script.
  • Implements all 8 it.todo placeholders in tests/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 finally cleanup 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.

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.
# Conflicts:
#	src/background/background.ts
@rubenhensen
rubenhensen marked this pull request as ready for review May 16, 2026 14:03

@rubenhensen rubenhensen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Clean extraction of handleAfterSend with dep injection. Tests cover happy path, failure path, no-local-folder path. finally cleanup preserved.

@rubenhensen
rubenhensen merged commit 823dbdf into main May 16, 2026
2 checks passed
@rubenhensen
rubenhensen deleted the tests/sent-copy branch May 16, 2026 14:04
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant