From dbe3c3194f45e3c21d67eb69990726e5be1073f0 Mon Sep 17 00:00:00 2001 From: Kenny Date: Mon, 31 Jul 2017 08:09:16 -0700 Subject: [PATCH] writing mock data test for pet --- test/e2e/db.json | 110 +++++++++++++++++- test/e2e/pages/main.js | 109 ++++++++++++++++- .../initial-render/informationContainer.js | 2 +- .../initial-render/operations/pet.js | 81 ++++++++++++- 4 files changed, 292 insertions(+), 10 deletions(-) diff --git a/test/e2e/db.json b/test/e2e/db.json index 74e92962..45d8b3f3 100644 --- a/test/e2e/db.json +++ b/test/e2e/db.json @@ -19,7 +19,115 @@ "status": "available" }, { - "id": 2, + "id": 3, + "category": { + "id": 0, + "name": "string" + }, + "name": "doggie", + "photoUrls": [ + "string" + ], + "tags": [ + { + "id": 0, + "name": "string" + } + ], + "status": "available" + }, + { + "id": 4, + "category": { + "id": 0, + "name": "string" + }, + "name": "doggie", + "photoUrls": [ + "string" + ], + "tags": [ + { + "id": 0, + "name": "string" + } + ], + "status": "available" + }, + { + "id": 5, + "category": { + "id": 0, + "name": "string" + }, + "name": "doggie", + "photoUrls": [ + "string" + ], + "tags": [ + { + "id": 0, + "name": "string" + } + ], + "status": "available" + }, + { + "id": 6, + "category": { + "id": 0, + "name": "string" + }, + "name": "doggie", + "photoUrls": [ + "string" + ], + "tags": [ + { + "id": 0, + "name": "string" + } + ], + "status": "available" + }, + { + "id": 7, + "category": { + "id": 0, + "name": "string" + }, + "name": "doggie", + "photoUrls": [ + "string" + ], + "tags": [ + { + "id": 0, + "name": "string" + } + ], + "status": "available" + }, + { + "id": 8, + "category": { + "id": 0, + "name": "string" + }, + "name": "doggie", + "photoUrls": [ + "string" + ], + "tags": [ + { + "id": 0, + "name": "string" + } + ], + "status": "available" + }, + { + "id": 9, "category": { "id": 0, "name": "string" diff --git a/test/e2e/pages/main.js b/test/e2e/pages/main.js index 7938f3a6..3f381bf0 100644 --- a/test/e2e/pages/main.js +++ b/test/e2e/pages/main.js @@ -117,6 +117,30 @@ module.exports = { petOperationPostExecuteBtn: { selector: ".swagger-ui .opblock-tag-section:nth-child(1) .opblock-post:nth-of-type(1) button.execute" }, + petOperationPostTryTextArea: { + selector: ".swagger-ui .opblock-tag-section:nth-child(1) .opblock-post:nth-of-type(1) textarea" + }, + petOperationPostResultsBox: { + selector: ".swagger-ui .opblock-tag-section:nth-child(1) .opblock-post:nth-of-type(1) pre.microlight" + }, + petOperationPostMockCategoryID: { + selector: ".swagger-ui .opblock-tag-section:nth-child(1) .opblock-post:nth-of-type(1) pre.microlight span:nth-child(17)" + }, + petOperationPostMockCategoryName: { + selector: ".swagger-ui .opblock-tag-section:nth-child(1) .opblock-post:nth-of-type(1) pre.microlight span:nth-child(23)" + }, + petOperationPostMockName: { + selector: ".swagger-ui .opblock-tag-section:nth-child(1) .opblock-post:nth-of-type(1) pre.microlight span:nth-child(31)" + }, + petOperationPostTagID: { + selector: ".swagger-ui .opblock-tag-section:nth-child(1) .opblock-post:nth-of-type(1) pre.microlight span:nth-child(54)" + }, + petOperationPostTagName: { + selector: ".swagger-ui .opblock-tag-section:nth-child(1) .opblock-post:nth-of-type(1) pre.microlight span:nth-child(60)" + }, + petOperationPostStatus: { + selector: ".swagger-ui .opblock-tag-section:nth-child(1) .opblock-post:nth-of-type(1) pre.microlight span:nth-child(70)" + }, /** * Put pet/ api */ @@ -141,6 +165,30 @@ module.exports = { petOperationPutExecuteBtn: { selector: ".swagger-ui .opblock-tag-section:nth-child(1) .opblock-put button.execute" }, + petOperationPutTryTextArea: { + selector: ".swagger-ui .opblock-tag-section:nth-child(1) .opblock-put textarea" + }, + petOperationPutResultsBox: { + selector: ".swagger-ui .opblock-tag-section:nth-child(1) .opblock-put pre.microlight" + }, + petOperationPutMockCategoryID: { + selector: ".swagger-ui .opblock-tag-section:nth-child(1) .opblock-put pre.microlight span:nth-child(17)" + }, + petOperationPutMockCategoryName: { + selector: ".swagger-ui .opblock-tag-section:nth-child(1) .opblock-put pre.microlight span:nth-child(23)" + }, + petOperationPutMockName: { + selector: ".swagger-ui .opblock-tag-section:nth-child(1) .opblock-put pre.microlight span:nth-child(31)" + }, + petOperationPutTagID: { + selector: ".swagger-ui .opblock-tag-section:nth-child(1) .opblock-put pre.microlight span:nth-child(54)" + }, + petOperationPutTagName: { + selector: ".swagger-ui .opblock-tag-section:nth-child(1) .opblock-put pre.microlight span:nth-child(60)" + }, + petOperationPutStatus: { + selector: ".swagger-ui .opblock-tag-section:nth-child(1) .opblock-put pre.microlight span:nth-child(70)" + }, /** * Get pet/ */ @@ -165,6 +213,31 @@ module.exports = { petOperationGetByTagExecuteBtn: { selector: ".swagger-ui .opblock-tag-section:nth-child(1) .opblock-deprecated button.execute" }, + petOperationGetByTagTryTextArea: { + selector: ".swagger-ui .opblock-tag-section:nth-child(1) .opblock-deprecated textarea" + }, + petOperationGetByTagResultsBox: { + selector: ".swagger-ui .opblock-tag-section:nth-child(1) .opblock-deprecated pre.microlight" + }, + petOperationGetByTagMockCategoryID: { + selector: ".swagger-ui .opblock-tag-section:nth-child(1) .opblock-deprecated pre.microlight span:nth-child(17)" + }, + petOperationGetByTagMockCategoryName: { + selector: ".swagger-ui .opblock-tag-section:nth-child(1) .opblock-deprecated pre.microlight span:nth-child(23)" + }, + petOperationGetByTagMockName: { + selector: ".swagger-ui .opblock-tag-section:nth-child(1) .opblock-deprecated pre.microlight span:nth-child(31)" + }, + petOperationGetByTagTagID: { + selector: ".swagger-ui .opblock-tag-section:nth-child(1) .opblock-deprecated pre.microlight span:nth-child(54)" + }, + petOperationGetByTagTagName: { + selector: ".swagger-ui .opblock-tag-section:nth-child(1) .opblock-deprecated pre.microlight span:nth-child(60)" + }, + petOperationGetByTagStatus: { + selector: ".swagger-ui .opblock-tag-section:nth-child(1) .opblock-deprecated pre.microlight span:nth-child(70)" + }, + /** * Delete pet/ */ @@ -186,6 +259,30 @@ module.exports = { petOperationDeleteExecuteBtn: { selector: ".swagger-ui .opblock-tag-section:nth-child(1) .opblock-delete button.execute" }, + petOperationDeleteTryTextArea: { + selector: ".swagger-ui .opblock-tag-section:nth-child(1) .opblock-delete textarea" + }, + petOperationDeleteResultsBox: { + selector: ".swagger-ui .opblock-tag-section:nth-child(1) .opblock-delete pre.microlight" + }, + petOperationDeleteMockCategoryID: { + selector: ".swagger-ui .opblock-tag-section:nth-child(1) .opblock-delete pre.microlight span:nth-child(17)" + }, + petOperationDeleteMockCategoryName: { + selector: ".swagger-ui .opblock-tag-section:nth-child(1) .opblock-delete pre.microlight span:nth-child(23)" + }, + petOperationDeleteMockName: { + selector: ".swagger-ui .opblock-tag-section:nth-child(1) .opblock-delete pre.microlight span:nth-child(31)" + }, + petOperationDeleteTagID: { + selector: ".swagger-ui .opblock-tag-section:nth-child(1) .opblock-delete pre.microlight span:nth-child(54)" + }, + petOperationDeleteTagName: { + selector: ".swagger-ui .opblock-tag-section:nth-child(1) .opblock-delete pre.microlight span:nth-child(60)" + }, + petOperationDeleteStatus: { + selector: ".swagger-ui .opblock-tag-section:nth-child(1) .opblock-delete pre.microlight span:nth-child(70)" + }, /** * ***********Store************ @@ -200,22 +297,22 @@ module.exports = { * Get /store/inventory */ storeOperationGetContainer: { - selector: ".swagger-ui .opblock-tag-section:nth-child(2) .opblock-get:nth-of-type(1)" + selector: ".swagger-ui .opblock-tag-section:nth-child(2) .opblock-get:nth-child(1)" }, storeOperationGetTitle: { - selector: ".swagger-ui .opblock-tag-section:nth-child(2) .opblock-get:nth-of-type(1) .opblock-summary-get span.opblock-summary-path span" + selector: ".swagger-ui .opblock-tag-section:nth-child(2) .opblock-get:nth-child(1) .opblock-summary-get span.opblock-summary-path span" }, storeOperationGetCollpase: { - selector: ".swagger-ui .opblock-tag-section:nth-child(2) .opblock-get:nth-of-type(1) .opblock-summary-get" + selector: ".swagger-ui .opblock-tag-section:nth-child(2) .opblock-get:nth-child(1) .opblock-summary-get" }, storeOperationGetCollapseContainer: { - selector: ".swagger-ui .opblock-tag-section:nth-child(2) .opblock-get:nth-of-type(1) .ReactCollapse--collapse" + selector: ".swagger-ui .opblock-tag-section:nth-child(2) .opblock-get:nth-child(1) .ReactCollapse--collapse" }, storeOperationGetTryBtn: { - selector: ".swagger-ui .opblock-tag-section:nth-child(2) .opblock-get:nth-of-type(1) button.try-out__btn" + selector: ".swagger-ui .opblock-tag-section:nth-child(2) .opblock-get:nth-child(1) button.try-out__btn" }, storeOperationGetExecuteBtn: { - selector: ".swagger-ui .opblock-tag-section:nth-child(2) .opblock-get:nth-of-type(1) button.execute" + selector: ".swagger-ui .opblock-tag-section:nth-child(2) .opblock-get:nth-child(1) button.execute" }, /** * Post /store/order diff --git a/test/e2e/scenarios/initial-render/informationContainer.js b/test/e2e/scenarios/initial-render/informationContainer.js index ed9f3c8d..4aebc045 100644 --- a/test/e2e/scenarios/initial-render/informationContainer.js +++ b/test/e2e/scenarios/initial-render/informationContainer.js @@ -19,7 +19,7 @@ describe("render informationContainer", function () { }) it("renders section", function (client) { - mainPage.expect.section("@informationContainer").to.be.visible.before(8000) + mainPage.expect.section("@informationContainer").to.be.visible.before(5000) client.end() }) diff --git a/test/e2e/scenarios/initial-render/operations/pet.js b/test/e2e/scenarios/initial-render/operations/pet.js index 8d0e78fa..454b66df 100644 --- a/test/e2e/scenarios/initial-render/operations/pet.js +++ b/test/e2e/scenarios/initial-render/operations/pet.js @@ -48,7 +48,26 @@ describe("render pet api container", function () { .waitForElementVisible("@petOperationPostExecuteBtn", 1000) .click("@petOperationPostTryBtn") .assert.cssClassNotPresent("@petOperationPostTryBtn", "cancel") - + + client.end() + }) + + it("Testing post /pet api Mock data", function (client) { + apiWrapper.waitForElementVisible("@petOperationPostContainer", 5000) + .click("@petOperationPostCollpase") + .waitForElementVisible("@petOperationPostCollapseContainer", 3000) + .click("@petOperationPostTryBtn") + .waitForElementVisible("@petOperationPostExecuteBtn", 1000) + .click("@petOperationPostExecuteBtn") + .waitForElementVisible("@petOperationPostMockCategoryID", 2000) + .assert.containsText("@petOperationPostMockCategoryID", "0") + .assert.containsText("@petOperationPostMockCategoryName", "\"string\"") + .assert.containsText("@petOperationPostMockName", "\"doggie\"") + .assert.containsText("@petOperationPostTagID", "0") + .assert.containsText("@petOperationPostTagName", "\"string\"") + .assert.containsText("@petOperationPostStatus", "\"available\"") + .click("@petOperationPostTryBtn") + .assert.cssClassNotPresent("@petOperationPostTryBtn", "cancel") client.end() }) @@ -64,11 +83,29 @@ describe("render pet api container", function () { .click("@petOperationPutTryBtn") .assert.cssClassNotPresent("@petOperationPutTryBtn", "cancel") + client.end() + }) + it("Testing put /pet api Mock data", function (client) { + apiWrapper.waitForElementVisible("@petOperationPutContainer", 5000) + .click("@petOperationPutCollpase") + .waitForElementVisible("@petOperationPutCollapseContainer", 3000) + .click("@petOperationPutTryBtn") + .waitForElementVisible("@petOperationPutExecuteBtn", 1000) + .click("@petOperationPutExecuteBtn") + .waitForElementVisible("@petOperationPutMockCategoryID") + .assert.containsText("@petOperationPutMockCategoryID", "0") + .assert.containsText("@petOperationPutMockCategoryName", "\"string\"") + .assert.containsText("@petOperationPutMockName", "\"doggie\"") + .assert.containsText("@petOperationPutTagID", "0") + .assert.containsText("@petOperationPutTagName", "\"string\"") + .assert.containsText("@petOperationPutStatus", "\"available\"") + .click("@petOperationPutTryBtn") + .assert.cssClassNotPresent("@petOperationPutTryBtn", "Cancel") client.end() }) - it("render get /pet api container", function (client) { + it("render get by tag /pet api container", function (client) { apiWrapper.waitForElementVisible("@petOperationGetByTagContainer", 5000) .assert.containsText("@petOperationGetByTagTitle", "/pet/findByTags") .click("@petOperationGetByTagCollpase") @@ -82,6 +119,26 @@ describe("render pet api container", function () { client.end() }) + it("Testing get by tag /pet api Mock data", function (client) { + apiWrapper.waitForElementVisible("@petOperationGetByTagContainer", 5000) + .click("@petOperationGetByTagCollpase") + .waitForElementVisible("@petOperationGetByTagCollapseContainer", 3000) + .click("@petOperationGetByTagTryBtn") + .waitForElementVisible("@petOperationGetByTagExecuteBtn", 1000) + .click("@petOperationGetByTagExecuteBtn") + .waitForElementVisible("@petOperationGetByTagMockCategoryID") + .assert.containsText("@petOperationGetByTagMockCategoryID", "0") + .assert.containsText("@petOperationGetByTagMockCategoryName", "\"string\"") + .assert.containsText("@petOperationGetByTagMockName", "\"doggie\"") + .assert.containsText("@petOpesrationGetByTagTagID", "0") + .assert.containsText("@petOperationGetByTagTagName", "\"string\"") + .assert.containsText("@petOperationGetByTagStatus", "\"available\"") + .click("@petOperationGetByTagTryBtn") + .assert.cssClassNotPresent("@petOperationGetByTagTryBtn", "cancel") + + client.end() + }) + it("render delete /pet api container", function (client) { apiWrapper.waitForElementVisible("@petOperationDeleteContainer", 5000) .assert.containsText("@petOperationDeleteTitle", "/pet/{petId}") @@ -94,4 +151,24 @@ describe("render pet api container", function () { client.end() }) + it("Testing delete /pet api Mock data", function (client) { + apiWrapper.waitForElementVisible("@petOperationDeleteContainer", 5000) + .click("@petOperationDeleteCollpase") + .waitForElementVisible("@petOperationDeleteCollapseContainer", 3000) + .click("@petOperationDeleteTryBtn") + .waitForElementVisible("@petOperationDeleteExecuteBtn", 1000) + .click("@petOperationDeleteExecuteBtn") + .waitForElementVisible("@petOperationDeleteMockCategoryID") + .assert.containsText("@petOperationDeleteMockCategoryID", "0") + .assert.containsText("@petOperationDeleteMockCategoryName", "\"string\"") + .assert.containsText("@petOperationDeleteMockName", "\"doggie\"") + .assert.containsText("@petOpesrationDeleteTagID", "0") + .assert.containsText("@petOperationDeleteTagName", "\"string\"") + .assert.containsText("@petOperationDeleteStatus", "\"available\"") + .click("@petOperationDeleteTryBtn") + .assert.cssClassNotPresent("@petOperationDeleteTryBtn", "cancel") + + client.end() + }) + }) \ No newline at end of file