test(encrypt): cover encryptPipeline, sealRaw and awaitAllOrAbort#117
Merged
Conversation
The encrypt/upload pipeline in src/crypto/encrypt.ts had no direct test coverage. Add unit tests with sealStream/loadWasm and the Cryptify upload sink mocked: - awaitAllOrAbort: happy path (no abort), first-failure abort + re-throw of the first error from either side, loser-rejection is swallowed (no unhandled rejection), and the abort(reason)-throws fallback. - encryptPipeline: seal -> chunk -> upload happy path returning the uuid, and upload-sink failure aborting the shared signal and re-throwing. - sealRaw: seals a Uint8Array payload and returns concatenated ciphertext. awaitAllOrAbort is exported for direct testing; it is not re-exported from src/index.ts, so the package's public API is unchanged. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
Author
There was a problem hiding this comment.
VERDICT: approve
Rules + review sign-off — clean. No blocking or style findings.
Checked the encrypt-pipeline test PR against the relevant TypeScript / test / PR-process rules:
- vitest-mock-hoisting ✓ — shared mocks are wrapped in
vi.hoisted(() => ({...}))and referenced from thevi.mockfactories, so no "cannot access before initialization" hazard. - conventional-commit-pr-titles ✓ —
test(encrypt): …is valid;pr-title.ymlruns on this repo. - pr-close-issue-keywords ✓ —
Closes #109on its own line will auto-close the tracking issue on merge. - tests-required-on-fixes ✓ — this PR is the coverage; each abort-path test was confirmed to fail when the logic is removed.
- Exporting
awaitAllOrAbortfor testability is scoped correctly (not re-exported fromsrc/index.ts), so the public API is unchanged.
Test suite green (230 passed) and typecheck clean per the prior step. Signing off and flipping to ready.
rubenhensen
approved these changes
Jul 21, 2026
|
🎉 This PR is included in version 2.3.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
Adds unit tests for the encrypt/upload pipeline in
src/crypto/encrypt.ts, which previously had no direct coverage.awaitAllOrAbort— the subtle concurrency helper (src/crypto/encrypt.ts:143):abort()whenabort(reason)throwsencryptPipeline— happy path (seal → chunk → upload) returns the upload uuid and carries the ZIP bytes through to the sink; an upload-sink failure aborts the shared signal driving the stream graph and re-throws.sealRaw— seals aUint8Arraypayload and returns the concatenated ciphertext.sealStream/loadWasm,fetchMPK,resolveSigningKeys,createZipReadableand the Cryptify upload sink are mocked; the realChunker/withTransformand policy builders run.Notes
awaitAllOrAbortis now exported so the concurrency logic can be unit-tested directly and deterministically. It is not re-exported fromsrc/index.ts, so the package's public API is unchanged.npm test: 230 passed) andnpm run typecheckclean.Closes #109