Skip to content

Commit d332e0c

Browse files
committed
Merge branch 'release/4.3.0'
2 parents ee2cc8d + 1d6e0dd commit d332e0c

File tree

8 files changed

+518
-98
lines changed

8 files changed

+518
-98
lines changed

CHANGELOG.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
4.3.0:
2+
date: 2023-11-18
3+
new features:
4+
- GH-1339 Added `getPath` method on Item
5+
chores:
6+
- Updated dependencies
7+
18
4.2.1:
29
date: 2023-09-11
310
fixed bugs:
Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
{
2+
"variables": [],
3+
"info": {
4+
"_postman_id": "e5f2e9cf-173b-c60a-7336-ac804a87d762",
5+
"description": "A simple V2 collection to test out multi level folder flows",
6+
"schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json"
7+
},
8+
"item": [
9+
{
10+
"id": "F1-id",
11+
"description": "",
12+
"item": [
13+
{
14+
"event": [
15+
{
16+
"listen": "test",
17+
"script": {
18+
"type": "text/javascript",
19+
"exec": [
20+
"tests[\"Status code is 200\"] = responseCode.code === 200;",
21+
"tests[\"Request executed in correct order\"] = postman.getEnvironmentVariable(\"count\") === 0;"
22+
]
23+
}
24+
}
25+
],
26+
"request": {
27+
"url": "https://postman-echo.com/get",
28+
"method": "GET",
29+
"header": [],
30+
"body": {},
31+
"description": ""
32+
},
33+
"response": [],
34+
"id": "F1.R1-id"
35+
},
36+
{
37+
"event": [
38+
{
39+
"listen": "test",
40+
"script": {
41+
"type": "text/javascript",
42+
"exec": [
43+
"tests[\"Status code is 200\"] = responseCode.code === 200;",
44+
"tests[\"Request executed in correct order\"] = postman.getEnvironmentVariable(\"count\") === \"1\";"
45+
]
46+
}
47+
}
48+
],
49+
"request": {
50+
"url": "https://postman-echo.com/get",
51+
"method": "GET",
52+
"header": [],
53+
"body": {},
54+
"description": ""
55+
},
56+
"response": [],
57+
"id": "F1.R2-id"
58+
},
59+
{
60+
"event": [
61+
{
62+
"listen": "test",
63+
"script": {
64+
"type": "text/javascript",
65+
"exec": [
66+
"tests[\"Status code is 200\"] = responseCode.code === 200;",
67+
"tests[\"Request executed in correct order\"] = postman.getEnvironmentVariable(\"count\") === \"2\";"
68+
]
69+
}
70+
}
71+
],
72+
"request": {
73+
"url": "https://postman-echo.com/get",
74+
"method": "GET",
75+
"header": [],
76+
"body": {},
77+
"description": ""
78+
},
79+
"response": [],
80+
"id": "F1.R3-id"
81+
}
82+
]
83+
},
84+
{
85+
"id": "F2-id",
86+
"description": "",
87+
"item": [
88+
{
89+
"id": "F2.F3-id",
90+
"description": "",
91+
"item": [
92+
{
93+
"id": "F2.F3.R1-id",
94+
"event": [
95+
{
96+
"listen": "prerequest",
97+
"script": {
98+
"type": "text/javascript",
99+
"exec": [
100+
"var count = parseInt(postman.getEnvironmentVariable(\"count\"));",
101+
"postman.setEnvironmentVariable(\"count\", isNaN(count) ? 0 : count + 1);"
102+
]
103+
}
104+
},
105+
{
106+
"listen": "test",
107+
"script": {
108+
"type": "text/javascript",
109+
"exec": [
110+
"tests[\"Status code is 200\"] = responseCode.code === 200;",
111+
"tests[\"Request executed in correct order\"] = postman.getEnvironmentVariable(\"count\") === \"3\";"
112+
]
113+
}
114+
}
115+
],
116+
"request": {
117+
"url": "https://postman-echo.com/get",
118+
"method": "GET",
119+
"header": [],
120+
"body": {},
121+
"description": ""
122+
},
123+
"response": []
124+
}
125+
]
126+
},
127+
{
128+
"description": "",
129+
"item": []
130+
},
131+
{
132+
"event": [
133+
{
134+
"listen": "test",
135+
"script": {
136+
"type": "text/javascript",
137+
"exec": [
138+
"tests[\"Status code is 200\"] = responseCode.code === 200;",
139+
"tests[\"Request executed in correct order\"] = postman.getEnvironmentVariable(\"count\") === \"4\";"
140+
]
141+
}
142+
}
143+
],
144+
"request": {
145+
"url": "https://postman-echo.com/get",
146+
"method": "GET",
147+
"header": [],
148+
"body": {},
149+
"description": ""
150+
},
151+
"response": []
152+
}
153+
]
154+
},
155+
{
156+
"event": [
157+
{
158+
"listen": "prerequest",
159+
"script": {
160+
"type": "text/javascript",
161+
"exec": [
162+
"var count = parseInt(postman.getEnvironmentVariable(\"count\"));",
163+
"postman.setEnvironmentVariable(\"count\", isNaN(count) ? 0 : count + 1);"
164+
]
165+
}
166+
},
167+
{
168+
"listen": "test",
169+
"script": {
170+
"type": "text/javascript",
171+
"exec": [
172+
"tests[\"Status code is 200\"] = responseCode.code === 200;",
173+
"tests[\"Request executed in correct order\"] = postman.getEnvironmentVariable(\"count\") === \"5\";"
174+
]
175+
}
176+
}
177+
],
178+
"request": {
179+
"url": "https://postman-echo.com/get",
180+
"method": "GET",
181+
"header": [],
182+
"body": {},
183+
"description": ""
184+
},
185+
"response": [],
186+
"id": "R1-id"
187+
}
188+
]
189+
}

examples/nested-v2-collection.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"item": [
1010
{
1111
"name": "F1",
12+
"id": "F1-id",
1213
"description": "",
1314
"item": [
1415
{
@@ -32,7 +33,8 @@
3233
"body": {},
3334
"description": ""
3435
},
35-
"response": []
36+
"response": [],
37+
"id": "F1.R1-id"
3638
},
3739
{
3840
"name": "F1.R2",
@@ -56,7 +58,8 @@
5658
"body": {},
5759
"description": ""
5860
},
59-
"response": []
61+
"response": [],
62+
"id": "F1.R2-id"
6063
},
6164
{
6265
"name": "F1.R3",
@@ -85,14 +88,17 @@
8588
},
8689
{
8790
"name": "F2",
91+
"id": "F2-id",
8892
"description": "",
8993
"item": [
9094
{
9195
"name": "F2.F3",
96+
"id": "F2.F3-id",
9297
"description": "",
9398
"item": [
9499
{
95100
"name": "F2.F3.R1",
101+
"id": "F2.F3.R1-id",
96102
"event": [
97103
{
98104
"listen": "prerequest",
@@ -187,7 +193,8 @@
187193
"body": {},
188194
"description": ""
189195
},
190-
"response": []
196+
"response": [],
197+
"id": "R1-id"
191198
}
192199
]
193200
}

lib/collection/item.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,21 @@ _.assign(Item.prototype, /** @lends Item.prototype */ {
329329
if (!this.request) { this.request = new Request(); } // worst case
330330

331331
return this.request.authorizeUsing(type, options);
332+
},
333+
334+
/**
335+
* Returns the path of the item
336+
*
337+
* @returns {Array<string>}
338+
*/
339+
getPath: function () {
340+
const path = [],
341+
pushItem = (item) => { path.push(item.name); };
342+
343+
pushItem(this);
344+
this.forEachParent({ withRoot: true }, pushItem);
345+
346+
return path.reverse();
332347
}
333348
});
334349

0 commit comments

Comments
 (0)