From cbcdd938eb06aa5ea760ed906e68e5cf01f80a20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferdinand=20M=C3=BCtsch?= Date: Sun, 26 Dec 2021 18:56:53 +0100 Subject: [PATCH] chore: add api tests for filtering --- .../Wakapi API Tests.postman_collection.json | 280 ++++++++++++++++++ 1 file changed, 280 insertions(+) diff --git a/testing/Wakapi API Tests.postman_collection.json b/testing/Wakapi API Tests.postman_collection.json index 1ab3ed0..c95e6c1 100644 --- a/testing/Wakapi API Tests.postman_collection.json +++ b/testing/Wakapi API Tests.postman_collection.json @@ -1437,6 +1437,156 @@ } }, "response": [] + }, + { + "name": "Get summary (today, filtered)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const moment = require('moment')", + "", + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});", + "", + "pm.test(\"Correct user\", function () {", + " const jsonData = pm.response.json();", + " pm.expect(jsonData.user_id).to.eql(\"writeuser\");", + "});", + "", + "pm.test(\"Correct summary data\", function () {", + " const jsonData = pm.response.json();", + " pm.expect(jsonData.projects.length).to.eql(1);", + " pm.expect(jsonData.languages.length).to.eql(1);", + " pm.expect(jsonData.editors.length).to.eql(1);", + " pm.expect(jsonData.operating_systems.length).to.eql(1);", + " pm.expect(jsonData.machines.length).to.eql(1);", + "});" + ], + "type": "text/javascript" + } + } + ], + "protocolProfileBehavior": { + "tlsPreferServerCiphers": true, + "disableCookies": true + }, + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{WRITEUSER_TOKEN}}", + "type": "string" + } + ] + }, + "method": "GET", + "header": [], + "url": { + "raw": "{{BASE_URL}}/api/summary?interval=today&project=wakapi&language=Go", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "api", + "summary" + ], + "query": [ + { + "key": "interval", + "value": "today" + }, + { + "key": "project", + "value": "wakapi" + }, + { + "key": "language", + "value": "Go" + } + ] + } + }, + "response": [] + }, + { + "name": "Get summary (today, filtered non-matching)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const moment = require('moment')", + "", + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});", + "", + "pm.test(\"Correct user\", function () {", + " const jsonData = pm.response.json();", + " pm.expect(jsonData.user_id).to.eql(\"writeuser\");", + "});", + "", + "pm.test(\"Correct summary data\", function () {", + " const jsonData = pm.response.json();", + " pm.expect(jsonData.projects.length).to.eql(0);", + " pm.expect(jsonData.languages.length).to.eql(0);", + " pm.expect(jsonData.editors.length).to.eql(0);", + " pm.expect(jsonData.operating_systems.length).to.eql(0);", + " pm.expect(jsonData.machines.length).to.eql(0);", + "});" + ], + "type": "text/javascript" + } + } + ], + "protocolProfileBehavior": { + "tlsPreferServerCiphers": true, + "disableCookies": true + }, + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{WRITEUSER_TOKEN}}", + "type": "string" + } + ] + }, + "method": "GET", + "header": [], + "url": { + "raw": "{{BASE_URL}}/api/summary?interval=today&project=wakapi&language=JavaScript", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "api", + "summary" + ], + "query": [ + { + "key": "interval", + "value": "today" + }, + { + "key": "project", + "value": "wakapi" + }, + { + "key": "language", + "value": "JavaScript" + } + ] + } + }, + "response": [] } ] }, @@ -1968,6 +2118,136 @@ }, "response": [] }, + { + "name": "Get stats (filtered)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});", + "", + "pm.test(\"Correct content\", function () {", + " const jsonData = pm.response.json();", + " pm.expect(jsonData.data.projects.length).to.eql(1);", + " pm.expect(jsonData.data.total_seconds).to.gt(0);", + "});" + ], + "type": "text/javascript" + } + } + ], + "protocolProfileBehavior": { + "disableCookies": true + }, + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{WRITEUSER_TOKEN}}", + "type": "string" + } + ] + }, + "method": "GET", + "header": [], + "url": { + "raw": "{{BASE_URL}}/api/compat/wakatime/v1/users/current/stats?project=wakapi&language=Go", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "api", + "compat", + "wakatime", + "v1", + "users", + "current", + "stats" + ], + "query": [ + { + "key": "project", + "value": "wakapi" + }, + { + "key": "language", + "value": "Go" + } + ] + } + }, + "response": [] + }, + { + "name": "Get stats (filtered non-matching)", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});", + "", + "pm.test(\"Correct content\", function () {", + " const jsonData = pm.response.json();", + " pm.expect(jsonData.data.projects.length).to.eql(0);", + " pm.expect(jsonData.data.total_seconds).to.eql(0);", + "});" + ], + "type": "text/javascript" + } + } + ], + "protocolProfileBehavior": { + "disableCookies": true + }, + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{WRITEUSER_TOKEN}}", + "type": "string" + } + ] + }, + "method": "GET", + "header": [], + "url": { + "raw": "{{BASE_URL}}/api/compat/wakatime/v1/users/current/stats?project=wakapi&language=JavaScript", + "host": [ + "{{BASE_URL}}" + ], + "path": [ + "api", + "compat", + "wakatime", + "v1", + "users", + "current", + "stats" + ], + "query": [ + { + "key": "project", + "value": "wakapi" + }, + { + "key": "language", + "value": "JavaScript" + } + ] + } + }, + "response": [] + }, { "name": "Get statusbar (current)", "event": [