test: derive overview relation request from counts

This commit is contained in:
Meik
2026-07-01 16:31:12 +02:00
parent ec9fc5fb47
commit 3124f6c97b

View File

@@ -113,6 +113,10 @@
"key": "overviewKey", "key": "overviewKey",
"value": "open" "value": "open"
}, },
{
"key": "overviewRelationExpectedCount",
"value": "0"
},
{ {
"key": "overviewKeys", "key": "overviewKeys",
"value": "TicketsNew,TicketsActive,TicketsCritical,TicketsNewInfo,IncidentNew,IncidentActive,IncidentCritical,IncidentNewInfo,UnassignedTickets,UnassignedTicketsCritical" "value": "TicketsNew,TicketsActive,TicketsCritical,TicketsNewInfo,IncidentNew,IncidentActive,IncidentCritical,IncidentNewInfo,UnassignedTickets,UnassignedTicketsCritical"
@@ -494,6 +498,39 @@
"item": [ "item": [
{ {
"name": "getTicketOverviewCounts personal", "name": "getTicketOverviewCounts personal",
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"const overviewCountsPersonalJson = pm.response.json();",
"const overviewCountsPersonal = overviewCountsPersonalJson.counts || overviewCountsPersonalJson.Counts || {};",
"const overviewPreferredKeysPersonal = (pm.collectionVariables.get(\"overviewKeys\") || \"\")",
" .split(\",\")",
" .map(key => key.trim())",
" .filter(Boolean);",
"const overviewRelationKeyPersonal = overviewPreferredKeysPersonal.find(key => Number(overviewCountsPersonal[key] || 0) > 0)",
" || Object.keys(overviewCountsPersonal).find(key => Number(overviewCountsPersonal[key] || 0) > 0)",
" || overviewPreferredKeysPersonal[0]",
" || Object.keys(overviewCountsPersonal)[0]",
" || \"\";",
"const overviewRelationCountPersonal = overviewRelationKeyPersonal ? Number(overviewCountsPersonal[overviewRelationKeyPersonal] || 0) : 0;",
"",
"pm.collectionVariables.set(\"scope\", \"personal\");",
"pm.collectionVariables.set(\"overviewKey\", overviewRelationKeyPersonal);",
"pm.collectionVariables.set(\"overviewRelationExpectedCount\", String(overviewRelationCountPersonal));",
"",
"pm.test(\"Captured personal overview relation parameters\", function () {",
" pm.expect(overviewCountsPersonal).to.be.an(\"object\");",
" pm.expect(pm.collectionVariables.get(\"scope\")).to.equal(\"personal\");",
" pm.expect(pm.collectionVariables.get(\"overviewKey\")).to.be.a(\"string\").and.not.empty;",
" pm.expect(Number(pm.collectionVariables.get(\"overviewRelationExpectedCount\"))).to.be.at.least(0);",
"});"
]
}
}
],
"request": { "request": {
"method": "GET", "method": "GET",
"header": [ "header": [
@@ -539,6 +576,39 @@
}, },
{ {
"name": "getTicketOverviewCounts role", "name": "getTicketOverviewCounts role",
"event": [
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
"const overviewCountsRoleJson = pm.response.json();",
"const overviewCountsRole = overviewCountsRoleJson.counts || overviewCountsRoleJson.Counts || {};",
"const overviewPreferredKeysRole = (pm.collectionVariables.get(\"overviewKeys\") || \"\")",
" .split(\",\")",
" .map(key => key.trim())",
" .filter(Boolean);",
"const overviewRelationKeyRole = overviewPreferredKeysRole.find(key => Number(overviewCountsRole[key] || 0) > 0)",
" || Object.keys(overviewCountsRole).find(key => Number(overviewCountsRole[key] || 0) > 0)",
" || overviewPreferredKeysRole[0]",
" || Object.keys(overviewCountsRole)[0]",
" || \"\";",
"const overviewRelationCountRole = overviewRelationKeyRole ? Number(overviewCountsRole[overviewRelationKeyRole] || 0) : 0;",
"",
"pm.collectionVariables.set(\"scope\", \"role\");",
"pm.collectionVariables.set(\"overviewKey\", overviewRelationKeyRole);",
"pm.collectionVariables.set(\"overviewRelationExpectedCount\", String(overviewRelationCountRole));",
"",
"pm.test(\"Captured role overview relation parameters\", function () {",
" pm.expect(overviewCountsRole).to.be.an(\"object\");",
" pm.expect(pm.collectionVariables.get(\"scope\")).to.equal(\"role\");",
" pm.expect(pm.collectionVariables.get(\"overviewKey\")).to.be.a(\"string\").and.not.empty;",
" pm.expect(Number(pm.collectionVariables.get(\"overviewRelationExpectedCount\"))).to.be.at.least(0);",
"});"
]
}
}
],
"request": { "request": {
"method": "GET", "method": "GET",
"header": [ "header": [
@@ -615,6 +685,23 @@
}, },
{ {
"name": "getTicketOverviewRelations", "name": "getTicketOverviewRelations",
"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 count matches captured overview count\", function () {",
" pm.expect(Array.isArray(overviewRelations)).to.equal(true);",
" pm.expect(overviewRelations.length).to.equal(expectedOverviewRelationCount);",
"});"
]
}
}
],
"request": { "request": {
"method": "GET", "method": "GET",
"header": [ "header": [
@@ -624,7 +711,7 @@
} }
], ],
"url": { "url": {
"raw": "{{baseUrl}}/api/c4itf4sdwebapi/getTicketOverviewRelations?sid={{sid}}&scope={{scope}}&key={{overviewKey}}&count=25&queueoption={{queueOption}}&queues={{queues}}", "raw": "{{baseUrl}}/api/c4itf4sdwebapi/getTicketOverviewRelations?sid={{sid}}&scope={{scope}}&key={{overviewKey}}&count={{overviewRelationExpectedCount}}&queueoption={{queueOption}}&queues={{queues}}",
"host": [ "host": [
"{{baseUrl}}" "{{baseUrl}}"
], ],
@@ -648,7 +735,7 @@
}, },
{ {
"key": "count", "key": "count",
"value": "25" "value": "{{overviewRelationExpectedCount}}"
}, },
{ {
"key": "queueoption", "key": "queueoption",