Skip to content

test(nodejs): add checkout behavioral test suite#138

Open
vishkaty wants to merge 1 commit into
Universal-Commerce-Protocol:mainfrom
vishkaty:test/nodejs-behavioral-suite
Open

test(nodejs): add checkout behavioral test suite#138
vishkaty wants to merge 1 commit into
Universal-Commerce-Protocol:mainfrom
vishkaty:test/nodejs-behavioral-suite

Conversation

@vishkaty

Copy link
Copy Markdown
Contributor

Closes the Node.js behavioral test gap described in #136.

What

Adds a behavioral test suite for the Node.js sample, mirroring the Python
server's coverage on the CI lane added in #126, so a regression in the checkout
flow no longer ships green. It uses the existing node:test + app.request()
conventions and adds no dependencies.

Area Coverage
lifecycle.test.ts create → retrieve → complete (order assigned), payment-failure (402), cancel, and completed/canceled immutability (409)
idempotency.test.ts same-key replay returns the original checkout; same-key + different body → 409; keyless requests stay independent
validation_flow.test.ts unknown product and over-stock are rejected; in-stock succeeds
discount.test.ts (extended) case-insensitive code match, empty codes[] clears discounts, and allocations[] reconcile to the applied amount

Why

The Node.js suite was three files; the Python server has a full behavioral
suite. That asymmetry meant checkout-flow regressions on the Node.js sample
passed CI. These tests exercise the real service handlers end to end through a
minimal Hono app (the same approach as discovery.test.ts), so they catch
behavioral drift, not just types.

Verification

  • npm run build clean and npm test green (21 tests).
  • pre-commit run clean (prettier, codespell).

Happy to split this into per-area PRs if that reviews more easily — offered in
#136; opening it as one small suite here since the areas share the harness.

…validation, discount)

Mirrors the Python server's behavioral coverage on the Node.js sample's CI
lane (added in Universal-Commerce-Protocol#126), so a regression in the checkout flow no longer ships
green. Uses the existing node:test + app.request() conventions, no new deps.

- lifecycle: create -> retrieve -> complete (order assigned), payment failure
  (402), cancel, and completed/canceled immutability (409)
- idempotency: same-key replay returns the original checkout; same-key with a
  different body is a 409; keyless requests stay independent
- validation: unknown product and over-stock are rejected; in-stock succeeds
- discount: case-insensitive code match, empty codes[] clears discounts, and
  allocations reconcile to the applied amount
@damaz91 damaz91 added the status:needs-triage Signal that the PR is ready for human triage label Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status:needs-triage Signal that the PR is ready for human triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants