From a648915eadc9c41f94b5918ee9e9629a6170bb7c Mon Sep 17 00:00:00 2001 From: "Ronald A. Richardson" Date: Wed, 14 Oct 2026 16:19:35 +0800 Subject: [PATCH] fix(fleetbase-api): assert the completed-order refusal instead of skipping cycle passes Postman CLI 1.53 counts a request ended with pm.execution.skipRequest() as "Request could not be completed" and exits 1: the first run after #69 completed the order, passed every assertion, and still failed on the 11 skipped passes. The Fleetbase API baseline now honours expected_status the way the Storefront baseline does; Update Order Activity sets it to 400 once Get Order Next Activity has recorded the flow as exhausted, and the last activity is kept so the body stays JSON. --- .../Fleetbase API/.resources/definition.yaml | 11 +++++++++- .../Get Order Next Activity.request.yaml | 20 +++++++------------ .../Orders/Update Order Activity.request.yaml | 10 +++++----- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/postman/collections/Fleetbase API/.resources/definition.yaml b/postman/collections/Fleetbase API/.resources/definition.yaml index 09fcd52..970e8f2 100644 --- a/postman/collections/Fleetbase API/.resources/definition.yaml +++ b/postman/collections/Fleetbase API/.resources/definition.yaml @@ -84,7 +84,16 @@ scripts: // started returning a document would still be caught. const contentType = pm.response.headers.get('Content-Type') || ''; const isDocument = /^(application\/pdf|image\/|application\/octet-stream|text\/csv)/i.test(contentType); - const expected = pm.request.method === "POST" ? [200, 201, 202] : [200, 201, 202, 204]; + + // A request whose documented answer is not 2xx (Update Order Activity on an order + // whose flow is already complete must answer 400) opts out of the 2xx expectation + // by setting `expected_status` in its own beforeRequest script. The variable is + // consumed here, so it never leaks into the next request. + 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]); if (isDocument) { // Still asserted, not excused: a document response must carry actual bytes. diff --git a/postman/collections/Fleetbase API/Orders/Get Order Next Activity.request.yaml b/postman/collections/Fleetbase API/Orders/Get Order Next Activity.request.yaml index 892da0b..91545b7 100644 --- a/postman/collections/Fleetbase API/Orders/Get Order Next Activity.request.yaml +++ b/postman/collections/Fleetbase API/Orders/Get Order Next Activity.request.yaml @@ -13,16 +13,6 @@ body: type: json content: "" scripts: - - type: beforeRequest - code: |- - // A contract run cycles this request with Update Order Activity more times than an - // order can need, since how many activities a flow takes is not known up front. Once - // the flow is exhausted there is nothing left to look up, so the surplus passes are - // skipped rather than sent: a skipped request is neither a pass nor a failure. - if (pm.environment.get('order_flow_exhausted')) { - pm.execution.skipRequest(); - } - language: text/javascript - type: afterResponse code: |- // The response is the list of activities available from the order's current point in @@ -34,10 +24,14 @@ scripts: pm.environment.set("next_activity", JSON.stringify(json_response[0])); } else { // An empty list means the order has reached the end of its flow: applying the - // last activity completed it. Update Order Activity would now answer 400 - // "Order is already completed.", so the cycle stops here. + // last activity completed it. A contract run cycles this request with Update + // Order Activity more times than an order can need, since how many activities + // a flow takes is not known up front; from here on Update Order Activity + // expects the 400 "Order is already completed." refusal. (A skipped request — + // pm.execution.skipRequest — is counted as an error by the Postman CLI, so the + // surplus passes are sent and asserted rather than skipped.) The last activity + // is kept so the body stays valid JSON. pm.environment.set("order_flow_exhausted", "true"); - pm.environment.unset("next_activity"); } language: text/javascript examples: ./.resources/Get Order Next Activity.resources/examples diff --git a/postman/collections/Fleetbase API/Orders/Update Order Activity.request.yaml b/postman/collections/Fleetbase API/Orders/Update Order Activity.request.yaml index 997d017..fdd8853 100644 --- a/postman/collections/Fleetbase API/Orders/Update Order Activity.request.yaml +++ b/postman/collections/Fleetbase API/Orders/Update Order Activity.request.yaml @@ -17,11 +17,11 @@ body: scripts: - type: beforeRequest code: |- - // Nothing to apply once Get Order Next Activity found the flow exhausted: the body - // would not be JSON, and the API refuses a completed order with 400 "Order is - // already completed." Skipped, not failed — see Get Order Next Activity. - if (pm.environment.get('order_flow_exhausted') || !pm.environment.get('next_activity')) { - pm.execution.skipRequest(); + // Once Get Order Next Activity found the flow exhausted, the order is complete and + // the API refuses further activity with 400 "Order is already completed." — the + // documented answer, so the surplus passes of the contract run's cycle assert it. + if (pm.environment.get('order_flow_exhausted')) { + pm.variables.set('expected_status', 400); } language: text/javascript - type: afterResponse