OUT-3954: integration tests for payment.succeeded webhook - #71
Merged
Conversation
…d constants Shared harness for the payment.succeeded webhook suite: a webhook payload builder, absorbed-fee Xero mock defaults (account creation, expense lookup, bank transaction), and constants incl. TEST_FEE as the single fee source. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Happy path (US+AU) asserts the SPEND expense, synced_payments row, and expense sync log. Skip gates: isSyncEnabled (controller), addAbsorbedFees (handler), and unsupported region. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…guard paths Replay guard skip, both reuse arms of the transaction-resolution chain (by-reference and legacy), the concurrent-duplicate insert race guard, and the missing-Xero-invoice recreate path. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
A missing Xero invoice and a failing createBankTransaction both wrap to a 500 with a failed EXPENSE sync log and a failed_syncs row keyed by payment id. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
Greptile SummaryThis PR adds integration coverage for the
Confidence Score: 5/5This looks safe to merge.
Important Files Changed
Reviews (1): Last reviewed commit: "test(OUT-3954): cover payment.succeeded ..." | Re-trigger Greptile |
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.
OUT-3954: Integration tests for
payment.succeededwebhookAdds an integration-test suite for the
payment.succeededCopilot→Xero webhook on the existing testcontainers Postgres + Vitest harness, mirroring theinvoicePaid/invoiceVoided/invoiceDeletedsuites. Tests-only — no product code changed.Linear OUT-3954
Coverage (10 files, 12 cases)
synced_paymentsEXPENSE row, and EXPENSE/CREATED/SUCCESS sync log; asserts region account codes and the cents→dollars conversion.isSyncEnabled(controller),addAbsorbedFees(handler), unsupported region.findBankTransactionByReference ?? findLegacyExpenseByInvoice ?? createBankTransactionchain.onConflictDoNothingrace guard (transaction created, insert no-ops, sync log skipped).failed_syncsrow keyed by the payment id.Notable behavior documented
Unlike
invoice.paid, the whole body ofcreatePlatformExpensePaymentis wrapped in a try/catch that re-wraps any error (incl. a missing Xero invoice) as a 500 carrying afailedSyncLogPayload— so error cases here return 500, not 404, andfailed_syncs.resourceIdis the payment id, not the invoice id.Harness additions
test/fixtures/paymentSucceeded.webhook.tstest/helpers/mocks.tsTEST_FEE(single source for the fee value) intest/helpers/constants.tsVerification
pnpm typecheck✅ ·pnpm lint✅ ·pnpm test→ 46 files / 53 tests passing ✅🤖 Generated with Claude Code