Skip to content

Commit ee19d06

Browse files
committed
fix(respect-core): consider severity in the next step execution when onFailure is ommited
1 parent 006c0ec commit ee19d06

File tree

7 files changed

+402
-19
lines changed

7 files changed

+402
-19
lines changed

.changeset/fast-islands-sell.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@redocly/respect-core": patch
3+
"@redocly/cli": patch
4+
---
5+
6+
Fixed step execution to respect severity levels when handling step failures. Previously, steps would always break workflow execution on failure when onFailure is ommited, but now they properly consider the configured severity level (e.g., `warn` | `off` severity allows subsequent steps to execute).
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,313 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`should not follow the default behavior to break and return if onFailure omitted with warn severity and continue execution of the next step 1`] = `
4+
"────────────────────────────────────────────────────────────────────────────────
5+
6+
Running workflow consider-severity-in-next-step-execution.arazzo.yaml / first-workflow
7+
8+
✓ GET /museum-hours - step first-step
9+
10+
    Request URL: https://redocly.com/_mock/demo/openapi/museum-api/museum-hours
11+
    Request Headers:
12+
      accept: application/json, application/problem+json
13+
      authorization: Basic Og==
14+
15+
16+
    Response status code: 200
17+
    Response time: <test> ms
18+
    Response Body:
19+
      [
20+
       {
21+
       "date": "2023-09-11",
22+
       "timeOpen": "09:00",
23+
       "timeClose": "18:00"
24+
       },
25+
       {
26+
       "date": "2023-09-12",
27+
       "timeOpen": "09:00",
28+
       "timeClose": "18:00"
29+
       },
30+
       {
31+
       "date": "2023-09-13",
32+
       "timeOpen": "09:00",
33+
       "timeClose": "18:00"
34+
       },
35+
       {
36+
       "date": "2023-09-14",
37+
       "timeOpen": "09:00",
38+
       "timeClose": "18:00"
39+
       },
40+
       {
41+
       "date": "2023-09-15",
42+
       "timeOpen": "10:00",
43+
       "timeClose": "16:00"
44+
       },
45+
       {
46+
       "date": "2023-09-18",
47+
       "timeOpen": "09:00",
48+
       "timeClose": "18:00"
49+
       },
50+
       {
51+
       "date": "2023-09-19",
52+
       "timeOpen": "09:00",
53+
       "timeClose": "18:00"
54+
       },
55+
       {
56+
       "date": "2023-09-20",
57+
       "timeOpen": "09:00",
58+
       "timeClose": "18:00"
59+
       },
60+
       {
61+
       "date": "2023-09-21",
62+
       "timeOpen": "09:00",
63+
       "timeClose": "18:00"
64+
       },
65+
       {
66+
       "date": "2023-09-22",
67+
       "timeOpen": "10:00",
68+
       "timeClose": "16:00"
69+
       }
70+
      ]
71+
72+
    ✓ success criteria check - $statusCode == 200
73+
    ✓ status code check - $statusCode in [200, 400, 404]
74+
    ✓ content-type check
75+
    ✓ schema check
76+
77+
────────────────────────────────────────────────────────────────────────────────
78+
79+
Running workflow consider-severity-in-next-step-execution.arazzo.yaml / second-workflow
80+
81+
✗ GET /special-events - step list-events
82+
83+
    Request URL: https://redocly.com/_mock/demo/openapi/museum-api/special-events
84+
    Request Headers:
85+
      accept: application/json, application/problem+json
86+
      authorization: Basic Og==
87+
88+
89+
    Response status code: 200
90+
    Response time: <test> ms
91+
    Response Body:
92+
      [
93+
       {
94+
       "eventId": "f3e0e76e-e4a8-466e-ab9c-ae36c15b8e97",
95+
       "name": "Sasquatch Ballet",
96+
       "location": "Seattle... probably",
97+
       "eventDescription": "They're big, they're hairy, but they're also graceful. Come learn how the biggest feet can have the lightest touch.",
98+
       "dates": [
99+
       "2023-12-15",
100+
       "2023-12-22"
101+
       ],
102+
       "price": 40
103+
       },
104+
       {
105+
       "eventId": "2f14374a-9c65-4ee5-94b7-fba66d893483",
106+
       "name": "Solar Telescope Demonstration",
107+
       "location": "Far from the sun.",
108+
       "eventDescription": "Look at the sun without going blind!",
109+
       "dates": [
110+
       "2023-09-07",
111+
       "2023-09-14"
112+
       ],
113+
       "price": 50
114+
       },
115+
       {
116+
       "eventId": "6aaa61ba-b2aa-4868-b803-603dbbf7bfdb",
117+
       "name": "Cook like a Caveman",
118+
       "location": "Fire Pit on East side",
119+
       "eventDescription": "Learn to cook on an open flame.",
120+
       "dates": [
121+
       "2023-11-10",
122+
       "2023-11-17",
123+
       "2023-11-24"
124+
       ],
125+
       "price": 5
126+
       },
127+
       {
128+
       "eventId": "602b75e1-5696-4ab8-8c7a-f9e13580f910",
129+
       "name": "Underwater Basket Weaving",
130+
       "location": "Rec Center Pool next door.",
131+
       "eventDescription": "Learn to weave baskets underwater.",
132+
       "dates": [
133+
       "2023-09-12",
134+
       "2023-09-15"
135+
       ],
136+
       "price": 15
137+
       },
138+
       {
139+
       "eventId": "dad4bce8-f5cb-4078-a211-995864315e39",
140+
       "name": "Mermaid Treasure Identification and Analysis",
141+
       "location": "Room Sea-12",
142+
       "eventDescription": "Join us as we review and classify a rare collection of 20 thingamabobs, gadgets, gizmos, whoosits, and whatsits — kindly donated by Ariel.",
143+
       "dates": [
144+
       "2023-09-05",
145+
       "2023-09-08"
146+
       ],
147+
       "price": 30
148+
       },
149+
       {
150+
       "eventId": "6744a0da-4121-49cd-8479-f8cc20526495",
151+
       "name": "Time Traveler Tea Party",
152+
       "location": "Temporal Tearoom",
153+
       "eventDescription": "Sip tea with important historical figures.",
154+
       "dates": [
155+
       "2023-11-18",
156+
       "2023-11-25",
157+
       "2023-12-02"
158+
       ],
159+
       "price": 60
160+
       },
161+
       {
162+
       "eventId": "3be6453c-03eb-4357-ae5a-984a0e574a54",
163+
       "name": "Pirate Coding Workshop",
164+
       "location": "Computer Room",
165+
       "eventDescription": "Captain Blackbeard shares his love of the C...language. And possibly Arrrrr (R lang).",
166+
       "dates": [
167+
       "2023-10-29",
168+
       "2023-10-30",
169+
       "2023-10-31"
170+
       ],
171+
       "price": 45
172+
       },
173+
       {
174+
       "eventId": "9d90d29a-2af5-4206-97d9-9ea9ceadcb78",
175+
       "name": "Llama Street Art Through the Ages",
176+
       "location": "Auditorium",
177+
       "eventDescription": "Llama street art?! Alpaca my bags -- let's go!",
178+
       "dates": [
179+
       "2023-10-29",
180+
       "2023-10-30",
181+
       "2023-10-31"
182+
       ],
183+
       "price": 45
184+
       },
185+
       {
186+
       "eventId": "a3c7b2c4-b5fb-4ef7-9322-00a919864957",
187+
       "name": "The Great Parrot Debate",
188+
       "location": "Outdoor Amphitheatre",
189+
       "eventDescription": "See leading parrot minds discuss important geopolitical issues.",
190+
       "dates": [
191+
       "2023-11-03",
192+
       "2023-11-10"
193+
       ],
194+
       "price": 35
195+
       },
196+
       {
197+
       "eventId": "b92d46b7-4c5d-422b-87a5-287767e26f29",
198+
       "name": "Eat a Bunch of Corn",
199+
       "location": "Cafeteria",
200+
       "eventDescription": "We accidentally bought too much corn. Please come eat it.",
201+
       "dates": [
202+
       "2023-11-10",
203+
       "2023-11-17",
204+
       "2023-11-24"
205+
       ],
206+
       "price": 5
207+
       }
208+
      ]
209+
210+
    ⚠ success criteria check - $statusCode == 201
211+
    ✓ status code check - $statusCode in [200, 400, 404]
212+
    ✓ content-type check
213+
    ✓ schema check
214+
215+
Running child workflow for the step call-first-workflow
216+
Running workflow consider-severity-in-next-step-execution.arazzo.yaml / first-workflow
217+
218+
✓ GET /museum-hours - step first-step
219+
220+
    Request URL: https://redocly.com/_mock/demo/openapi/museum-api/museum-hours
221+
    Request Headers:
222+
      accept: application/json, application/problem+json
223+
      authorization: Basic Og==
224+
225+
226+
    Response status code: 200
227+
    Response time: <test> ms
228+
    Response Body:
229+
      [
230+
       {
231+
       "date": "2023-09-11",
232+
       "timeOpen": "09:00",
233+
       "timeClose": "18:00"
234+
       },
235+
       {
236+
       "date": "2023-09-12",
237+
       "timeOpen": "09:00",
238+
       "timeClose": "18:00"
239+
       },
240+
       {
241+
       "date": "2023-09-13",
242+
       "timeOpen": "09:00",
243+
       "timeClose": "18:00"
244+
       },
245+
       {
246+
       "date": "2023-09-14",
247+
       "timeOpen": "09:00",
248+
       "timeClose": "18:00"
249+
       },
250+
       {
251+
       "date": "2023-09-15",
252+
       "timeOpen": "10:00",
253+
       "timeClose": "16:00"
254+
       },
255+
       {
256+
       "date": "2023-09-18",
257+
       "timeOpen": "09:00",
258+
       "timeClose": "18:00"
259+
       },
260+
       {
261+
       "date": "2023-09-19",
262+
       "timeOpen": "09:00",
263+
       "timeClose": "18:00"
264+
       },
265+
       {
266+
       "date": "2023-09-20",
267+
       "timeOpen": "09:00",
268+
       "timeClose": "18:00"
269+
       },
270+
       {
271+
       "date": "2023-09-21",
272+
       "timeOpen": "09:00",
273+
       "timeClose": "18:00"
274+
       },
275+
       {
276+
       "date": "2023-09-22",
277+
       "timeOpen": "10:00",
278+
       "timeClose": "16:00"
279+
       }
280+
      ]
281+
282+
    ✓ success criteria check - $statusCode == 200
283+
    ✓ status code check - $statusCode in [200, 400, 404]
284+
    ✓ content-type check
285+
    ✓ schema check
286+
287+
288+
289+
  Failed tests info:
290+
291+
  Workflow name: second-workflow
292+
293+
    stepId - list-events
294+
    ⚠ success criteria check
295+
      Checking simple criteria: {"condition":"$statusCode == 201"}
296+
      
297+
  Summary for consider-severity-in-next-step-execution.arazzo.yaml
298+
  
299+
  Workflows: 2 passed, 2 total
300+
  Steps: 3 passed, 1 warnings, 3 total
301+
  Checks: 12 passed, 1 warnings, 12 total
302+
  Time: <test>ms
303+
304+
305+
┌──────────────────────────────────────────────────────────────────────────────────────────────┬────────────┬─────────┬─────────┬──────────┐
306+
│ Filename │ Workflows │ Passed │ Failed │ Warnings │
307+
├──────────────────────────────────────────────────────────────────────────────────────────────┼────────────┼─────────┼─────────┼──────────┤
308+
│ ✓ consider-severity-in-next-step-execution.arazzo.yaml │ 2 │ 2 │ - │ 1 │
309+
└──────────────────────────────────────────────────────────────────────────────────────────────┴────────────┴─────────┴─────────┴──────────┘
310+
311+
312+
"
313+
`;
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
arazzo: 1.0.1
2+
info:
3+
title: Redocly Museum API
4+
version: 1.0.0
5+
6+
sourceDescriptions:
7+
- name: museum-api
8+
type: openapi
9+
url: ../museum-api.yaml
10+
11+
workflows:
12+
- workflowId: first-workflow
13+
parameters:
14+
- in: header
15+
name: Authorization
16+
value: Basic Og==
17+
steps:
18+
- stepId: first-step
19+
operationId: museum-api.getMuseumHours
20+
successCriteria:
21+
- condition: $statusCode == 200
22+
- workflowId: second-workflow
23+
description: >-
24+
This workflow demonstrates how to list, create, update, and delete special events at the museum.
25+
parameters:
26+
- in: header
27+
name: Authorization
28+
value: Basic Og==
29+
steps:
30+
- stepId: list-events
31+
operationPath: '{$sourceDescriptions.museum-api.url}#/paths/~1special-events/get'
32+
successCriteria:
33+
# Make this check fail
34+
- condition: $statusCode == 201
35+
# should not follow the default behavior to break and return if onFailure omitted with warn severity and continue execution of the next step
36+
- stepId: call-first-workflow
37+
workflowId: first-workflow
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { getParams, getCommandOutput } from '../utils';
2+
import { join } from 'path';
3+
4+
test('should not follow the default behavior to break and return if onFailure omitted with warn severity and continue execution of the next step', () => {
5+
const indexEntryPoint = join(process.cwd(), 'packages/cli/lib/index.js');
6+
const fixturesPath = join(__dirname, 'consider-severity-in-next-step-execution.arazzo.yaml');
7+
const args = getParams(indexEntryPoint, [
8+
'respect',
9+
fixturesPath,
10+
'--verbose',
11+
'--severity',
12+
'STATUS_CODE_CHECK=off',
13+
'--severity',
14+
'SCHEMA_CHECK=warn',
15+
'--severity',
16+
'SUCCESS_CRITERIA_CHECK=warn',
17+
'--severity',
18+
'CONTENT_TYPE_CHECK=off',
19+
]);
20+
21+
const result = getCommandOutput(args);
22+
expect(result).toMatchSnapshot();
23+
});

packages/respect-core/src/modules/__tests__/flow-runner/call-api-and-analyze-results.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ describe('callAPIAndAnalyzeResults', () => {
371371
},
372372
});
373373
expect(result).toEqual({
374-
expectCheck: true,
374+
schemaCheck: true,
375375
networkCheck: true,
376376
successCriteriaCheck: true,
377377
});

0 commit comments

Comments
 (0)