Chain v2 overview relation Postman test
This commit is contained in:
@@ -1063,6 +1063,37 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "get filtered ticket overview counts",
|
"name": "get filtered ticket overview counts",
|
||||||
|
"event": [
|
||||||
|
{
|
||||||
|
"listen": "test",
|
||||||
|
"script": {
|
||||||
|
"type": "text/javascript",
|
||||||
|
"exec": [
|
||||||
|
"const overviewCountsJson = pm.response.json();",
|
||||||
|
"const overviewCounts = overviewCountsJson.counts || overviewCountsJson.Counts || {};",
|
||||||
|
"const overviewPreferredKeys = (pm.collectionVariables.get(\"overviewKeys\") || \"\")",
|
||||||
|
" .split(\",\")",
|
||||||
|
" .map(key => key.trim())",
|
||||||
|
" .filter(Boolean);",
|
||||||
|
"const overviewRelationKey = overviewPreferredKeys.find(key => Number(overviewCounts[key] || 0) > 0)",
|
||||||
|
" || Object.keys(overviewCounts).find(key => Number(overviewCounts[key] || 0) > 0)",
|
||||||
|
" || \"\";",
|
||||||
|
"const overviewRelationCount = overviewRelationKey ? Number(overviewCounts[overviewRelationKey] || 0) : 0;",
|
||||||
|
"",
|
||||||
|
"if (overviewRelationKey && overviewRelationCount > 0) {",
|
||||||
|
" pm.collectionVariables.set(\"overviewKey\", overviewRelationKey);",
|
||||||
|
" pm.collectionVariables.set(\"overviewRelationExpectedCount\", String(overviewRelationCount));",
|
||||||
|
"}",
|
||||||
|
"",
|
||||||
|
"pm.test(\"Captured a populated overview key for the relation request\", function () {",
|
||||||
|
" pm.expect(overviewCounts).to.be.an(\"object\");",
|
||||||
|
" pm.expect(overviewRelationKey).to.be.a(\"string\").and.not.empty;",
|
||||||
|
" pm.expect(overviewRelationCount).to.be.above(0);",
|
||||||
|
"});"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
"request": {
|
"request": {
|
||||||
"method": "POST",
|
"method": "POST",
|
||||||
"header": [
|
"header": [
|
||||||
@@ -1071,7 +1102,7 @@
|
|||||||
],
|
],
|
||||||
"body": {
|
"body": {
|
||||||
"mode": "raw",
|
"mode": "raw",
|
||||||
"raw": "{\r\n \"UserId\": \"{{userId}}\",\r\n \"Scope\": \"{{scope}}\",\r\n \"Keys\": {{overviewKeysJson}},\r\n \"Filters\": { \"Filters\": [] }\r\n}"
|
"raw": "{\r\n \"Sid\": \"{{sid}}\",\r\n \"Scope\": \"{{scope}}\",\r\n \"Keys\": {{overviewKeysJson}},\r\n \"Filters\": { \"Filters\": [] }\r\n}"
|
||||||
},
|
},
|
||||||
"url": {
|
"url": {
|
||||||
"raw": "{{baseUrl}}/api/c4itf4sdwebapi/v2/getTicketOverviewCounts",
|
"raw": "{{baseUrl}}/api/c4itf4sdwebapi/v2/getTicketOverviewCounts",
|
||||||
@@ -1082,6 +1113,24 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "get filtered ticket overview relations",
|
"name": "get filtered ticket overview relations",
|
||||||
|
"event": [
|
||||||
|
{
|
||||||
|
"listen": "test",
|
||||||
|
"script": {
|
||||||
|
"type": "text/javascript",
|
||||||
|
"exec": [
|
||||||
|
"const overviewRelations = pm.response.text() ? pm.response.json() : [];",
|
||||||
|
"const expectedOverviewRelationCount = Number(pm.collectionVariables.get(\"overviewRelationExpectedCount\") || 0);",
|
||||||
|
"",
|
||||||
|
"pm.test(\"Overview relations match the captured populated count\", function () {",
|
||||||
|
" pm.expect(Array.isArray(overviewRelations)).to.equal(true);",
|
||||||
|
" pm.expect(expectedOverviewRelationCount).to.be.above(0);",
|
||||||
|
" pm.expect(overviewRelations.length).to.equal(expectedOverviewRelationCount);",
|
||||||
|
"});"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
"request": {
|
"request": {
|
||||||
"method": "POST",
|
"method": "POST",
|
||||||
"header": [
|
"header": [
|
||||||
@@ -1090,7 +1139,7 @@
|
|||||||
],
|
],
|
||||||
"body": {
|
"body": {
|
||||||
"mode": "raw",
|
"mode": "raw",
|
||||||
"raw": "{\r\n \"UserId\": \"{{userId}}\",\r\n \"Scope\": \"{{scope}}\",\r\n \"Key\": \"{{overviewKey}}\",\r\n \"Count\": {{overviewRelationExpectedCount}},\r\n \"Filters\": { \"Filters\": [] }\r\n}"
|
"raw": "{\r\n \"Sid\": \"{{sid}}\",\r\n \"Scope\": \"{{scope}}\",\r\n \"Key\": \"{{overviewKey}}\",\r\n \"Count\": {{overviewRelationExpectedCount}},\r\n \"Filters\": { \"Filters\": [] }\r\n}"
|
||||||
},
|
},
|
||||||
"url": {
|
"url": {
|
||||||
"raw": "{{baseUrl}}/api/c4itf4sdwebapi/v2/getTicketOverviewRelations",
|
"raw": "{{baseUrl}}/api/c4itf4sdwebapi/v2/getTicketOverviewRelations",
|
||||||
|
|||||||
Reference in New Issue
Block a user