Skip to content

fix(storefront): consume the expected_status override per request - #56

Merged
roncodes merged 1 commit into
mainfrom
fix/expected-status-override-scope
Aug 31, 2026
Merged

fix(storefront): consume the expected_status override per request#56
roncodes merged 1 commit into
mainfrom
fix/expected-status-override-scope

Conversation

@roncodes

Copy link
Copy Markdown
Member

What happened

Follow-up bugfix to #55. The re-run of the storefront contract job shows the original 10 failures are gone — customer updates authenticate, the 402 negative contract asserts correctly, and the cash capture creates a real order — but 10 NEW failures appeared, all shaped like:

Before Cash Pickup Checkout responds 2xx
got HTTP 200: expected 200 to be one of [ 402 ]

Every one is a healthy 2xx being held against [402]. Root cause: pm.variables is run-scoped, not request-scoped. Once Capture Stripe checkout without payment set expected_status = 402 in its beforeRequest script, the variable stayed set, and the baseline assertion applied the 402 expectation to every request that ran after it.

Fix

One line in the collection baseline script: pm.variables.unset('expected_status') immediately after reading it, so an override applies to exactly the request whose beforeRequest script set it. A comment documents the run-scope gotcha for the next person.

Safe because the collection-level afterResponse runs before the request-level one (which only inspects pm.response), and the error-payload skip uses the already-captured const.

Validation

  • node scripts/validate-collections.js — 5 collections, 3 environments validated
  • postman collection lint on Fleetbase Storefront API — 62 items, 0 errors, 0 warnings

After merge, re-running the storefront#91 contract job should be fully green — no companion changes needed this time (fleetbase/fleetbase#635 is already merged and its sequence is correct).

pm.variables lives for the whole run, not one request — so after Capture
Stripe checkout without payment set expected_status=402 (and correctly
passed), every later request in the run was asserted against [402] and
ten healthy 200/201 responses were reported as failures, e.g.:

  Before Cash Pickup Checkout responds 2xx
  got HTTP 200: expected 200 to be one of [ 402 ]

Unset the variable in the collection baseline immediately after reading
it, so an override applies to exactly the request whose beforeRequest
script set it. Safe: the collection-level script runs before the
request-level afterResponse, which only inspects pm.response, and the
error-payload skip uses the already-captured const.

Validation: node scripts/validate-collections.js (5 collections, 3
environments); postman collection lint on Fleetbase Storefront API —
62 items, 0 errors, 0 warnings.
@roncodes
roncodes merged commit 43253db into main Aug 31, 2026
1 check passed
@roncodes
roncodes deleted the fix/expected-status-override-scope branch August 31, 2026 05:07
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.

1 participant