test: capture ticket variables from list response

This commit is contained in:
Meik
2026-07-01 09:35:47 +02:00
parent 3ef49054ca
commit 8ba97b6baf

View File

@@ -71,10 +71,18 @@
"key": "ticketObjectId", "key": "ticketObjectId",
"value": "00000000-0000-0000-0000-000000000000" "value": "00000000-0000-0000-0000-000000000000"
}, },
{
"key": "eoid",
"value": "00000000-0000-0000-0000-000000000000"
},
{ {
"key": "objectType", "key": "objectType",
"value": "SPSActivityTypeIncident" "value": "SPSActivityTypeIncident"
}, },
{
"key": "type",
"value": "SPSActivityTypeIncident"
},
{ {
"key": "assetName", "key": "assetName",
"value": "" "value": ""
@@ -310,7 +318,24 @@
" if (!text) return;", " if (!text) return;",
" const json = pm.response.json();", " const json = pm.response.json();",
" pm.expect(json === null || Array.isArray(json)).to.equal(true);", " pm.expect(json === null || Array.isArray(json)).to.equal(true);",
"});" "});",
"",
"const tickets = pm.response.text() ? pm.response.json() : null;",
"if (Array.isArray(tickets) && tickets.length > 0) {",
" const ticket = tickets[0];",
" if (ticket.TicketObjectId) {",
" pm.collectionVariables.set(\"ticketObjectId\", ticket.TicketObjectId);",
" pm.collectionVariables.set(\"eoid\", ticket.TicketObjectId);",
" }",
" if (ticket.ActivityType) {",
" pm.collectionVariables.set(\"objectType\", ticket.ActivityType);",
" pm.collectionVariables.set(\"type\", ticket.ActivityType);",
" }",
" pm.test(\"Captured ticket object id and type\", function () {",
" pm.expect(pm.collectionVariables.get(\"eoid\")).to.match(/^[0-9a-fA-F-]{36}$/);",
" pm.expect(pm.collectionVariables.get(\"type\")).to.be.a(\"string\").and.not.empty;",
" });",
"}"
] ]
} }
} }
@@ -365,7 +390,7 @@
} }
], ],
"url": { "url": {
"raw": "{{baseUrl}}/api/c4itf4sdwebapi/getTicketDetails?objectId={{ticketObjectId}}", "raw": "{{baseUrl}}/api/c4itf4sdwebapi/getTicketDetails?objectId={{eoid}}",
"host": [ "host": [
"{{baseUrl}}" "{{baseUrl}}"
], ],
@@ -377,7 +402,7 @@
"query": [ "query": [
{ {
"key": "objectId", "key": "objectId",
"value": "{{ticketObjectId}}" "value": "{{eoid}}"
} }
] ]
} }
@@ -394,7 +419,7 @@
} }
], ],
"url": { "url": {
"raw": "{{baseUrl}}/api/c4itf4sdwebapi/getTicketHistory?objectId={{ticketObjectId}}", "raw": "{{baseUrl}}/api/c4itf4sdwebapi/getTicketHistory?objectId={{eoid}}",
"host": [ "host": [
"{{baseUrl}}" "{{baseUrl}}"
], ],
@@ -406,7 +431,7 @@
"query": [ "query": [
{ {
"key": "objectId", "key": "objectId",
"value": "{{ticketObjectId}}" "value": "{{eoid}}"
} }
] ]
} }
@@ -456,7 +481,7 @@
} }
], ],
"url": { "url": {
"raw": "{{baseUrl}}/api/c4itf4sdwebapi/getDirectLinkF4SD?EOID={{ticketObjectId}}&Type={{objectType}}", "raw": "{{baseUrl}}/api/c4itf4sdwebapi/getDirectLinkF4SD?EOID={{eoid}}&Type={{type}}",
"host": [ "host": [
"{{baseUrl}}" "{{baseUrl}}"
], ],
@@ -468,11 +493,11 @@
"query": [ "query": [
{ {
"key": "EOID", "key": "EOID",
"value": "{{ticketObjectId}}" "value": "{{eoid}}"
}, },
{ {
"key": "Type", "key": "Type",
"value": "{{objectType}}" "value": "{{type}}"
} }
] ]
} }