diff --git a/Postman-backend-dev-tests/Damage Assessment API Tests.postman_collection.json b/Postman-backend-dev-tests/Damage Assessment API Tests.postman_collection.json index b7dad9c..9f8e8a3 100644 --- a/Postman-backend-dev-tests/Damage Assessment API Tests.postman_collection.json +++ b/Postman-backend-dev-tests/Damage Assessment API Tests.postman_collection.json @@ -60,81 +60,178 @@ "name": "Answers", "item": [ { - "name": "Get Answers", - "event": [ + "name": "Get Requests", + "item": [ { - "listen": "test", - "script": { - "exec": [ - "var jsonData = JSON.parse(responseBody);", - "", - "pm.test(\"No errors in Pre-request Script\", function() {", - " pm.expect(pm.environment.get(\"preRequestError\")).to.be.undefined;", - "});", - "", - "tests[\"200 Unauthorized POST request\"] = responseCode.code === 200;", - "pm.test(\"Response status code is 200\", function () {", - " pm.response.to.have.status(200);", - "});", - "", - "", - "pm.test(\"Response is an array\", function () {", - " pm.expect(pm.response.json()).to.be.an('array');", - "});", - "", - "", - "pm.test(\"Response array is empty\", function () {", - " const responseData = pm.response.json();", - " ", - " pm.expect(responseData).to.be.an('array');", - " pm.expect(responseData).to.have.lengthOf(0);", - "});", - "", - "", - "pm.test(\"Response time is less than 200ms\", function () {", - " pm.expect(pm.response.responseTime).to.be.below(200);", - "});", - "", - "", - "pm.test(\"Response does not contain any errors or error messages\", function () {", - " const responseData = pm.response.json();", - "", - " pm.expect(responseData).to.be.an('array');", - " pm.expect(responseData).to.have.lengthOf(0, \"Response should not contain any errors or error messages\");", - "});" - ], - "type": "text/javascript" - } + "name": "Get Answers", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "var jsonData = JSON.parse(responseBody);", + "", + "pm.test(\"No errors in Pre-request Script\", function() {", + " pm.expect(pm.environment.get(\"preRequestError\")).to.be.undefined;", + "});", + "", + "tests[\"200 Unauthorized POST request\"] = responseCode.code === 200;", + "pm.test(\"Response status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});", + "", + "", + "pm.test(\"Response is an array\", function () {", + " pm.expect(pm.response.json()).to.be.an('array');", + "});", + "", + "", + "pm.test(\"Response array is empty\", function () {", + " const responseData = pm.response.json();", + " ", + " pm.expect(responseData).to.be.an('array');", + " pm.expect(responseData).to.have.lengthOf(0);", + "});", + "", + "", + "pm.test(\"Response time is less than 200ms\", function () {", + " pm.expect(pm.response.responseTime).to.be.below(200);", + "});", + "", + "", + "pm.test(\"Response does not contain any errors or error messages\", function () {", + " const responseData = pm.response.json();", + "", + " pm.expect(responseData).to.be.an('array');", + " pm.expect(responseData).to.have.lengthOf(0, \"Response should not contain any errors or error messages\");", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "if (!pm.environment.get(\"domain\")) {", + " console.error(\"Error: Domain is missing!\");", + "", + " // Set an error flag", + " pm.environment.set(\"preRequestError\", \"Domain is missing!\");", + "", + " // Change request URL to prevent it from sending", + " pm.request.url = \"http://invalid-url-to-prevent-sending.com\";", + "}" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{domain}}answers", + "host": [ + "{{domain}}answers" + ] + } + }, + "response": [] }, { - "listen": "prerequest", - "script": { - "exec": [ - "if (!pm.environment.get(\"domain\")) {", - " console.error(\"Error: Domain is missing!\");", - "", - " // Set an error flag", - " pm.environment.set(\"preRequestError\", \"Domain is missing!\");", - "", - " // Change request URL to prevent it from sending", - " pm.request.url = \"http://invalid-url-to-prevent-sending.com\";", - "}" - ], - "type": "text/javascript" - } + "name": "Get Answers By Id", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "var jsonData = JSON.parse(responseBody);", + "", + "tests[\"200 Unauthorized POST request\"] = responseCode.code === 200;" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{domain}}answers/1", + "host": [ + "{{domain}}answers" + ], + "path": [ + "1" + ] + } + }, + "response": [] + }, + { + "name": "Get Answers By Reponse Id", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "var jsonData = JSON.parse(responseBody);", + "", + "tests[\"200 Unauthorized POST request\"] = responseCode.code === 200;" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{domain}}answers/byresponse/1", + "host": [ + "{{domain}}answers" + ], + "path": [ + "byresponse", + "1" + ] + } + }, + "response": [] + }, + { + "name": "Get Answers By Question Id", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "var jsonData = JSON.parse(responseBody);", + "", + "tests[\"200 Unauthorized POST request\"] = responseCode.code === 200;" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{domain}}answers/byquestion/1", + "host": [ + "{{domain}}answers" + ], + "path": [ + "byquestion", + "1" + ] + } + }, + "response": [] } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{domain}}answers", - "host": [ - "{{domain}}answers" - ] - } - }, - "response": [] + ] }, { "name": "Put Answers", @@ -203,98 +300,6 @@ }, "response": [] }, - { - "name": "Get Answers By Id", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "var jsonData = JSON.parse(responseBody);", - "", - "tests[\"200 Unauthorized POST request\"] = responseCode.code === 200;" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{domain}}answers/1", - "host": [ - "{{domain}}answers" - ], - "path": [ - "1" - ] - } - }, - "response": [] - }, - { - "name": "Get Answers By Reponse Id", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "var jsonData = JSON.parse(responseBody);", - "", - "tests[\"200 Unauthorized POST request\"] = responseCode.code === 200;" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{domain}}answers/byresponse/1", - "host": [ - "{{domain}}answers" - ], - "path": [ - "byresponse", - "1" - ] - } - }, - "response": [] - }, - { - "name": "Get Answers By Question Id", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "var jsonData = JSON.parse(responseBody);", - "", - "tests[\"200 Unauthorized POST request\"] = responseCode.code === 200;" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{domain}}answers/byquestion/1", - "host": [ - "{{domain}}answers" - ], - "path": [ - "byquestion", - "1" - ] - } - }, - "response": [] - }, { "name": "Delete Answers by Id", "event": [ @@ -331,409 +336,1777 @@ "name": "Employees", "item": [ { - "name": "Get Employees", - "event": [ + "name": "Get Requests", + "item": [ { - "listen": "test", - "script": { - "exec": [ - "var jsonData = JSON.parse(responseBody);", - "", - "", - "pm.test(\"No errors in Pre-request Script\", function() {", - " pm.expect(pm.environment.get(\"preRequestError\")).to.be.undefined;", - "});", - "", - "", - "tests[\"Response code is 200 OK\"] = responseCode.code === 200;", - "", - "// This assumes jsonData.items is sorted and you want the next ID.", - "var nextId;", - "if (jsonData && jsonData.length > 0) {", - " nextId = _.last(jsonData).id + 1;", - " pm.environment.set(\"nextEmployeeId\", nextId);", - "} else {", - " console.log(\"No items found in the response or invalid response format\");", - "}", - "" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "if (!pm.environment.get(\"domain\")) {", - " console.error(\"Error: Domain is missing!\");", - "", - " // Set an error flag", - " pm.environment.set(\"preRequestError\", \"Domain is missing!\");", - "", - " // Change request URL to prevent it from sending", - " pm.request.url = \"http://invalid-url-to-prevent-sending.com\";", - "}" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{domain}}employees", - "host": [ - "{{domain}}employees" - ] - } - }, - "response": [] - }, - { - "name": "Post Employees", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "var jsonData = JSON.parse(responseBody);", - "", - "tests[\"200 Unauthorized POST request\"] = responseCode.code === 200;", - "" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "function pad(number, digits) {", - " return String(number).padStart(digits, '0');", - "}", - "", - "// Random year between 1980 and 2000", - "var randomYear = Math.floor(Math.random() * (2000 - 1980 + 1) + 1980);", - "", - "// Random month between 1 and 12", - "var randomMonth = Math.floor(Math.random() * 12) + 1;", - "", - "// Days per month (considering leap year for February)", - "var daysInMonth = [31, (randomYear % 4 === 0 && (randomYear % 100 !== 0 || randomYear % 400 === 0)) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];", - "", - "// Random day based on month", - "var randomDay = Math.floor(Math.random() * daysInMonth[randomMonth - 1]) + 1;", - "", - "// Random time components", - "var randomHour = Math.floor(Math.random() * 24);", - "var randomMinute = Math.floor(Math.random() * 60);", - "var randomSecond = Math.floor(Math.random() * 60);", - "var randomMillisecond = Math.floor(Math.random() * 10000000); // 7 digits", - "", - "// Construct the date string", - "var randomBirthDate = randomYear + '-' +", - " pad(randomMonth, 2) + '-' +", - " pad(randomDay, 2) + 'T' +", - " pad(randomHour, 2) + ':' +", - " pad(randomMinute, 2) + ':' +", - " pad(randomSecond, 2) + '.' +", - " pad(randomMillisecond, 7) + '+00:00';", - "", - "// Array of possible languages", - "var languages = [\"en\", \"fr\", \"de\", \"ht\", \"es\"];", - "var randomLanguage = languages[Math.floor(Math.random() * languages.length)];", - "", - "// Use Postman's built-in dynamic variables", - "var firstName = pm.variables.replaceIn(\"{{$randomFirstName}}\");", - "var lastName = pm.variables.replaceIn(\"{{$randomLastName}}\");", - "var phoneNumber = pm.variables.replaceIn(\"{{$randomPhoneNumber}}\");", - "var email = pm.variables.replaceIn(\"{{$randomEmail}}\");", - "var randomBoolean = pm.variables.replaceIn(\"{{$randomBoolean}}\"); // This will return \"true\" or \"false\" as a string", - "", - "// Set the environment variables", - "pm.environment.set(\"employeeName\", firstName + \" \" + lastName);", - "pm.environment.set(\"randomPhoneNumber\", phoneNumber);", - "pm.environment.set(\"randomBirthDate\", randomBirthDate);", - "pm.environment.set(\"randomEmail\", email);", - "pm.environment.set(\"randomBoolean\", randomBoolean);", - "pm.environment.set(\"randomLanguage\", randomLanguage);", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"id\": {{nextEmployeeId}},\n \"employeeCode\": \"{{$randomBankAccount}}\",\n \"name\": \"{{employeeName}}\",\n \"birthDate\": \"{{randomBirthDate}}\",\n \"officePhoneNumber\": \"{{randomPhoneNumber}}\",\n \"email\": \"{{randomEmail}}\",\n \"isActive\": {{$randomBoolean}},\n \"preferredLanguage\": \"{{randomLanguage}}\"\n}", - "options": { - "raw": { - "language": "json" + "name": "Get Employees", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "var jsonData = JSON.parse(responseBody);", + "", + "", + "pm.test(\"No errors in Pre-request Script\", function() {", + " pm.expect(pm.environment.get(\"preRequestError\")).to.be.undefined;", + "});", + "", + "", + "tests[\"Response code is 200 OK\"] = responseCode.code === 200;", + "", + "// This assumes jsonData.items is sorted and you want the next ID.", + "var nextId;", + "if (jsonData && jsonData.length > 0) {", + " lastId = _.last(jsonData).id", + " nextId = lastId + 1;", + " pm.environment.set(\"lastEmployeeId\", lastId);", + " pm.environment.set(\"nextEmployeeId\", nextId);", + "} else {", + " console.log(\"No items found in the response or invalid response format\");", + "}", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "if (!pm.environment.get(\"domain\")) {", + " console.error(\"Error: Domain is missing!\");", + "", + " // Set an error flag", + " pm.environment.set(\"preRequestError\", \"Domain is missing!\");", + "", + " // Change request URL to prevent it from sending", + " pm.request.url = \"http://invalid-url-to-prevent-sending.com\";", + "}" + ], + "type": "text/javascript" + } } - } - }, - "url": { - "raw": "{{domain}}employees", - "host": [ - "{{domain}}employees" - ] - } - }, - "response": [] - }, - { - "name": "Get Employees By Id", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "var jsonData = JSON.parse(responseBody);", - "", - "tests[\"Response code is 200 OK\"] = responseCode.code === 200;", - "", - "pm.test(\"Employee name matches\", function() {", - " var expectedName = pm.environment.get(\"employeeName\");", - " pm.expect(jsonData.name).to.eql(expectedName);", - "});", - "", - "pm.test(\"Birth date matches\", function() {", - " var expectedBirthDate = pm.environment.get(\"randomBirthDate\");", - " pm.expect(jsonData.birthDate).to.eql(expectedBirthDate);", - "});", - "", - "pm.test(\"Phone number matches\", function() {", - " var expectedPhoneNumber = pm.environment.get(\"randomPhoneNumber\");", - " pm.expect(jsonData.officePhoneNumber).to.eql(expectedPhoneNumber);", - "});", - "", - "pm.test(\"Email matches\", function() {", - " var expectedEmail = pm.environment.get(\"randomEmail\");", - " pm.expect(jsonData.email).to.eql(expectedEmail);", - "});", - "", - "pm.test(\"Activity status matches\", function() {", - " var expectedIsActive = pm.environment.get(\"randomBoolean\");", - " pm.expect(jsonData.isActive).to.eql(expectedIsActive === \"true\");", - "});", - "", - "pm.test(\"Preferred language matches\", function() {", - " var expectedLanguage = pm.environment.get(\"randomLanguage\");", - " pm.expect(jsonData.preferredLanguage).to.eql(expectedLanguage);", - "});", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{domain}}employees/{{nextEmployeeId}}", - "host": [ - "{{domain}}employees" ], - "path": [ - "{{nextEmployeeId}}" - ] - } - }, - "response": [] - }, - { - "name": "Put Employees", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "var jsonData = JSON.parse(responseBody);", - "", - "tests[\"200 Unauthorized POST request\"] = responseCode.code === 200;", - "" - ], - "type": "text/javascript" - } - }, - { - "listen": "prerequest", - "script": { - "exec": [ - "function pad(number, digits) {", - " return String(number).padStart(digits, '0');", - "}", - "", - "// Random year between 1980 and 2000", - "var randomYear = Math.floor(Math.random() * (2000 - 1980 + 1) + 1980);", - "", - "// Random month between 1 and 12", - "var randomMonth = Math.floor(Math.random() * 12) + 1;", - "", - "// Days per month (considering leap year for February)", - "var daysInMonth = [31, (randomYear % 4 === 0 && (randomYear % 100 !== 0 || randomYear % 400 === 0)) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];", - "", - "// Random day based on month", - "var randomDay = Math.floor(Math.random() * daysInMonth[randomMonth - 1]) + 1;", - "", - "// Random time components", - "var randomHour = Math.floor(Math.random() * 24);", - "var randomMinute = Math.floor(Math.random() * 60);", - "var randomSecond = Math.floor(Math.random() * 60);", - "var randomMillisecond = Math.floor(Math.random() * 10000000); // 7 digits", - "", - "// Construct the date string", - "var randomBirthDate = randomYear + '-' +", - " pad(randomMonth, 2) + '-' +", - " pad(randomDay, 2) + 'T' +", - " pad(randomHour, 2) + ':' +", - " pad(randomMinute, 2) + ':' +", - " pad(randomSecond, 2) + '.' +", - " pad(randomMillisecond, 7) + '+00:00';", - "", - "// Array of possible languages", - "var languages = [\"en\", \"fr\", \"de\", \"ht\", \"es\"];", - "var randomLanguage = languages[Math.floor(Math.random() * languages.length)];", - "", - "// Use Postman's built-in dynamic variables", - "var firstName = pm.variables.replaceIn(\"{{$randomFirstName}}\");", - "var lastName = pm.variables.replaceIn(\"{{$randomLastName}}\");", - "var phoneNumber = pm.variables.replaceIn(\"{{$randomPhoneNumber}}\");", - "var email = pm.variables.replaceIn(\"{{$randomEmail}}\");", - "var randomBoolean = pm.variables.replaceIn(\"{{$randomBoolean}}\"); // This will return \"true\" or \"false\" as a string", - "", - "// Set the environment variables", - "pm.environment.set(\"employeeName\", firstName + \" \" + lastName);", - "pm.environment.set(\"randomPhoneNumber\", phoneNumber);", - "pm.environment.set(\"randomBirthDate\", randomBirthDate);", - "pm.environment.set(\"randomEmail\", email);", - "pm.environment.set(\"randomBoolean\", randomBoolean);", - "pm.environment.set(\"randomLanguage\", randomLanguage);", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "PUT", - "header": [], - "body": { - "mode": "raw", - "raw": "{\n \"id\": {{nextEmployeeId}},\n \"employeeCode\": \"{{$randomBankAccount}}\",\n \"name\": \"{{employeeName}}\",\n \"birthDate\": \"{{randomBirthDate}}\",\n \"officePhoneNumber\": \"{{randomPhoneNumber}}\",\n \"email\": \"{{randomEmail}}\",\n \"isActive\": {{$randomBoolean}},\n \"preferredLanguage\": \"{{randomLanguage}}\"\n}", - "options": { - "raw": { - "language": "json" + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{domain}}employees", + "host": [ + "{{domain}}employees" + ] } - } + }, + "response": [] }, - "url": { - "raw": "{{domain}}employees", - "host": [ - "{{domain}}employees" - ] + { + "name": "Get Employees By Id", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "var jsonData = JSON.parse(responseBody);", + "", + "tests[\"Response code is 200 OK\"] = responseCode.code === 200;", + "", + "pm.test(\"Employee name matches\", function() {", + " var expectedName = pm.environment.get(\"employeeName\");", + " pm.expect(jsonData.name).to.eql(expectedName);", + "});", + "", + "pm.test(\"Birth date matches\", function() {", + " var expectedBirthDate = pm.environment.get(\"randomBirthDate\");", + " pm.expect(jsonData.birthDate).to.eql(expectedBirthDate);", + "});", + "", + "pm.test(\"Phone number matches\", function() {", + " var expectedPhoneNumber = pm.environment.get(\"randomPhoneNumber\");", + " pm.expect(jsonData.officePhoneNumber).to.eql(expectedPhoneNumber);", + "});", + "", + "pm.test(\"Email matches\", function() {", + " var expectedEmail = pm.environment.get(\"randomEmail\");", + " pm.expect(jsonData.email).to.eql(expectedEmail);", + "});", + "", + "pm.test(\"Activity status matches\", function() {", + " var expectedIsActive = pm.environment.get(\"randomBoolean\");", + " pm.expect(jsonData.isActive).to.eql(expectedIsActive === \"true\");", + "});", + "", + "pm.test(\"Preferred language matches\", function() {", + " var expectedLanguage = pm.environment.get(\"randomLanguage\");", + " pm.expect(jsonData.preferredLanguage).to.eql(expectedLanguage);", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{domain}}employees/{{lastEmployeeId}}", + "host": [ + "{{domain}}employees" + ], + "path": [ + "{{lastEmployeeId}}" + ] + } + }, + "response": [] } - }, - "response": [] + ] }, { - "name": "Get Employees By Id", - "event": [ + "name": "Add Employee", + "item": [ { - "listen": "test", - "script": { - "exec": [ - "var jsonData = JSON.parse(responseBody);", - "", - "tests[\"Response code is 200 OK\"] = responseCode.code === 200;", - "", - "pm.test(\"Employee name matches\", function() {", - " var expectedName = pm.environment.get(\"employeeName\");", - " pm.expect(jsonData.name).to.eql(expectedName);", - "});", - "", - "pm.test(\"Birth date matches\", function() {", - " var expectedBirthDate = pm.environment.get(\"randomBirthDate\");", - " pm.expect(jsonData.birthDate).to.eql(expectedBirthDate);", - "});", - "", - "pm.test(\"Phone number matches\", function() {", - " var expectedPhoneNumber = pm.environment.get(\"randomPhoneNumber\");", - " pm.expect(jsonData.officePhoneNumber).to.eql(expectedPhoneNumber);", - "});", - "", - "pm.test(\"Email matches\", function() {", - " var expectedEmail = pm.environment.get(\"randomEmail\");", - " pm.expect(jsonData.email).to.eql(expectedEmail);", - "});", - "", - "pm.test(\"Activity status matches\", function() {", - " var expectedIsActive = pm.environment.get(\"randomBoolean\");", - " pm.expect(jsonData.isActive).to.eql(expectedIsActive === \"true\");", - "});", - "", - "pm.test(\"Preferred language matches\", function() {", - " var expectedLanguage = pm.environment.get(\"randomLanguage\");", - " pm.expect(jsonData.preferredLanguage).to.eql(expectedLanguage);", - "});", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{domain}}employees/{{nextEmployeeId}}", - "host": [ - "{{domain}}employees" + "name": "Post Employees", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "var jsonData = JSON.parse(responseBody);", + "", + "tests[\"200 Unauthorized POST request\"] = responseCode.code === 200;", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "function pad(number, digits) {", + " return String(number).padStart(digits, '0');", + "}", + "", + "// Random year between 1980 and 2000", + "var randomYear = Math.floor(Math.random() * (2000 - 1980 + 1) + 1980);", + "", + "// Random month between 1 and 12", + "var randomMonth = Math.floor(Math.random() * 12) + 1;", + "", + "// Days per month (considering leap year for February)", + "var daysInMonth = [31, (randomYear % 4 === 0 && (randomYear % 100 !== 0 || randomYear % 400 === 0)) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];", + "", + "// Random day based on month", + "var randomDay = Math.floor(Math.random() * daysInMonth[randomMonth - 1]) + 1;", + "", + "// Random time components", + "var randomHour = Math.floor(Math.random() * 24);", + "var randomMinute = Math.floor(Math.random() * 60);", + "var randomSecond = Math.floor(Math.random() * 60);", + "var randomMillisecond = Math.floor(Math.random() * 10000000); // 7 digits", + "", + "// Construct the date string", + "var randomBirthDate = randomYear + '-' +", + " pad(randomMonth, 2) + '-' +", + " pad(randomDay, 2) + 'T' +", + " pad(randomHour, 2) + ':' +", + " pad(randomMinute, 2) + ':' +", + " pad(randomSecond, 2) + '.' +", + " pad(randomMillisecond, 7) + '+00:00';", + "", + "// Array of possible languages", + "var languages = [\"en\", \"fr\", \"de\", \"ht\", \"es\"];", + "var randomLanguage = languages[Math.floor(Math.random() * languages.length)];", + "", + "// Use Postman's built-in dynamic variables", + "var firstName = pm.variables.replaceIn(\"{{$randomFirstName}}\");", + "var lastName = pm.variables.replaceIn(\"{{$randomLastName}}\");", + "var phoneNumber = pm.variables.replaceIn(\"{{$randomPhoneNumber}}\");", + "var email = pm.variables.replaceIn(\"{{$randomEmail}}\");", + "var randomBoolean = pm.variables.replaceIn(\"{{$randomBoolean}}\"); // This will return \"true\" or \"false\" as a string", + "", + "// Set the environment variables", + "pm.environment.set(\"employeeName\", firstName + \" \" + lastName);", + "pm.environment.set(\"randomPhoneNumber\", phoneNumber);", + "pm.environment.set(\"randomBirthDate\", randomBirthDate);", + "pm.environment.set(\"randomEmail\", email);", + "pm.environment.set(\"randomBoolean\", randomBoolean);", + "pm.environment.set(\"randomLanguage\", randomLanguage);", + "" + ], + "type": "text/javascript" + } + } ], - "path": [ - "{{nextEmployeeId}}" - ] + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"id\": {{nextEmployeeId}},\n \"employeeCode\": \"{{$randomBankAccount}}\",\n \"name\": \"{{employeeName}}\",\n \"birthDate\": \"{{randomBirthDate}}\",\n \"officePhoneNumber\": \"{{randomPhoneNumber}}\",\n \"email\": \"{{randomEmail}}\",\n \"isActive\": {{$randomBoolean}},\n \"preferredLanguage\": \"{{randomLanguage}}\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{domain}}employees", + "host": [ + "{{domain}}employees" + ] + } + }, + "response": [] + }, + { + "name": "Verify Add", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "var jsonData = JSON.parse(responseBody);", + "", + "tests[\"Response code is 200 OK\"] = responseCode.code === 200;", + "", + "pm.test(\"Employee name matches\", function() {", + " var expectedName = pm.environment.get(\"employeeName\");", + " pm.expect(jsonData.name).to.eql(expectedName);", + "});", + "", + "pm.test(\"Birth date matches\", function() {", + " var expectedBirthDate = pm.environment.get(\"randomBirthDate\");", + " pm.expect(jsonData.birthDate).to.eql(expectedBirthDate);", + "});", + "", + "pm.test(\"Phone number matches\", function() {", + " var expectedPhoneNumber = pm.environment.get(\"randomPhoneNumber\");", + " pm.expect(jsonData.officePhoneNumber).to.eql(expectedPhoneNumber);", + "});", + "", + "pm.test(\"Email matches\", function() {", + " var expectedEmail = pm.environment.get(\"randomEmail\");", + " pm.expect(jsonData.email).to.eql(expectedEmail);", + "});", + "", + "pm.test(\"Activity status matches\", function() {", + " var expectedIsActive = pm.environment.get(\"randomBoolean\");", + " pm.expect(jsonData.isActive).to.eql(expectedIsActive === \"true\");", + "});", + "", + "pm.test(\"Preferred language matches\", function() {", + " var expectedLanguage = pm.environment.get(\"randomLanguage\");", + " pm.expect(jsonData.preferredLanguage).to.eql(expectedLanguage);", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{domain}}employees/{{nextEmployeeId}}", + "host": [ + "{{domain}}employees" + ], + "path": [ + "{{nextEmployeeId}}" + ] + } + }, + "response": [] } - }, - "response": [] + ] }, { - "name": "Delete Employees", - "event": [ + "name": "Update Employee", + "item": [ { - "listen": "test", - "script": { - "exec": [ - "var jsonData = JSON.parse(responseBody);", - "", - "tests[\"Response code is 200 OK\"] = responseCode.code === 200;", - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "DELETE", - "header": [], - "url": { - "raw": "{{domain}}employees/{{nextEmployeeId}}", - "host": [ - "{{domain}}employees" + "name": "Put Employees", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "var jsonData = JSON.parse(responseBody);", + "", + "tests[\"200 Unauthorized POST request\"] = responseCode.code === 200;", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "function pad(number, digits) {", + " return String(number).padStart(digits, '0');", + "}", + "", + "// Random year between 1980 and 2000", + "var randomYear = Math.floor(Math.random() * (2000 - 1980 + 1) + 1980);", + "", + "// Random month between 1 and 12", + "var randomMonth = Math.floor(Math.random() * 12) + 1;", + "", + "// Days per month (considering leap year for February)", + "var daysInMonth = [31, (randomYear % 4 === 0 && (randomYear % 100 !== 0 || randomYear % 400 === 0)) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];", + "", + "// Random day based on month", + "var randomDay = Math.floor(Math.random() * daysInMonth[randomMonth - 1]) + 1;", + "", + "// Random time components", + "var randomHour = Math.floor(Math.random() * 24);", + "var randomMinute = Math.floor(Math.random() * 60);", + "var randomSecond = Math.floor(Math.random() * 60);", + "var randomMillisecond = Math.floor(Math.random() * 10000000); // 7 digits", + "", + "// Construct the date string", + "var randomBirthDate = randomYear + '-' +", + " pad(randomMonth, 2) + '-' +", + " pad(randomDay, 2) + 'T' +", + " pad(randomHour, 2) + ':' +", + " pad(randomMinute, 2) + ':' +", + " pad(randomSecond, 2) + '.' +", + " pad(randomMillisecond, 7) + '+00:00';", + "", + "// Array of possible languages", + "var languages = [\"en\", \"fr\", \"de\", \"ht\", \"es\"];", + "var randomLanguage = languages[Math.floor(Math.random() * languages.length)];", + "", + "// Use Postman's built-in dynamic variables", + "var firstName = pm.variables.replaceIn(\"{{$randomFirstName}}\");", + "var lastName = pm.variables.replaceIn(\"{{$randomLastName}}\");", + "var phoneNumber = pm.variables.replaceIn(\"{{$randomPhoneNumber}}\");", + "var email = pm.variables.replaceIn(\"{{$randomEmail}}\");", + "var randomBoolean = pm.variables.replaceIn(\"{{$randomBoolean}}\"); // This will return \"true\" or \"false\" as a string", + "", + "// Set the environment variables", + "pm.environment.set(\"employeeName\", firstName + \" \" + lastName);", + "pm.environment.set(\"randomPhoneNumber\", phoneNumber);", + "pm.environment.set(\"randomBirthDate\", randomBirthDate);", + "pm.environment.set(\"randomEmail\", email);", + "pm.environment.set(\"randomBoolean\", randomBoolean);", + "pm.environment.set(\"randomLanguage\", randomLanguage);", + "" + ], + "type": "text/javascript" + } + } ], - "path": [ - "{{nextEmployeeId}}" - ] + "request": { + "method": "PUT", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"id\": {{nextEmployeeId}},\n \"employeeCode\": \"{{$randomBankAccount}}\",\n \"name\": \"{{employeeName}}\",\n \"birthDate\": \"{{randomBirthDate}}\",\n \"officePhoneNumber\": \"{{randomPhoneNumber}}\",\n \"email\": \"{{randomEmail}}\",\n \"isActive\": {{$randomBoolean}},\n \"preferredLanguage\": \"{{randomLanguage}}\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{domain}}employees", + "host": [ + "{{domain}}employees" + ] + } + }, + "response": [] + }, + { + "name": "Verify Update", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "var jsonData = JSON.parse(responseBody);", + "", + "tests[\"Response code is 200 OK\"] = responseCode.code === 200;", + "", + "pm.test(\"Employee name matches\", function() {", + " var expectedName = pm.environment.get(\"employeeName\");", + " pm.expect(jsonData.name).to.eql(expectedName);", + "});", + "", + "pm.test(\"Birth date matches\", function() {", + " var expectedBirthDate = pm.environment.get(\"randomBirthDate\");", + " pm.expect(jsonData.birthDate).to.eql(expectedBirthDate);", + "});", + "", + "pm.test(\"Phone number matches\", function() {", + " var expectedPhoneNumber = pm.environment.get(\"randomPhoneNumber\");", + " pm.expect(jsonData.officePhoneNumber).to.eql(expectedPhoneNumber);", + "});", + "", + "pm.test(\"Email matches\", function() {", + " var expectedEmail = pm.environment.get(\"randomEmail\");", + " pm.expect(jsonData.email).to.eql(expectedEmail);", + "});", + "", + "pm.test(\"Activity status matches\", function() {", + " var expectedIsActive = pm.environment.get(\"randomBoolean\");", + " pm.expect(jsonData.isActive).to.eql(expectedIsActive === \"true\");", + "});", + "", + "pm.test(\"Preferred language matches\", function() {", + " var expectedLanguage = pm.environment.get(\"randomLanguage\");", + " pm.expect(jsonData.preferredLanguage).to.eql(expectedLanguage);", + "});", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{domain}}employees/{{nextEmployeeId}}", + "host": [ + "{{domain}}employees" + ], + "path": [ + "{{nextEmployeeId}}" + ] + } + }, + "response": [] } - }, - "response": [] + ] + }, + { + "name": "Delete Employee", + "item": [ + { + "name": "Delete Employees", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "var jsonData = JSON.parse(responseBody);", + "", + "tests[\"Response code is 200 OK\"] = responseCode.code === 200;", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "DELETE", + "header": [], + "url": { + "raw": "{{domain}}employees/{{nextEmployeeId}}", + "host": [ + "{{domain}}employees" + ], + "path": [ + "{{nextEmployeeId}}" + ] + } + }, + "response": [] + } + ] } ] + }, + { + "name": "Questions", + "item": [ + { + "name": "Get Requests", + "item": [ + { + "name": "Get Questions", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "var jsonData = JSON.parse(responseBody);", + "", + "pm.test(\"No errors in Pre-request Script\", function () {", + " pm.expect(pm.environment.get(\"preRequestError\")).to.be.undefined;", + "});", + "", + "tests[\"200 Unauthorized POST request\"] = responseCode.code === 200;", + "pm.test(\"Response status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});", + "", + "", + "pm.test(\"Response is an array\", function () {", + " pm.expect(pm.response.json()).to.be.an('array');", + "});", + "", + "", + "pm.test(\"Check if id is a non-negative integer\", function () {", + " const responseData = pm.response.json();", + "", + " pm.expect(responseData).to.be.an('array').that.is.not.empty;", + "", + " responseData.forEach(function (question) {", + " pm.expect(question.id).to.be.a('number').that.is.greaterThan(-1);", + " });", + "});", + "", + "", + "pm.test(\"QuestionNumber is a non-negative integer\", function () {", + " const responseData = pm.response.json();", + "", + " pm.expect(responseData).to.be.an('array').and.to.have.lengthOf.at.least(1);", + "", + " responseData.forEach(function (question) {", + " pm.expect(question.questionNumber).to.be.a('number').and.to.be.at.least(0);", + " });", + "});", + "", + "", + "pm.test(\"surveyId is a non-negative integer\", function () {", + " const responseData = pm.response.json();", + "", + " pm.expect(responseData).to.be.an('array');", + "", + " responseData.forEach(function (question) {", + " pm.expect(question.surveyId).to.be.a('number');", + " pm.expect(question.surveyId).to.be.at.least(0);", + " });", + "});", + "", + "", + "", + "", + "pm.test(\"Response status code is 200\", function () {", + " pm.expect(pm.response.code).to.equal(200);", + "});", + "", + "", + "pm.test(\"Response is an array\", function () {", + " const responseData = pm.response.json();", + "", + " pm.expect(responseData).to.be.an('array');", + "});", + "", + "", + "pm.test(\"Each question has a non-negative integer id\", function () {", + " const responseData = pm.response.json();", + "", + " pm.expect(responseData).to.be.an('array');", + "", + " responseData.forEach(function (question) {", + " pm.expect(question.id).to.be.a('number');", + " pm.expect(question.id).to.be.at.least(0);", + " });", + "});", + "", + "", + "pm.test(\"Each question has a non-negative integer questionNumber\", function () {", + " const responseData = pm.response.json();", + "", + " pm.expect(responseData).to.be.an('array');", + " responseData.forEach(function (question) {", + " pm.expect(question.questionNumber).to.be.a('number');", + " pm.expect(question.questionNumber).to.be.at.least(0);", + " });", + "});", + "", + "", + "pm.test(\"Each question has a non-negative integer surveyId\", function () {", + " const responseData = pm.response.json();", + "", + " pm.expect(responseData).to.be.an('array');", + "", + " responseData.forEach(function (question) {", + " pm.expect(question.surveyId).to.be.a('number');", + " pm.expect(question.surveyId).to.be.at.least(0);", + " });", + "});", + "", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "if (!pm.environment.get(\"domain\")) {", + " console.error(\"Error: Domain is missing!\");", + "", + " // Set an error flag", + " pm.environment.set(\"preRequestError\", \"Domain is missing!\");", + "", + " // Change request URL to prevent it from sending", + " pm.request.url = \"http://invalid-url-to-prevent-sending.com\";", + "}" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{domain}}questions", + "host": [ + "{{domain}}questions" + ] + } + }, + "response": [] + }, + { + "name": "Get Questions By Language", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "var jsonData = JSON.parse(responseBody);", + "", + "pm.test(\"No errors in Pre-request Script\", function() {", + " pm.expect(pm.environment.get(\"preRequestError\")).to.be.undefined;", + "});", + "", + "tests[\"200 Unauthorized POST request\"] = responseCode.code === 200;", + "pm.test(\"Response status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "if (!pm.environment.get(\"domain\")) {", + " console.error(\"Error: Domain is missing!\");", + "", + " // Set an error flag", + " pm.environment.set(\"preRequestError\", \"Domain is missing!\");", + "", + " // Change request URL to prevent it from sending", + " pm.request.url = \"http://invalid-url-to-prevent-sending.com\";", + "}" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{domain}}questions/en", + "host": [ + "{{domain}}questions" + ], + "path": [ + "en" + ] + } + }, + "response": [] + }, + { + "name": "Get Questions By Id and Language", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "var jsonData = JSON.parse(responseBody);", + "", + "pm.test(\"No errors in Pre-request Script\", function() {", + " pm.expect(pm.environment.get(\"preRequestError\")).to.be.undefined;", + "});", + "", + "tests[\"200 Unauthorized POST request\"] = responseCode.code === 200;", + "pm.test(\"Response status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "if (!pm.environment.get(\"domain\")) {", + " console.error(\"Error: Domain is missing!\");", + "", + " // Set an error flag", + " pm.environment.set(\"preRequestError\", \"Domain is missing!\");", + "", + " // Change request URL to prevent it from sending", + " pm.request.url = \"http://invalid-url-to-prevent-sending.com\";", + "}" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{domain}}questions/1/en", + "host": [ + "{{domain}}questions" + ], + "path": [ + "1", + "en" + ] + } + }, + "response": [] + }, + { + "name": "Get Questions By Id", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "var jsonData = JSON.parse(responseBody);", + "", + "pm.test(\"No errors in Pre-request Script\", function() {", + " pm.expect(pm.environment.get(\"preRequestError\")).to.be.undefined;", + "});", + "", + "tests[\"200 Unauthorized POST request\"] = responseCode.code === 200;", + "pm.test(\"Response status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "if (!pm.environment.get(\"domain\")) {", + " console.error(\"Error: Domain is missing!\");", + "", + " // Set an error flag", + " pm.environment.set(\"preRequestError\", \"Domain is missing!\");", + "", + " // Change request URL to prevent it from sending", + " pm.request.url = \"http://invalid-url-to-prevent-sending.com\";", + "}" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{domain}}questions/1", + "host": [ + "{{domain}}questions" + ], + "path": [ + "1" + ] + } + }, + "response": [] + }, + { + "name": "Get Questions By Survey Id", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "var jsonData = JSON.parse(responseBody);", + "", + "pm.test(\"No errors in Pre-request Script\", function() {", + " pm.expect(pm.environment.get(\"preRequestError\")).to.be.undefined;", + "});", + "", + "tests[\"200 Unauthorized POST request\"] = responseCode.code === 200;", + "pm.test(\"Response status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "if (!pm.environment.get(\"domain\")) {", + " console.error(\"Error: Domain is missing!\");", + "", + " // Set an error flag", + " pm.environment.set(\"preRequestError\", \"Domain is missing!\");", + "", + " // Change request URL to prevent it from sending", + " pm.request.url = \"http://invalid-url-to-prevent-sending.com\";", + "}" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{domain}}questions/bysurvey/1", + "host": [ + "{{domain}}questions" + ], + "path": [ + "bysurvey", + "1" + ] + } + }, + "response": [] + }, + { + "name": "Get Questions By Survey Id and Language", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "var jsonData = JSON.parse(responseBody);", + "", + "pm.test(\"No errors in Pre-request Script\", function() {", + " pm.expect(pm.environment.get(\"preRequestError\")).to.be.undefined;", + "});", + "", + "tests[\"200 Unauthorized POST request\"] = responseCode.code === 200;", + "pm.test(\"Response status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "if (!pm.environment.get(\"domain\")) {", + " console.error(\"Error: Domain is missing!\");", + "", + " // Set an error flag", + " pm.environment.set(\"preRequestError\", \"Domain is missing!\");", + "", + " // Change request URL to prevent it from sending", + " pm.request.url = \"http://invalid-url-to-prevent-sending.com\";", + "}" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{domain}}questions/bysurvey/1/en", + "host": [ + "{{domain}}questions" + ], + "path": [ + "bysurvey", + "1", + "en" + ] + } + }, + "response": [] + }, + { + "name": "Get Questions Categories", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "var jsonData = JSON.parse(responseBody);", + "", + "pm.test(\"No errors in Pre-request Script\", function() {", + " pm.expect(pm.environment.get(\"preRequestError\")).to.be.undefined;", + "});", + "", + "tests[\"200 Unauthorized POST request\"] = responseCode.code === 200;", + "pm.test(\"Response status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "if (!pm.environment.get(\"domain\")) {", + " console.error(\"Error: Domain is missing!\");", + "", + " // Set an error flag", + " pm.environment.set(\"preRequestError\", \"Domain is missing!\");", + "", + " // Change request URL to prevent it from sending", + " pm.request.url = \"http://invalid-url-to-prevent-sending.com\";", + "}" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{domain}}questions/categories", + "host": [ + "{{domain}}questions" + ], + "path": [ + "categories" + ] + } + }, + "response": [] + }, + { + "name": "Get Questions Categories Language", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "var jsonData = JSON.parse(responseBody);", + "", + "pm.test(\"No errors in Pre-request Script\", function() {", + " pm.expect(pm.environment.get(\"preRequestError\")).to.be.undefined;", + "});", + "", + "tests[\"200 Unauthorized POST request\"] = responseCode.code === 200;", + "pm.test(\"Response status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "if (!pm.environment.get(\"domain\")) {", + " console.error(\"Error: Domain is missing!\");", + "", + " // Set an error flag", + " pm.environment.set(\"preRequestError\", \"Domain is missing!\");", + "", + " // Change request URL to prevent it from sending", + " pm.request.url = \"http://invalid-url-to-prevent-sending.com\";", + "}" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{domain}}questions/categories/en", + "host": [ + "{{domain}}questions" + ], + "path": [ + "categories", + "en" + ] + } + }, + "response": [] + }, + { + "name": "Get Questions Categories By Id", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "var jsonData = JSON.parse(responseBody);", + "", + "pm.test(\"No errors in Pre-request Script\", function() {", + " pm.expect(pm.environment.get(\"preRequestError\")).to.be.undefined;", + "});", + "", + "tests[\"200 Unauthorized POST request\"] = responseCode.code === 200;", + "pm.test(\"Response status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "if (!pm.environment.get(\"domain\")) {", + " console.error(\"Error: Domain is missing!\");", + "", + " // Set an error flag", + " pm.environment.set(\"preRequestError\", \"Domain is missing!\");", + "", + " // Change request URL to prevent it from sending", + " pm.request.url = \"http://invalid-url-to-prevent-sending.com\";", + "}" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{domain}}questions/categories/1", + "host": [ + "{{domain}}questions" + ], + "path": [ + "categories", + "1" + ] + } + }, + "response": [] + }, + { + "name": "Get Questions Categories By Id and Lanuage", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "var jsonData = JSON.parse(responseBody);", + "", + "pm.test(\"No errors in Pre-request Script\", function() {", + " pm.expect(pm.environment.get(\"preRequestError\")).to.be.undefined;", + "});", + "", + "tests[\"200 Unauthorized POST request\"] = responseCode.code === 200;", + "pm.test(\"Response status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "if (!pm.environment.get(\"domain\")) {", + " console.error(\"Error: Domain is missing!\");", + "", + " // Set an error flag", + " pm.environment.set(\"preRequestError\", \"Domain is missing!\");", + "", + " // Change request URL to prevent it from sending", + " pm.request.url = \"http://invalid-url-to-prevent-sending.com\";", + "}" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{domain}}questions/categories/en/1", + "host": [ + "{{domain}}questions" + ], + "path": [ + "categories", + "en", + "1" + ] + } + }, + "response": [] + } + ] + } + ] + }, + { + "name": "Locations", + "item": [] + }, + { + "name": "Surveys", + "item": [ + { + "name": "Get Requests", + "item": [ + { + "name": "Get Surveys", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "var jsonData = JSON.parse(responseBody);", + "", + "", + "pm.test(\"No errors in Pre-request Script\", function() {", + " pm.expect(pm.environment.get(\"preRequestError\")).to.be.undefined;", + "});", + "", + "", + "tests[\"Response code is 200 OK\"] = responseCode.code === 200;", + "", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "if (!pm.environment.get(\"domain\")) {", + " console.error(\"Error: Domain is missing!\");", + "", + " // Set an error flag", + " pm.environment.set(\"preRequestError\", \"Domain is missing!\");", + "", + " // Change request URL to prevent it from sending", + " pm.request.url = \"http://invalid-url-to-prevent-sending.com\";", + "}" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{domain}}surveys", + "host": [ + "{{domain}}surveys" + ] + } + }, + "response": [] + }, + { + "name": "Get Surveys By Language", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "var jsonData = JSON.parse(responseBody);", + "", + "", + "pm.test(\"No errors in Pre-request Script\", function() {", + " pm.expect(pm.environment.get(\"preRequestError\")).to.be.undefined;", + "});", + "", + "", + "tests[\"Response code is 200 OK\"] = responseCode.code === 200;", + "", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "if (!pm.environment.get(\"domain\")) {", + " console.error(\"Error: Domain is missing!\");", + "", + " // Set an error flag", + " pm.environment.set(\"preRequestError\", \"Domain is missing!\");", + "", + " // Change request URL to prevent it from sending", + " pm.request.url = \"http://invalid-url-to-prevent-sending.com\";", + "}" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{domain}}surveys/en", + "host": [ + "{{domain}}surveys" + ], + "path": [ + "en" + ] + } + }, + "response": [] + }, + { + "name": "Get Surveys By Id", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "var jsonData = JSON.parse(responseBody);", + "", + "", + "pm.test(\"No errors in Pre-request Script\", function() {", + " pm.expect(pm.environment.get(\"preRequestError\")).to.be.undefined;", + "});", + "", + "", + "tests[\"Response code is 200 OK\"] = responseCode.code === 200;", + "", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "if (!pm.environment.get(\"domain\")) {", + " console.error(\"Error: Domain is missing!\");", + "", + " // Set an error flag", + " pm.environment.set(\"preRequestError\", \"Domain is missing!\");", + "", + " // Change request URL to prevent it from sending", + " pm.request.url = \"http://invalid-url-to-prevent-sending.com\";", + "}" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{domain}}surveys/1", + "host": [ + "{{domain}}surveys" + ], + "path": [ + "1" + ] + } + }, + "response": [] + }, + { + "name": "Get Surveys By Id and Language", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "var jsonData = JSON.parse(responseBody);", + "", + "", + "pm.test(\"No errors in Pre-request Script\", function() {", + " pm.expect(pm.environment.get(\"preRequestError\")).to.be.undefined;", + "});", + "", + "", + "tests[\"Response code is 200 OK\"] = responseCode.code === 200;", + "", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "if (!pm.environment.get(\"domain\")) {", + " console.error(\"Error: Domain is missing!\");", + "", + " // Set an error flag", + " pm.environment.set(\"preRequestError\", \"Domain is missing!\");", + "", + " // Change request URL to prevent it from sending", + " pm.request.url = \"http://invalid-url-to-prevent-sending.com\";", + "}" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{domain}}surveys/1/en", + "host": [ + "{{domain}}surveys" + ], + "path": [ + "1", + "en" + ] + } + }, + "response": [] + } + ] + } + ] + }, + { + "name": "SurveyResponses", + "item": [ + { + "name": "Get Requests", + "item": [ + { + "name": "Get Responses", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "var jsonData = JSON.parse(responseBody);", + "", + "", + "pm.test(\"No errors in Pre-request Script\", function() {", + " pm.expect(pm.environment.get(\"preRequestError\")).to.be.undefined;", + "});", + "", + "", + "tests[\"Response code is 200 OK\"] = responseCode.code === 200;", + "", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "if (!pm.environment.get(\"domain\")) {", + " console.error(\"Error: Domain is missing!\");", + "", + " // Set an error flag", + " pm.environment.set(\"preRequestError\", \"Domain is missing!\");", + "", + " // Change request URL to prevent it from sending", + " pm.request.url = \"http://invalid-url-to-prevent-sending.com\";", + "}" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{domain}}responses", + "host": [ + "{{domain}}responses" + ] + } + }, + "response": [] + }, + { + "name": "Get Responses By Survey Id", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "var jsonData = JSON.parse(responseBody);", + "", + "", + "pm.test(\"No errors in Pre-request Script\", function() {", + " pm.expect(pm.environment.get(\"preRequestError\")).to.be.undefined;", + "});", + "", + "", + "tests[\"Response code is 200 OK\"] = responseCode.code === 200;", + "", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "if (!pm.environment.get(\"domain\")) {", + " console.error(\"Error: Domain is missing!\");", + "", + " // Set an error flag", + " pm.environment.set(\"preRequestError\", \"Domain is missing!\");", + "", + " // Change request URL to prevent it from sending", + " pm.request.url = \"http://invalid-url-to-prevent-sending.com\";", + "}" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{domain}}responses/bysurvey/1", + "host": [ + "{{domain}}responses" + ], + "path": [ + "bysurvey", + "1" + ] + } + }, + "response": [] + }, + { + "name": "Get Responses By Survey Id and Location Id", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "var jsonData = JSON.parse(responseBody);", + "", + "", + "pm.test(\"No errors in Pre-request Script\", function() {", + " pm.expect(pm.environment.get(\"preRequestError\")).to.be.undefined;", + "});", + "", + "", + "tests[\"Response code is 200 OK\"] = responseCode.code === 200;", + "", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "if (!pm.environment.get(\"domain\")) {", + " console.error(\"Error: Domain is missing!\");", + "", + " // Set an error flag", + " pm.environment.set(\"preRequestError\", \"Domain is missing!\");", + "", + " // Change request URL to prevent it from sending", + " pm.request.url = \"http://invalid-url-to-prevent-sending.com\";", + "}" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{domain}}responses/1/1", + "host": [ + "{{domain}}responses" + ], + "path": [ + "1", + "1" + ] + } + }, + "response": [] + }, + { + "name": "Get Responses Survey Id and Question Id and Answer Id", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "var jsonData = JSON.parse(responseBody);", + "", + "", + "pm.test(\"No errors in Pre-request Script\", function() {", + " pm.expect(pm.environment.get(\"preRequestError\")).to.be.undefined;", + "});", + "", + "", + "tests[\"Response code is 200 OK\"] = responseCode.code === 200;", + "", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "if (!pm.environment.get(\"domain\")) {", + " console.error(\"Error: Domain is missing!\");", + "", + " // Set an error flag", + " pm.environment.set(\"preRequestError\", \"Domain is missing!\");", + "", + " // Change request URL to prevent it from sending", + " pm.request.url = \"http://invalid-url-to-prevent-sending.com\";", + "}" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{domain}}responses/byanswer/1/1/1", + "host": [ + "{{domain}}responses" + ], + "path": [ + "byanswer", + "1", + "1", + "1" + ] + } + }, + "response": [] + }, + { + "name": "Get Responses By Region", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "var jsonData = JSON.parse(responseBody);", + "", + "", + "pm.test(\"No errors in Pre-request Script\", function() {", + " pm.expect(pm.environment.get(\"preRequestError\")).to.be.undefined;", + "});", + "", + "", + "tests[\"Response code is 200 OK\"] = responseCode.code === 200;", + "", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "if (!pm.environment.get(\"domain\")) {", + " console.error(\"Error: Domain is missing!\");", + "", + " // Set an error flag", + " pm.environment.set(\"preRequestError\", \"Domain is missing!\");", + "", + " // Change request URL to prevent it from sending", + " pm.request.url = \"http://invalid-url-to-prevent-sending.com\";", + "}" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{domain}}responses/byregion/1", + "host": [ + "{{domain}}responses" + ], + "path": [ + "byregion", + "1" + ] + } + }, + "response": [] + }, + { + "name": "Get Responses By Maintenance Center", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "var jsonData = JSON.parse(responseBody);", + "", + "", + "pm.test(\"No errors in Pre-request Script\", function() {", + " pm.expect(pm.environment.get(\"preRequestError\")).to.be.undefined;", + "});", + "", + "", + "tests[\"Response code is 200 OK\"] = responseCode.code === 200;", + "", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "if (!pm.environment.get(\"domain\")) {", + " console.error(\"Error: Domain is missing!\");", + "", + " // Set an error flag", + " pm.environment.set(\"preRequestError\", \"Domain is missing!\");", + "", + " // Change request URL to prevent it from sending", + " pm.request.url = \"http://invalid-url-to-prevent-sending.com\";", + "}" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{domain}}responses/bymaintenancecenter/1", + "host": [ + "{{domain}}responses" + ], + "path": [ + "bymaintenancecenter", + "1" + ] + } + }, + "response": [] + }, + { + "name": "Get Responses By Response Id", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "var jsonData = JSON.parse(responseBody);", + "", + "", + "pm.test(\"No errors in Pre-request Script\", function() {", + " pm.expect(pm.environment.get(\"preRequestError\")).to.be.undefined;", + "});", + "", + "", + "tests[\"Response code is 200 OK\"] = responseCode.code === 200;", + "", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "if (!pm.environment.get(\"domain\")) {", + " console.error(\"Error: Domain is missing!\");", + "", + " // Set an error flag", + " pm.environment.set(\"preRequestError\", \"Domain is missing!\");", + "", + " // Change request URL to prevent it from sending", + " pm.request.url = \"http://invalid-url-to-prevent-sending.com\";", + "}" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{domain}}responses/bymaintenancecenter/1", + "host": [ + "{{domain}}responses" + ], + "path": [ + "bymaintenancecenter", + "1" + ] + } + }, + "response": [] + } + ] + } + ] + }, + { + "name": "Attachments", + "item": [] + }, + { + "name": "UserAccess", + "item": [] } ] } \ No newline at end of file