OUT-3953: integration tests for invoice.deleted webhook - #70
Merged
Conversation
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ag disabled Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ice is missing Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…Invoice failure Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ior created log deleteInvoice built its sync-log payloads by spreading prevSyncLog without setting the NOT-NULL entityType. When no invoice.created log exists the log INSERT crashes, so a delete whose Xero calls succeeded still returns 500 and (on the failure path) records no failed_syncs row. Hardcode entityType like voidInvoice and syncPaidInvoiceToXero already do, and cover it with a regression test. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ce then deletes 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 coverage for the
Confidence Score: 5/5This looks safe to merge.
Important Files Changed
Reviews (1): Last reviewed commit: "test(OUT-3953): assert invoice.deleted c..." | Re-trigger Greptile |
priosshrsth
approved these changes
Jul 10, 2026
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 integration tests for the
invoice.deletedwebhook flow, following the OUT-3951/OUT-3952 pattern, plus thedeleteInvoiceentityTypefix deferred from OUT-3952. Ref: OUT-3953.Drives the real
/api/webhookroute end-to-end, mocking only the Copilot and Xero clients.Test cases (
test/integration/webhook/invoiceDeleted/)happyPath.test.tsVOIDED+DELETEDlogsalreadyVoided.test.tsVOIDED→ skips void, deletes directly; onlyDELETEDlogdeleteSyncDisabled.test.tsDELETEDlogsyncDisabled.test.tsinvoiceNotFound.test.tsgetInvoiceById→ undefined → 500 (validation is inside the try) +failed_syncsxeroDeleteFails.test.tsdeleteInvoicethrows → 500; failedDELETEDlog +failed_syncsmissingXeroInvoice.test.tsxeroInvoiceIdnull → create → void → deletenoPriorCreatedLog.test.tsHarness additions:
test/fixtures/deletedInvoice.webhook.ts,test/helpers/deleteSyncFlag.ts(togglesFLAG_ENABLE_DELETE_SYNCper test — it defaults tofalseand isn't set in.env.test), and adeleteInvoicedefault intest/helpers/mocks.ts.Production fix
deleteInvoicebuilt its sync-log payloads by spreadingprevSyncLogwithout hardcoding theNOT NULLentityType. With no priorinvoice.createdlog, the log INSERT crashed — a delete whose Xero calls succeeded still returned 500, and on the failure path nofailed_syncsrow was written. Fixed by hardcodingentityType: SyncEntityType.INVOICEin both the success log and failure payload, matchingvoidInvoice/syncPaidInvoiceToXero. Covered bynoPriorCreatedLog.test.ts(verified failing before the fix).Notes / follow-ups (out of scope)
voidInvoicefailure duringdeleteInvoiceis logged insync_logswitheventType=deleted(audit-trail mislabel only; retry unaffected).voidInvoice(404) anddeleteInvoice(500) for a missing Xero invoice — pinned byinvoiceNotFound.test.ts.invoicePaid/missingXeroInvoice.test.ts(synced_contactsduplicate-key) tracked in OUT-3971.Verification
pnpm test→ 36 files / 41 tests passpnpm typecheckandpnpm lintclean🤖 Generated with Claude Code