Skip to content
This repository was archived by the owner on Jul 30, 2026. It is now read-only.

tests: extract buildRecipients + partial implementation of crypto-popup.test.ts - #115

Merged
rubenhensen merged 1 commit into
mainfrom
tests/crypto-popup
May 16, 2026
Merged

tests: extract buildRecipients + partial implementation of crypto-popup.test.ts#115
rubenhensen merged 1 commit into
mainfrom
tests/crypto-popup

Conversation

@dobby-coder

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

Copy link
Copy Markdown
Contributor

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

Summary

Pulls the `SerializedRecipient[] -> Recipient[]` mapping out of `yivi-popup.ts` into a new `src/pages/yivi-popup/recipients.ts`. The popup now calls `buildRecipients(pg.recipient, data.recipients)`. Production behavior is unchanged.

Implements 5 of 23 `it.todo` placeholders in `tests/crypto-popup.test.ts` (the recipient-rebuild subset: typed-vs-domain, custom policy mapping, no double-counting the email attribute, no `extraAttribute` when policy is absent).

The remaining 18 placeholders are scoped to the popup's `handleEncrypt` / `handleDecrypt` closures and the popup's DOM init. Reaching them needs either:

  1. The popup loaded under jsdom with a stubbed pg-js, or
  2. `handleEncrypt`/`handleDecrypt` extracted behind injected `pg` + `runtime` deps.

Both are substantial refactors and out of scope for this batch of test PRs. Tracking the remaining surface here so it isn't forgotten — the test count goes back up once that refactor lands.

Test report

Before: 59 passing, 82 todo.
After: 64 passing, 78 todo. (+5 tests; -4 todos)

Combined progress across the 5 follow-up PRs (#111#115)

PR Tests added Todo reduction
#111 message-routing +14 -11
#112 sent-copy +9 -8
#113 encryption-flow +19 -18
#114 decryption-flow +19 -19
#115 crypto-popup +5 -4
Total +66 -60

Once all five land the suite moves from 21→87 passing and 108→48 todo — the remaining todos are the closures that need the larger refactor noted above.

Reviewer quickstart

```
git fetch origin && git checkout tests/crypto-popup && npm install && npm test
```

Refs #105.

…ests

Pulls the SerializedRecipient -> Recipient[] mapping out of
yivi-popup.ts into src/pages/yivi-popup/recipients.ts. The popup now
calls buildRecipients(pg.recipient, data.recipients); production
behavior is unchanged.

Implements 5 of 23 it.todo placeholders in crypto-popup.test.ts (the
recipient-rebuild subset). The remaining placeholders need the popup
loaded under jsdom or its handle{Encrypt,Decrypt} closures extracted
behind injected pg/runtime deps — left as todos rather than written
as shape-check noise. (Refactoring those closures is a much larger
change than this test PR should carry.)

Test report: 59 -> 64 passing (+5), 82 -> 78 todo.

Refs #105.
@dobby-coder
dobby-coder Bot requested a review from rubenhensen May 16, 2026 13:37
@dobby-coder
dobby-coder Bot marked this pull request as ready for review May 16, 2026 13:41

@dobby-coder dobby-coder Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Self-review (the bot opened this PR, so GH blocks --approve). Posting findings here for the human reviewer:

  • buildRecipients is a clean, behaviour-preserving extraction from yivi-popup.ts: same branch on r.type, same policy iteration, same EMAIL_ATTRIBUTE_TYPE skip.
  • RecipientFactory = Pick<PostGuard["recipient"], "email" | "emailDomain"> keeps the production call site type-safe while letting tests inject a fake.
  • Tests cover the meaningful invariants: typed-vs-domain dispatch, no double-counting the email attribute, no extraAttribute when policy is absent, and extraAttribute calls for non-email policy entries.
  • npm test locally: 64 passed / 78 todo, matching the PR description. CI build is green.

The remaining 18 todos for handleEncrypt / handleDecrypt / DOM init are out of scope here and clearly documented as needing a deeper refactor.

No blockers from this agent's side — ready for human approval and merge.

@rubenhensen
rubenhensen merged commit 39ccb92 into main May 16, 2026
2 checks passed
@rubenhensen
rubenhensen deleted the tests/crypto-popup branch May 16, 2026 13:53
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