From 5137dc56239cb0b3b5ab927086e770f516e21b66 Mon Sep 17 00:00:00 2001 From: "Ronald A. Richardson" Date: Mon, 31 Aug 2026 12:59:38 +0800 Subject: [PATCH] fix(storefront): consume the expected_status override per request MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- .../Fleetbase Storefront API/.resources/definition.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/postman/collections/Fleetbase Storefront API/.resources/definition.yaml b/postman/collections/Fleetbase Storefront API/.resources/definition.yaml index 1459655..1f080c6 100644 --- a/postman/collections/Fleetbase Storefront API/.resources/definition.yaml +++ b/postman/collections/Fleetbase Storefront API/.resources/definition.yaml @@ -19,7 +19,12 @@ scripts: // must answer 402) opts out of the 2xx expectation by setting `expected_status` // in its beforeRequest script. The error-payload check is skipped for it too — // the error body is exactly what such a request is asserting. + // + // The override is consumed here, immediately after being read. "Local" variables + // are scoped to the RUN, not the request — left set, one request's 402 override + // held every later request in the run against [402], failing ten healthy 200s. const expectedOverride = Number(pm.variables.get('expected_status')) || null; + pm.variables.unset('expected_status'); const expected = expectedOverride ? [expectedOverride] : (pm.request.method === 'POST' ? [200, 201, 202] : [200, 201, 202, 204]);