Skip to content

OUT-4006: land payout test suite + shared test infra#268

Open
SandipBajracharya wants to merge 5 commits into
feature/payout-reconciliationfrom
OUT-4006
Open

OUT-4006: land payout test suite + shared test infra#268
SandipBajracharya wants to merge 5 commits into
feature/payout-reconciliationfrom
OUT-4006

Conversation

@SandipBajracharya

Copy link
Copy Markdown
Collaborator

Adds integration + unit coverage for the bank-deposit payout flow so CI exercises it, plus the shared test infra those tests depend on. Test-only — no source changes.

Shared test infra

  • test/integration/setup.ts — mock QB_ACCOUNT_COLUMNS on the @/utils/intuitAPI mock
  • test/helpers/mocks.tscreateDeposit + account-status (getAnAccount/updateAccount) mocks
  • test/helpers/seed.tsTEST_BANK_ACCOUNT_REF + bank-account seeding on the portal connection

Tests

  • payoutReconciliation/ — happy path + abort guards (refund line, negative fee, sum mismatch, duplicate/empty/unresolved line items), idempotent redelivery, flag-off no-op, inactive/deleted bank account, claim idempotency, invoice→QBO-payment resolution
  • paymentSucceeded/bankDepositFlagNoOp.test.tspayment.succeeded creates no per-payment deposit in batched mode
  • syncLog/staleReaperPayoutTerminal.test.ts — stale PENDING payout claims flip to non-retryable
  • unit/utils/tokenRefresh.test.tsbankAccountRef carried on every token path
  • unit/type/settingRequestSchema.test.ts + setting/ — bank-account listing, invoice settings, request schema (OUT-4003)
  • test/fixtures/payout.webhook.ts — payout webhook fixture

Excludes the local captureWebhookEventGET harness (webhook/route.ts, webhook/webhook.controller.ts) — a dev-only manual testing aid.

🤖 Generated with Claude Code

SandipBajracharya and others added 5 commits July 23, 2026 14:50
Mock QB_ACCOUNT_COLUMNS on the intuitAPI mock, add createDeposit and
account-status (getAnAccount/updateAccount) mocks, and seed
TEST_BANK_ACCOUNT_REF on the portal connection.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Happy path plus abort guards (refund line, negative fee, sum mismatch,
duplicate/empty/unresolved line items), idempotent redelivery, flag-off
no-op, inactive/deleted bank account, claim idempotency, and
invoice->QBO-payment resolution.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
payment.succeeded creates no per-payment deposit in batched mode; stale
PENDING payout claims flip to non-retryable.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…uest schema

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 23, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
quickbooks-sync (dev) Ready Ready Preview, Comment Jul 23, 2026 9:10am
quickbooks-sync Ready Ready Preview, Comment Jul 23, 2026 9:10am

Request Review

@linear-code

linear-code Bot commented Jul 23, 2026

Copy link
Copy Markdown

OUT-4006

@SandipBajracharya

Copy link
Copy Markdown
Collaborator Author

@greptileai review

@greptile-apps

greptile-apps Bot commented Jul 23, 2026

Copy link
Copy Markdown

Greptile Summary

Adds shared integration-test infrastructure and broad coverage for payout reconciliation, bank-deposit settings, stale payout claims, and token propagation.

  • Introduces a representative payout webhook fixture and reusable QuickBooks mocks and seed constants.
  • Covers payout success, validation guards, account state handling, payment resolution, idempotency, and feature-flag behavior.
  • Adds settings API/schema tests and verifies bankAccountRef across token retrieval paths.

Confidence Score: 5/5

The test-only pull request appears safe to merge, with no concrete defects identified in the added coverage or shared test infrastructure.

The new fixtures and mocks align with their production contracts, and the added tests consistently isolate database state while exercising the intended payout, settings, and token paths.

Important Files Changed

Filename Overview
test/integration/setup.ts Extends the shared Intuit API mock with the production account-column export required by bank-account controller tests.
test/helpers/mocks.ts Adds a successful deposit mock while preserving override-based test customization.
test/helpers/seed.ts Adds a shared bank-account reference used by payout and settings fixtures.
test/fixtures/payout.webhook.ts Defines a payout fixture whose field types and totals match the webhook validation and reconciliation contracts.
test/integration/quickbooks/payoutReconciliation/happyPath.test.ts Verifies deposit construction, linked payment lines, fee accounting, destination account, transaction date, and success logging.
test/integration/quickbooks/setting/invoiceSettings.test.ts Covers persistence, validation, and retrieval of batched-deposit invoice settings.
test/unit/utils/tokenRefresh.test.ts Extends existing token-path assertions to ensure the configured bank account reference is retained.

Reviews (1): Last reviewed commit: "test(OUT-4003): cover bank-account listi..." | Re-trigger Greptile

@greptile-apps

greptile-apps Bot commented Jul 23, 2026

Copy link
Copy Markdown

Greptile Summary

Adds shared test infrastructure and comprehensive coverage for payout reconciliation.

  • Covers successful batched deposits, validation guards, account recovery, idempotency, and stale claims.
  • Verifies bank-deposit settings, account listing, token propagation, and per-payment no-op behavior.
  • Adds reusable payout fixtures, account references, and QuickBooks API mocks.

Confidence Score: 5/5

The PR appears safe to merge, with no actionable defects identified in the added test infrastructure or coverage.

The new fixtures match the payout schema, the integration suite is configured for sequential shared-database execution with per-test cleanup, and the mock additions match the production exports and APIs exercised by these tests.

Important Files Changed

Filename Overview
test/integration/quickbooks/payoutReconciliation/happyPath.test.ts Exercises the complete successful payout-to-deposit flow and verifies its QuickBooks payload and sync log.
test/integration/setup.ts Extends the integration mock with the account-column export required by account-listing code.
test/helpers/mocks.ts Adds a default createDeposit response used by the payout integration suite.
test/fixtures/payout.webhook.ts Introduces a schema-compatible, internally balanced payout webhook fixture.
test/integration/quickbooks/setting/invoiceSettings.test.ts Verifies invoice setting persistence, validation, and retrieval of the selected bank account.
test/unit/utils/tokenRefresh.test.ts Extends token-path assertions to ensure bankAccountRef survives fresh and refreshed token flows.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Payout reconciliation webhook] --> B{Bank-deposit mode enabled?}
    B -- No --> C[No-op]
    B -- Yes --> D{Payload and account valid?}
    D -- No --> E[Record terminal failure]
    D -- Yes --> F[Resolve invoice payment IDs]
    F --> G{All lines resolved and totals valid?}
    G -- No --> E
    G -- Yes --> H[Create one QuickBooks deposit]
    H --> I[Record payout success]
    I --> J[Ignore duplicate delivery]
Loading

Reviews (2): Last reviewed commit: "test(OUT-4003): cover bank-account listi..." | Re-trigger Greptile

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.

1 participant