Skip to content

test(OUT-3955): integration tests for product.updated webhook - #72

Merged
SandipBajracharya merged 5 commits into
mainfrom
OUT-3955
Jul 14, 2026
Merged

test(OUT-3955): integration tests for product.updated webhook#72
SandipBajracharya merged 5 commits into
mainfrom
OUT-3955

Conversation

@SandipBajracharya

Copy link
Copy Markdown
Collaborator

What

Integration tests for the product.updated webhook flow on the testcontainers harness (OUT-3955, parent OUT-3949). Test-only — no production code changed.

Mirrors the existing productCreated/ suite: each test drives the real /api/webhook route end to end and mocks only the Copilot and Xero API clients.

Coverage (7 tests, all reachable branches)

Test Scenario
happyPath mapped product → updateItem called with code + htmlToText'd description, SUCCESS log, mapping row untouched, 200
productNotMapped no synced_items row → service no-ops, updateItem not called, 200
syncProductsAutomaticallyDisabled APIError(OK) swallowed → 200, no Xero call
isSyncDisabled workspace gate stops dispatch → 200, no Xero call
unsupportedRegion countryCode='GB' → ack & skip, 200
xeroUpdateItemFails updateItem throws → FAILED log + failed_syncs (type: 'product.updated'), mapping survives, 500
missingXeroItem mapped item absent from items-map → code read throws before updateItem, FAILED log + failed_syncs, 500

Also adds shared scaffolding: a productUpdated fixture (HTML in description to exercise htmlToText), three mock defaults (getItemsMap, updateItem, getProductsMapById), and a TEST_XERO_ITEM.code constant.

Intentionally out of scope

  • Idempotency / multiple mapped items — the unique index on synced_items (portalId, tenantId, productId) makes the service loop length ≤ 1, and update has no "already applied" branch.
  • Display-name enrichment failure (getCopilotProductAndXeroItem null-swallow) — shared production code; asserts only null names on an otherwise-SUCCESS log.

Verification

  • New suite: 7/7 pass
  • Full project: 53 files / 60 tests pass, pnpm typecheck and pnpm lint clean

🤖 Generated with Claude Code

SandipBajracharya and others added 4 commits July 14, 2026 15:51
…ts, and item code constant

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

linear-code Bot commented Jul 14, 2026

Copy link
Copy Markdown

OUT-3955

@vercel

vercel Bot commented Jul 14, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
xero-integration Ready Ready Preview, Comment Jul 14, 2026 10:49am

Request Review

@supabase

supabase Bot commented Jul 14, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project pkdwtcdqcefmlgxmcwmc because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@greptile-apps

greptile-apps Bot commented Jul 14, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds integration coverage for the product.updated webhook flow.

  • Adds a reusable product-updated webhook fixture.
  • Adds Xero and Copilot mock defaults for product updates.
  • Covers successful updates, sync gates, unsupported regions, unmapped products, and Xero failures.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
test/integration/webhook/productUpdated/productNotMapped.test.ts Adds coverage for an unmapped product and verifies the returned empty item list.
test/integration/webhook/productUpdated/happyPath.test.ts Adds end-to-end coverage for updating a mapped Xero item and recording a successful sync.
test/integration/webhook/productUpdated/xeroUpdateItemFails.test.ts Adds coverage for Xero update failures and their recorded retry state.
test/integration/webhook/productUpdated/missingXeroItem.test.ts Adds coverage for a local mapping whose upstream Xero item is absent.
test/helpers/mocks.ts Adds shared mock behavior for product lookup and Xero item updates.

Reviews (2): Last reviewed commit: "test(OUT-3955): assert no-mapping branch..." | Re-trigger Greptile

Comment thread test/integration/webhook/productUpdated/productNotMapped.test.ts
The product-not-mapped test previously asserted only 200 + no Xero call +
no rows, which the swallowed syncProductsAutomatically gate also satisfies.
Assert the handler's { items: [] } result in the response body so the test
proves it reached the no-mapping path.

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

Copy link
Copy Markdown
Collaborator Author

@greptileai review again

@priosshrsth priosshrsth left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lgtm

@SandipBajracharya
SandipBajracharya merged commit cbdf288 into main Jul 14, 2026
7 checks passed
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