diff --git a/petshop-api.postman_collection.json b/petshop-api.postman_collection.json index 192c834c..c8fa07ca 100644 --- a/petshop-api.postman_collection.json +++ b/petshop-api.postman_collection.json @@ -2363,7 +2363,12 @@ ], "body": { "mode": "raw", - "raw": "{\n \"message\": \"I need help\"\n}" + "raw": "{\n \"message\": \"I need help\"\n}", + "options": { + "raw": { + "language": "json" + } + } } }, "event": [ @@ -2376,14 +2381,46 @@ " pm.response.to.have.status(201);", "});", "var jsonData = pm.response.json();", - "if (jsonData.id !== undefined) pm.collectionVariables.set('conversationId', jsonData.id);" + "pm.expect(jsonData.id).to.exist;", + "pm.collectionVariables.set('conversationId', jsonData.id);" ] } } ] }, { - "name": "List Conversations", + "name": "Customer List Conversations", + "request": { + "method": "GET", + "url": "{{baseUrl}}/api/v1/chat/conversations", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Authorization", + "value": "Bearer {{customerToken}}", + "type": "text" + } + ] + }, + "event": [ + { + "listen": "test", + "script": { + "type": "text/javascript", + "exec": [ + "pm.test('Status code is 200', function () {", + " pm.response.to.have.status(200);", + "});" + ] + } + } + ] + }, + { + "name": "Staff List Conversations", "request": { "method": "GET", "url": "{{baseUrl}}/api/v1/chat/conversations", @@ -2445,7 +2482,80 @@ ] }, { - "name": "Send Message", + "name": "Customer Request Human", + "request": { + "method": "POST", + "url": "{{baseUrl}}/api/v1/chat/conversations/{{conversationId}}/request-human", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Authorization", + "value": "Bearer {{customerToken}}", + "type": "text" + } + ] + }, + "event": [ + { + "listen": "test", + "script": { + "type": "text/javascript", + "exec": [ + "pm.test('Status code is 200', function () {", + " pm.response.to.have.status(200);", + "});", + "var jsonData = pm.response.json();", + "pm.expect(jsonData.mode).to.eql('AUTOMATED');" + ] + } + } + ] + }, + { + "name": "Customer Send Message", + "request": { + "method": "POST", + "url": "{{baseUrl}}/api/v1/chat/conversations/{{conversationId}}/messages", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Authorization", + "value": "Bearer {{customerToken}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"content\": \"Customer follow-up from Postman\"\n}", + "options": { + "raw": { + "language": "json" + } + } + } + }, + "event": [ + { + "listen": "test", + "script": { + "type": "text/javascript", + "exec": [ + "pm.test('Status code is 201', function () {", + " pm.response.to.have.status(201);", + "});" + ] + } + } + ] + }, + { + "name": "Staff Send Message", "request": { "method": "POST", "url": "{{baseUrl}}/api/v1/chat/conversations/{{conversationId}}/messages", @@ -2478,14 +2588,16 @@ "exec": [ "pm.test('Status code is 201', function () {", " pm.response.to.have.status(201);", - "});" + "});", + "var jsonData = pm.response.json();", + "pm.expect(jsonData.senderRole).to.eql('STAFF');" ] } } ] }, { - "name": "Get Messages", + "name": "Customer Get Messages", "request": { "method": "GET", "url": "{{baseUrl}}/api/v1/chat/conversations/{{conversationId}}/messages", @@ -2509,7 +2621,42 @@ "exec": [ "pm.test('Status code is 200', function () {", " pm.response.to.have.status(200);", - "});" + "});", + "var jsonData = pm.response.json();", + "pm.expect(jsonData.length).to.be.above(0);" + ] + } + } + ] + }, + { + "name": "Staff Get Messages", + "request": { + "method": "GET", + "url": "{{baseUrl}}/api/v1/chat/conversations/{{conversationId}}/messages", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Authorization", + "value": "Bearer {{staffToken}}", + "type": "text" + } + ] + }, + "event": [ + { + "listen": "test", + "script": { + "type": "text/javascript", + "exec": [ + "pm.test('Status code is 200', function () {", + " pm.response.to.have.status(200);", + "});", + "var jsonData = pm.response.json();", + "pm.expect(jsonData.length).to.be.above(0);" ] } }