test(nodejs): add checkout behavioral test suite#138
Open
vishkaty wants to merge 1 commit into
Open
Conversation
…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
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.
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.
lifecycle.test.tsidempotency.test.tsvalidation_flow.test.tsdiscount.test.ts(extended)codes[]clears discounts, andallocations[]reconcile to the applied amountWhy
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 catchbehavioral drift, not just types.
Verification
npm run buildclean andnpm testgreen (21 tests).pre-commit runclean (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.