Skip to content

eng-194#292

Merged
Connorbelez merged 1 commit intomainfrom
eng-194
Mar 27, 2026
Merged

eng-194#292
Connorbelez merged 1 commit intomainfrom
eng-194

Conversation

@Connorbelez
Copy link
Copy Markdown
Owner

@Connorbelez Connorbelez commented Mar 27, 2026

TL;DR

Replaced shallow transfer effect tests with comprehensive integration tests that verify the actual transfer effect handlers create correct journal entries and handle edge cases properly.

What changed?

Completely rewrote convex/engine/effects/__tests__/transfer.test.ts to use convex-test integration testing instead of simple registry presence checks. The new tests verify:

  • recordTransferProviderRef patches provider references onto transfers
  • publishTransferConfirmed creates CASH_RECEIVED entries for inbound transfers and LENDER_PAYOUT_SENT entries for outbound transfers
  • Bridged transfers (with collectionAttemptId) skip duplicate cash posting
  • publishTransferReversed creates REVERSAL entries with proper causedBy linkage
  • publishTransferFailed patches failure metadata correctly
  • Error conditions like missing direction or missing journal entries throw appropriate errors

How to test?

Run the new integration tests:

bun run test convex/engine/effects/__tests__/transfer.test.ts

Also verify related cash ledger tests still pass:

bun run test convex/payments/cashLedger/__tests__/reversalCascade.test.ts
bun run test convex/payments/cashLedger/__tests__/transferReconciliation.test.ts

Why make this change?

The original tests only verified that effect handlers were registered in the registry but didn't test their actual behavior. Since these effects are critical for posting cash journal entries when transfers confirm, fail, or reverse, proper integration testing was needed to ensure the handlers work correctly with the cash ledger and handle the D4 conditional logic for bridged vs non-bridged transfers.

Summary by CodeRabbit

  • Tests

    • Expanded integration test coverage for transfer operations to validate proper ledger integration when transfers are confirmed, failed, or reversed.
  • Documentation

    • Added implementation specification documents for transfer effect handlers, including integration requirements and verification criteria.

@linear
Copy link
Copy Markdown

linear bot commented Mar 27, 2026

Copy link
Copy Markdown

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Sorry @Connorbelez, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 27, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 47d42e9e-b645-405f-a0d1-8ebdc22e42f8

📥 Commits

Reviewing files that changed from the base of the PR and between a66a8a0 and d44847a.

📒 Files selected for processing (6)
  • convex/engine/effects/__tests__/transfer.test.ts
  • specs/ENG-194/chunks/chunk-01-transfer-effect-tests/context.md
  • specs/ENG-194/chunks/chunk-01-transfer-effect-tests/status.md
  • specs/ENG-194/chunks/chunk-01-transfer-effect-tests/tasks.md
  • specs/ENG-194/chunks/manifest.md
  • specs/ENG-194/tasks.md

📝 Walkthrough

Walkthrough

The pull request expands transfer effect handler test coverage from lightweight unit tests to full integration tests using a Convex runtime harness, validating observable side effects on database documents and journal entries. Supporting documentation is added outlining implementation requirements, architecture context, completion status, and task tracking for ENG-194.

Changes

Cohort / File(s) Summary
Transfer Effect Integration Tests
convex/engine/effects/__tests__/transfer.test.ts
Replaced lightweight registry/payload extraction unit tests with comprehensive integration tests validating DB and journal side effects for four handlers: recordTransferProviderRef (patches providerRef), publishTransferConfirmed (creates cash/journal entries with correct entryType, skips bridged transfers, rejects missing direction), publishTransferFailed (patches failure metadata), publishTransferReversed (creates REVERSAL entries with causedBy linkage, skips bridged reversals, rejects missing originating journal). Added test helpers for seeding entities and loading journal entries via transfer-request index.
ENG-194 Implementation Specification
specs/ENG-194/tasks.md, specs/ENG-194/chunks/manifest.md, specs/ENG-194/chunks/chunk-01-transfer-effect-tests/...
Added implementation plan, architecture context document, task checklist, and status tracking for ENG-194 transfer effect handlers feature. Documentation specifies acceptance criteria, integration contracts, journal posting logic (D4 conditional for bridged transfers, fail-closed reversals), and validation requirements.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

Possibly related PRs

Poem

🐰 Hops with glee through transfer flows,
Integration tests now reap what code sows,
Journal entries linked with causedBy care,
Bridged reversals skipped with developer flair!
Specs and tasks laid crystal clear—
Transfer handlers shine throughout the year!

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title 'eng-194' is a ticket/issue reference only, not a descriptive summary of the actual changes made in the pull request. Use a descriptive title that summarizes the main change, such as 'Replace transfer effect tests with comprehensive integration tests' or 'Implement integration tests for transfer effect handlers'.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch eng-194

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Owner Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@Connorbelez Connorbelez marked this pull request as ready for review March 27, 2026 21:47
Copilot AI review requested due to automatic review settings March 27, 2026 21:47
Copy link
Copy Markdown

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR upgrades transfer effect coverage by replacing shallow “registry presence” assertions with integration tests that exercise the real transfer effect internal mutations and verify correct cash-ledger journal posting behavior across confirmed/failed/reversed/bridged scenarios.

Changes:

  • Rewrote convex/engine/effects/__tests__/transfer.test.ts to use convex-test harnessing and assert actual journal entries + transfer patches.
  • Added explicit coverage for bridged-transfer skip behavior and fail-loud / fail-closed error paths.
  • Added ENG-194 spec/task tracking docs describing the testing work and verification status.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
specs/ENG-194/tasks.md Adds ENG-194 task checklist and verification steps for the transfer effect test rewrite.
specs/ENG-194/chunks/manifest.md Introduces chunk manifest for ENG-194 work breakdown/status tracking.
specs/ENG-194/chunks/chunk-01-transfer-effect-tests/tasks.md Chunk-level checklist for transfer effect integration test coverage.
specs/ENG-194/chunks/chunk-01-transfer-effect-tests/status.md Records completion notes + quality gate results for the chunk.
specs/ENG-194/chunks/chunk-01-transfer-effect-tests/context.md Captures implementation plan context and relevant code excerpts for ENG-194.
convex/engine/effects/tests/transfer.test.ts Replaces shallow tests with integration tests validating effect handler behavior and cash ledger postings.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Connorbelez Connorbelez merged commit b547b62 into main Mar 27, 2026
5 of 7 checks passed
Connorbelez added a commit that referenced this pull request Mar 28, 2026
### TL;DR

Replaced shallow transfer effect tests with comprehensive integration tests that verify the actual transfer effect handlers create correct journal entries and handle edge cases properly.

### What changed?

Completely rewrote `convex/engine/effects/__tests__/transfer.test.ts` to use `convex-test` integration testing instead of simple registry presence checks. The new tests verify:

- `recordTransferProviderRef` patches provider references onto transfers
- `publishTransferConfirmed` creates `CASH_RECEIVED` entries for inbound transfers and `LENDER_PAYOUT_SENT` entries for outbound transfers
- Bridged transfers (with `collectionAttemptId`) skip duplicate cash posting
- `publishTransferReversed` creates `REVERSAL` entries with proper `causedBy` linkage
- `publishTransferFailed` patches failure metadata correctly
- Error conditions like missing direction or missing journal entries throw appropriate errors

### How to test?

Run the new integration tests:
```bash
bun run test convex/engine/effects/__tests__/transfer.test.ts
```

Also verify related cash ledger tests still pass:
```bash
bun run test convex/payments/cashLedger/__tests__/reversalCascade.test.ts
bun run test convex/payments/cashLedger/__tests__/transferReconciliation.test.ts
```

### Why make this change?

The original tests only verified that effect handlers were registered in the registry but didn't test their actual behavior. Since these effects are critical for posting cash journal entries when transfers confirm, fail, or reverse, proper integration testing was needed to ensure the handlers work correctly with the cash ledger and handle the D4 conditional logic for bridged vs non-bridged transfers.

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->

## Summary by CodeRabbit

* **Tests**
  * Expanded integration test coverage for transfer operations to validate proper ledger integration when transfers are confirmed, failed, or reversed.

* **Documentation**
  * Added implementation specification documents for transfer effect handlers, including integration requirements and verification criteria.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This was referenced Mar 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants