From dbd8f44831bf3ad175d512d8175a4dc999c8a87e Mon Sep 17 00:00:00 2001 From: Jemma Date: Wed, 26 Apr 2023 00:25:23 -0500 Subject: [PATCH] Updated community test case to also validate error response formatting --- postman/collections/Communities.json | 52 ++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 3 deletions(-) diff --git a/postman/collections/Communities.json b/postman/collections/Communities.json index 5114a0d..7fd63df 100644 --- a/postman/collections/Communities.json +++ b/postman/collections/Communities.json @@ -420,7 +420,7 @@ { "listen": "prerequest", "script": { - "id": "ab6f4437-0090-4f7e-a72e-36c1db11a5a7", + "id": "64933ef4-dc38-4d6f-a8c5-54b93decd369", "type": "text/javascript", "exec": [ "" @@ -430,7 +430,7 @@ { "listen": "test", "script": { - "id": "095ce2df-1f5a-4fcf-b4d4-c3b7616d3baa", + "id": "f00757f9-3faf-40da-89ff-0f3fb356678f", "type": "text/javascript", "exec": [ "const headerSchema = {", @@ -468,9 +468,55 @@ " ]", "};", "", + "const errorSchema = {", + " \"type\": \"object\",", + " \"properties\": {", + " \"result\": {", + " \"type\": \"object\",", + " \"properties\": {", + " \"has_error\": {", + " \"type\": \"string\",", + " \"maxLength\": 1", + " },", + " \"version\": {", + " \"type\": \"string\",", + " \"maxLength\": 1", + " },", + " \"code\": {", + " \"type\": \"string\",", + " \"maxLength\": 3", + " },", + " \"error_code\": {", + " \"type\": \"string\",", + " \"maxLength\": 4", + " },", + " \"message\": {", + " \"type\": \"string\"", + " }", + " },", + " \"required\": [", + " \"has_error\",", + " \"version\",", + " \"code\",", + " \"error_code\",", + " \"message\"", + " ]", + " },", + "", + " },", + " \"required\": [", + " \"result\"", + " ]", + "};", + "", "pm.test(\"Valid XML Response Header\", function () {", " var json = xml2Json(pm.response.text());", - " pm.expect(json).to.have.jsonSchema(headerSchema);", + " console.log(pm.response.code);", + " if(pm.response.code === 200)", + " pm.expect(json).to.have.jsonSchema(headerSchema);", + " else ", + " pm.expect(json).to.have.jsonSchema(errorSchema);", + " ", "})" ] }