Skip to content

Commit 1dba5fc

Browse files
committed
chore: add e2e tests for inputs
1 parent c6983ef commit 1dba5fc

9 files changed

+390
-0
lines changed

.changeset/brave-moments-mix.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 handling of input parameters when invoking step target workflows in Respect.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2+
3+
exports[`should pass inputs to step target workflow with additional input parameter from parent step and remapped, custom_price is expected to be undefined 1`] = `
4+
"────────────────────────────────────────────────────────────────────────────────
5+
6+
Running workflow inputs-passed-to-step-target-workflow-and-remapped.arazzo.yaml / inputs-passed-to-step-target-workflow
7+
8+
Running child workflow for the step health-workflow
9+
Running workflow events.arazzo.yaml / events-crud
10+
11+
✗ POST /special-events - step create-event
12+
13+
    Request URL: https://redocly.com/_mock/demo/openapi/museum-api/special-events
14+
    Request Headers:
15+
      content-type: application/json
16+
      accept: application/json, application/problem+json
17+
      authorization: ********
18+
      multi-word-secret: composed ********
19+
      custom_price: undefined
20+
    Request Body:
21+
      {
22+
       "PROJECT_CLIENT_ID": "0000001",
23+
       "PROJECT_CLIENT_SECRET": "PROJECT_CLIENT_SECRET",
24+
       "PROJECT_SUBSCRIPTION_KEY": "PROJECT_SUBSCRIPTION_KEY",
25+
       "name": "Mermaid Treasure Identification and Analysis",
26+
       "location": "Under the seaaa 🦀 🎶 🌊.",
27+
       "eventDescription": "Join us as we review and classify a rare collection of 20 thingamabobs, gadgets, gizmos, whoosits, and whatsits, kindly donated by Ariel.",
28+
       "dates": [
29+
       "2023-09-05",
30+
       "2023-09-08"
31+
       ]
32+
      }
33+
34+
35+
    Response status code: 400
36+
    Response time: <test> ms
37+
    Response Headers: <response headers test>
38+
    Response Body:
39+
      {
40+
       "type": "object",
41+
       "title": "Error validating body. data must have required property 'price'"
42+
      }
43+
44+
    ✗ success criteria check - $statusCode == 201
45+
    ✗ success criteria check - $.name == 'Mermaid Treasure Identification and Ana...
46+
    ✓ status code check - $statusCode in [201, 400, 404]
47+
    ✓ content-type check
48+
    ✓ schema check
49+
50+
51+
52+
  Failed tests info:
53+
54+
  Workflow name: inputs-passed-to-step-target-workflow
55+
56+
    stepId - create-event
57+
    ✗ success criteria check
58+
      Checking simple criteria: {"condition":"$statusCode == 201"}
59+
      
60+
    ✗ success criteria check
61+
      Checking jsonpath criteria: $.name == 'Mermaid Treasure Identification and Analysis'
62+
      
63+
  Summary for inputs-passed-to-step-target-workflow-and-remapped.arazzo.yaml
64+
  
65+
  Workflows: 1 failed, 1 total
66+
  Steps: 1 failed, 1 total
67+
  Checks: 3 passed, 2 failed, 5 total
68+
  Time: <test>ms
69+
70+
71+
┌────────────────────────────────────────────────────────────────────────────────────────────────────────┬────────────┬─────────┬─────────┬──────────┐
72+
│ Filename │ Workflows │ Passed │ Failed │ Warnings │
73+
├────────────────────────────────────────────────────────────────────────────────────────────────────────┼────────────┼─────────┼─────────┼──────────┤
74+
│ x inputs-passed-to-step-target-workflow-and-remapped.arazzo.yaml │ 1 │ 0 │ 1 │ - │
75+
└────────────────────────────────────────────────────────────────────────────────────────────────────────┴────────────┴─────────┴─────────┴──────────┘
76+
77+
78+
Tests exited with error
79+
80+
"
81+
`;
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
arazzo: 1.0.1
2+
info:
3+
title: Apply inputs from parent step to steps in target workflow
4+
description: >-
5+
Testing functionality of applying inputs from parent step to steps in target workflow
6+
version: 1.0.0
7+
8+
sourceDescriptions:
9+
- name: museum-api
10+
type: openapi
11+
url: ../museum-api.yaml
12+
13+
workflows:
14+
- workflowId: events-crud
15+
description: >-
16+
This workflow demonstrates how to list, create, update, and delete special events at the museum.
17+
parameters:
18+
- in: header
19+
name: Authorization
20+
value: $inputs.env.AUTH_TOKEN
21+
- in: header
22+
name: multi-word-secret
23+
value: composed {$inputs.env.AUTH_TOKEN}
24+
- in: header
25+
name: custom_price
26+
value: $inputs.custom_price
27+
inputs:
28+
type: object
29+
properties:
30+
PROJECT_CLIENT_ID:
31+
type: string
32+
PROJECT_CLIENT_SECRET:
33+
type: string
34+
PROJECT_SUBSCRIPTION_KEY:
35+
type: string
36+
env:
37+
type: object
38+
properties:
39+
AUTH_TOKEN:
40+
type: string
41+
format: password
42+
steps:
43+
- stepId: create-event
44+
description: >-
45+
Create a new special event.
46+
operationPath: '{$sourceDescriptions.museum-api.url}#/paths/~1special-events/post'
47+
requestBody:
48+
payload:
49+
PROJECT_CLIENT_ID: $inputs.PROJECT_CLIENT_ID
50+
PROJECT_CLIENT_SECRET: $inputs.PROJECT_CLIENT_SECRET
51+
PROJECT_SUBSCRIPTION_KEY: $inputs.PROJECT_SUBSCRIPTION_KEY
52+
name: 'Mermaid Treasure Identification and Analysis'
53+
location: 'Under the seaaa 🦀 🎶 🌊.'
54+
eventDescription: 'Join us as we review and classify a rare collection of 20 thingamabobs, gadgets, gizmos, whoosits, and whatsits, kindly donated by Ariel.'
55+
dates:
56+
- '2023-09-05'
57+
- '2023-09-08'
58+
price: $inputs.custom_price
59+
successCriteria:
60+
- condition: $statusCode == 201
61+
- context: $response.body
62+
condition: $.name == 'Mermaid Treasure Identification and Analysis'
63+
type: jsonpath
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
arazzo: 1.0.1
2+
info:
3+
title: Test inputs passed to step target workflow
4+
version: 1.0.0
5+
sourceDescriptions:
6+
- name: events
7+
url: ./events.arazzo.yaml
8+
type: arazzo
9+
workflows:
10+
- workflowId: inputs-passed-to-step-target-workflow
11+
summary: PEARL Merchandising API - Health Check for PRD
12+
inputs:
13+
type: object
14+
properties:
15+
PROJECT_CLIENT_ID:
16+
type: string
17+
PROJECT_CLIENT_SECRET:
18+
type: string
19+
PROJECT_SUBSCRIPTION_KEY:
20+
type: string
21+
steps:
22+
- stepId: health-workflow
23+
workflowId: $sourceDescriptions.events.workflows.events-crud
24+
parameters:
25+
- name: custom_price
26+
value: 800
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { dirname, join } from 'node:path';
2+
import { fileURLToPath } from 'node:url';
3+
import { getCommandOutput, getParams } from '../../helpers.js';
4+
5+
const __dirname = dirname(fileURLToPath(import.meta.url));
6+
7+
test('should pass inputs to step target workflow with additional input parameter from parent step and remapped, custom_price is expected to be undefined', () => {
8+
process.env.AUTH_TOKEN = 'Basic Og==';
9+
10+
const indexEntryPoint = join(process.cwd(), 'packages/cli/lib/index.js');
11+
const fixturesPath = join(
12+
__dirname,
13+
'inputs-passed-to-step-target-workflow-and-remapped.arazzo.yaml'
14+
);
15+
const args = getParams(indexEntryPoint, [
16+
'respect',
17+
fixturesPath,
18+
'--verbose',
19+
'--input',
20+
'{"PROJECT_CLIENT_ID":"0000001","PROJECT_CLIENT_SECRET":"PROJECT_CLIENT_SECRET","PROJECT_SUBSCRIPTION_KEY":"PROJECT_SUBSCRIPTION_KEY"}',
21+
]);
22+
23+
const result = getCommandOutput(args);
24+
expect(result).toMatchSnapshot();
25+
26+
delete process.env.AUTH_TOKEN;
27+
}, 60_000);
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2+
3+
exports[`should pass inputs to step target workflow with additional input parameter from parent step 1`] = `
4+
"────────────────────────────────────────────────────────────────────────────────
5+
6+
Running workflow inputs-passed-to-step-target-workflow.arazzo.yaml / inputs-passed-to-step-target-workflow
7+
8+
Running child workflow for the step health-workflow
9+
Running workflow events.arazzo.yaml / events-crud
10+
11+
✓ POST /special-events - step create-event
12+
13+
    Request URL: https://redocly.com/_mock/demo/openapi/museum-api/special-events
14+
    Request Headers:
15+
      content-type: application/json
16+
      accept: application/json, application/problem+json
17+
      authorization: ********
18+
      multi-word-secret: composed ********
19+
    Request Body:
20+
      {
21+
       "PROJECT_CLIENT_ID": "0000001",
22+
       "PROJECT_CLIENT_SECRET": "PROJECT_CLIENT_SECRET",
23+
       "PROJECT_SUBSCRIPTION_KEY": "PROJECT_SUBSCRIPTION_KEY",
24+
       "name": "Mermaid Treasure Identification and Analysis",
25+
       "location": "Under the seaaa 🦀 🎶 🌊.",
26+
       "eventDescription": "Join us as we review and classify a rare collection of 20 thingamabobs, gadgets, gizmos, whoosits, and whatsits, kindly donated by Ariel.",
27+
       "dates": [
28+
       "2023-09-05",
29+
       "2023-09-08"
30+
       ],
31+
       "price": 800
32+
      }
33+
34+
35+
    Response status code: 201
36+
    Response time: <test> ms
37+
    Response Headers: <response headers test>
38+
    Response Body:
39+
      {
40+
       "eventId": "dad4bce8-f5cb-4078-a211-995864315e39",
41+
       "name": "Mermaid Treasure Identification and Analysis",
42+
       "location": "Under the seaaa 🦀 🎶 🌊.",
43+
       "eventDescription": "Join us as we review and classify a rare collection of 20 thingamabobs, gadgets, gizmos, whoosits, and whatsits, kindly donated by Ariel.",
44+
       "dates": [
45+
       "2023-09-05",
46+
       "2023-09-08"
47+
       ],
48+
       "price": 800
49+
      }
50+
51+
    ✓ success criteria check - $statusCode == 201
52+
    ✓ success criteria check - $.name == 'Mermaid Treasure Identification and Ana...
53+
    ✓ status code check - $statusCode in [201, 400, 404]
54+
    ✓ content-type check
55+
    ✓ schema check
56+
57+
58+
59+
  Summary for inputs-passed-to-step-target-workflow.arazzo.yaml
60+
  
61+
  Workflows: 1 passed, 1 total
62+
  Steps: 1 passed, 1 total
63+
  Checks: 5 passed, 5 total
64+
  Time: <test>ms
65+
66+
67+
┌───────────────────────────────────────────────────────────────────────────────────────────┬────────────┬─────────┬─────────┬──────────┐
68+
│ Filename │ Workflows │ Passed │ Failed │ Warnings │
69+
├───────────────────────────────────────────────────────────────────────────────────────────┼────────────┼─────────┼─────────┼──────────┤
70+
│ ✓ inputs-passed-to-step-target-workflow.arazzo.yaml │ 1 │ 1 │ - │ - │
71+
└───────────────────────────────────────────────────────────────────────────────────────────┴────────────┴─────────┴─────────┴──────────┘
72+
73+
74+
"
75+
`;
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
arazzo: 1.0.1
2+
info:
3+
title: Apply inputs from parent step to steps in target workflow
4+
description: >-
5+
Testing functionality of applying inputs from parent step to steps in target workflow
6+
version: 1.0.0
7+
8+
sourceDescriptions:
9+
- name: museum-api
10+
type: openapi
11+
url: ../museum-api.yaml
12+
13+
workflows:
14+
- workflowId: events-crud
15+
description: >-
16+
This workflow demonstrates how to list, create, update, and delete special events at the museum.
17+
parameters:
18+
- in: header
19+
name: Authorization
20+
value: $inputs.env.AUTH_TOKEN
21+
- in: header
22+
name: multi-word-secret
23+
value: composed {$inputs.env.AUTH_TOKEN}
24+
inputs:
25+
type: object
26+
properties:
27+
PROJECT_CLIENT_ID:
28+
type: string
29+
PROJECT_CLIENT_SECRET:
30+
type: string
31+
PROJECT_SUBSCRIPTION_KEY:
32+
type: string
33+
custom_price:
34+
type: number
35+
env:
36+
type: object
37+
properties:
38+
AUTH_TOKEN:
39+
type: string
40+
format: password
41+
steps:
42+
- stepId: create-event
43+
description: >-
44+
Create a new special event.
45+
operationPath: '{$sourceDescriptions.museum-api.url}#/paths/~1special-events/post'
46+
requestBody:
47+
payload:
48+
PROJECT_CLIENT_ID: $inputs.PROJECT_CLIENT_ID
49+
PROJECT_CLIENT_SECRET: $inputs.PROJECT_CLIENT_SECRET
50+
PROJECT_SUBSCRIPTION_KEY: $inputs.PROJECT_SUBSCRIPTION_KEY
51+
name: 'Mermaid Treasure Identification and Analysis'
52+
location: 'Under the seaaa 🦀 🎶 🌊.'
53+
eventDescription: 'Join us as we review and classify a rare collection of 20 thingamabobs, gadgets, gizmos, whoosits, and whatsits, kindly donated by Ariel.'
54+
dates:
55+
- '2023-09-05'
56+
- '2023-09-08'
57+
price: $inputs.custom_price
58+
successCriteria:
59+
- condition: $statusCode == 201
60+
- context: $response.body
61+
condition: $.name == 'Mermaid Treasure Identification and Analysis'
62+
type: jsonpath
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
arazzo: 1.0.1
2+
info:
3+
title: Test inputs passed to step target workflow
4+
version: 1.0.0
5+
sourceDescriptions:
6+
- name: events
7+
url: ./events.arazzo.yaml
8+
type: arazzo
9+
workflows:
10+
- workflowId: inputs-passed-to-step-target-workflow
11+
summary: PEARL Merchandising API - Health Check for PRD
12+
inputs:
13+
type: object
14+
properties:
15+
PROJECT_CLIENT_ID:
16+
type: string
17+
PROJECT_CLIENT_SECRET:
18+
type: string
19+
PROJECT_SUBSCRIPTION_KEY:
20+
type: string
21+
steps:
22+
- stepId: health-workflow
23+
workflowId: $sourceDescriptions.events.workflows.events-crud
24+
parameters:
25+
- name: custom_price
26+
value: 800
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { dirname, join } from 'node:path';
2+
import { fileURLToPath } from 'node:url';
3+
import { getCommandOutput, getParams } from '../../helpers.js';
4+
5+
const __dirname = dirname(fileURLToPath(import.meta.url));
6+
7+
test('should pass inputs to step target workflow with additional input parameter from parent step', () => {
8+
process.env.AUTH_TOKEN = 'Basic Og==';
9+
10+
const indexEntryPoint = join(process.cwd(), 'packages/cli/lib/index.js');
11+
const fixturesPath = join(__dirname, 'inputs-passed-to-step-target-workflow.arazzo.yaml');
12+
const args = getParams(indexEntryPoint, [
13+
'respect',
14+
fixturesPath,
15+
'--verbose',
16+
'--input',
17+
'{"PROJECT_CLIENT_ID":"0000001","PROJECT_CLIENT_SECRET":"PROJECT_CLIENT_SECRET","PROJECT_SUBSCRIPTION_KEY":"PROJECT_SUBSCRIPTION_KEY"}',
18+
]);
19+
20+
const result = getCommandOutput(args);
21+
expect(result).toMatchSnapshot();
22+
23+
delete process.env.AUTH_TOKEN;
24+
}, 60_000);

0 commit comments

Comments
 (0)