Skip to content

Commit

Permalink
Merge branch 'release/4.3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
codenirvana committed Nov 18, 2023
2 parents ee2cc8d + 1d6e0dd commit d332e0c
Show file tree
Hide file tree
Showing 8 changed files with 518 additions and 98 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
4.3.0:
date: 2023-11-18
new features:
- GH-1339 Added `getPath` method on Item
chores:
- Updated dependencies

4.2.1:
date: 2023-09-11
fixed bugs:
Expand Down
189 changes: 189 additions & 0 deletions examples/nested-v2-collection-without-name.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
{
"variables": [],
"info": {
"_postman_id": "e5f2e9cf-173b-c60a-7336-ac804a87d762",
"description": "A simple V2 collection to test out multi level folder flows",
"schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json"
},
"item": [
{
"id": "F1-id",
"description": "",
"item": [
{
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"tests[\"Status code is 200\"] = responseCode.code === 200;",
"tests[\"Request executed in correct order\"] = postman.getEnvironmentVariable(\"count\") === 0;"
]
}
}
],
"request": {
"url": "https://postman-echo.com/get",
"method": "GET",
"header": [],
"body": {},
"description": ""
},
"response": [],
"id": "F1.R1-id"
},
{
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"tests[\"Status code is 200\"] = responseCode.code === 200;",
"tests[\"Request executed in correct order\"] = postman.getEnvironmentVariable(\"count\") === \"1\";"
]
}
}
],
"request": {
"url": "https://postman-echo.com/get",
"method": "GET",
"header": [],
"body": {},
"description": ""
},
"response": [],
"id": "F1.R2-id"
},
{
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"tests[\"Status code is 200\"] = responseCode.code === 200;",
"tests[\"Request executed in correct order\"] = postman.getEnvironmentVariable(\"count\") === \"2\";"
]
}
}
],
"request": {
"url": "https://postman-echo.com/get",
"method": "GET",
"header": [],
"body": {},
"description": ""
},
"response": [],
"id": "F1.R3-id"
}
]
},
{
"id": "F2-id",
"description": "",
"item": [
{
"id": "F2.F3-id",
"description": "",
"item": [
{
"id": "F2.F3.R1-id",
"event": [
{
"listen": "prerequest",
"script": {
"type": "text/javascript",
"exec": [
"var count = parseInt(postman.getEnvironmentVariable(\"count\"));",
"postman.setEnvironmentVariable(\"count\", isNaN(count) ? 0 : count + 1);"
]
}
},
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"tests[\"Status code is 200\"] = responseCode.code === 200;",
"tests[\"Request executed in correct order\"] = postman.getEnvironmentVariable(\"count\") === \"3\";"
]
}
}
],
"request": {
"url": "https://postman-echo.com/get",
"method": "GET",
"header": [],
"body": {},
"description": ""
},
"response": []
}
]
},
{
"description": "",
"item": []
},
{
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"tests[\"Status code is 200\"] = responseCode.code === 200;",
"tests[\"Request executed in correct order\"] = postman.getEnvironmentVariable(\"count\") === \"4\";"
]
}
}
],
"request": {
"url": "https://postman-echo.com/get",
"method": "GET",
"header": [],
"body": {},
"description": ""
},
"response": []
}
]
},
{
"event": [
{
"listen": "prerequest",
"script": {
"type": "text/javascript",
"exec": [
"var count = parseInt(postman.getEnvironmentVariable(\"count\"));",
"postman.setEnvironmentVariable(\"count\", isNaN(count) ? 0 : count + 1);"
]
}
},
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"tests[\"Status code is 200\"] = responseCode.code === 200;",
"tests[\"Request executed in correct order\"] = postman.getEnvironmentVariable(\"count\") === \"5\";"
]
}
}
],
"request": {
"url": "https://postman-echo.com/get",
"method": "GET",
"header": [],
"body": {},
"description": ""
},
"response": [],
"id": "R1-id"
}
]
}
13 changes: 10 additions & 3 deletions examples/nested-v2-collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"item": [
{
"name": "F1",
"id": "F1-id",
"description": "",
"item": [
{
Expand All @@ -32,7 +33,8 @@
"body": {},
"description": ""
},
"response": []
"response": [],
"id": "F1.R1-id"
},
{
"name": "F1.R2",
Expand All @@ -56,7 +58,8 @@
"body": {},
"description": ""
},
"response": []
"response": [],
"id": "F1.R2-id"
},
{
"name": "F1.R3",
Expand Down Expand Up @@ -85,14 +88,17 @@
},
{
"name": "F2",
"id": "F2-id",
"description": "",
"item": [
{
"name": "F2.F3",
"id": "F2.F3-id",
"description": "",
"item": [
{
"name": "F2.F3.R1",
"id": "F2.F3.R1-id",
"event": [
{
"listen": "prerequest",
Expand Down Expand Up @@ -187,7 +193,8 @@
"body": {},
"description": ""
},
"response": []
"response": [],
"id": "R1-id"
}
]
}
15 changes: 15 additions & 0 deletions lib/collection/item.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,21 @@ _.assign(Item.prototype, /** @lends Item.prototype */ {
if (!this.request) { this.request = new Request(); } // worst case

return this.request.authorizeUsing(type, options);
},

/**
* Returns the path of the item
*
* @returns {Array<string>}
*/
getPath: function () {
const path = [],
pushItem = (item) => { path.push(item.name); };

pushItem(this);
this.forEachParent({ withRoot: true }, pushItem);

return path.reverse();
}
});

Expand Down
Loading

0 comments on commit d332e0c

Please sign in to comment.