From ad549f9638793f6add740e113db6d70c58a65c70 Mon Sep 17 00:00:00 2001 From: Nandan H A Date: Wed, 24 Jun 2020 13:52:41 +0000 Subject: [PATCH] Feature/locators update --- app/client/cypress/fixtures/testdata.json | 1 + .../ApiFlow/CurlImportFlow_spec.js | 4 ++-- .../ApiPaneTests/API_All_Verb_spec.js | 18 ++++++++++++++- .../ApiPaneTests/API_Edit_spec.js | 6 ++--- app/client/cypress/support/commands.js | 22 ++++--------------- 5 files changed, 27 insertions(+), 24 deletions(-) diff --git a/app/client/cypress/fixtures/testdata.json b/app/client/cypress/fixtures/testdata.json index 1793a8b9a7..e7ef26506d 100644 --- a/app/client/cypress/fixtures/testdata.json +++ b/app/client/cypress/fixtures/testdata.json @@ -31,6 +31,7 @@ "putAction": "//div[contains(@id,'react-select') and contains(text(),'PUT')]", "postAction": "//div[contains(@id,'react-select') and contains(text(),'POST')]", "patchAction": "//div[contains(@id,'react-select') and contains(text(),'PATCH')]", + "deleteAction": "//div[contains(@id,'react-select') and contains(text(),'DELETE')]", "moustacheMethod": "{{Api.text}}", "nextUrl": ".data.next}}", "prevUrl": ".data.previous}}" diff --git a/app/client/cypress/integration/Smoke_TestSuite/ApiFlow/CurlImportFlow_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ApiFlow/CurlImportFlow_spec.js index 656eb22f1f..78fe72d7b1 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/ApiFlow/CurlImportFlow_spec.js +++ b/app/client/cypress/integration/Smoke_TestSuite/ApiFlow/CurlImportFlow_spec.js @@ -20,13 +20,13 @@ describe("Test curl import flow", function() { expect(someText).to.equal(response.response.body.data.name); }); }); - // cy.WaitAutoSave(); + //cy.WaitAutoSave(); cy.RunAPI(); cy.ResponseStatusCheck("200 OK"); cy.get(ApiEditor.formActionButtons).should("be.visible"); cy.get(ApiEditor.ApiDeleteBtn).click(); cy.get(ApiEditor.ApiDeleteBtn).should("be.disabled"); - cy.testDeleteApi(); + cy.wait("@deleteAction"); cy.get("@deleteAction").then(response => { cy.expect(response.response.body.responseMeta.success).to.eq(true); }); diff --git a/app/client/cypress/integration/Smoke_TestSuite/ApiPaneTests/API_All_Verb_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ApiPaneTests/API_All_Verb_spec.js index bbd64c9b81..aa52f6d8b3 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/ApiPaneTests/API_All_Verb_spec.js +++ b/app/client/cypress/integration/Smoke_TestSuite/ApiPaneTests/API_All_Verb_spec.js @@ -89,6 +89,22 @@ describe("API Panel Test Functionality", function() { cy.log("Response data check successful"); }); + it("Delete Action test API fetaure", function() { + cy.CreateAPI("FirstAPI"); + cy.log("Creation of FirstAPI Action successful"); + cy.SelectAction(testdata.deleteAction); + cy.EnterSourceDetailsWithbody( + testdata.baseUrl2, + testdata.methodpatch, + testdata.headerKey, + testdata.headerValue, + ); + cy.WaitAutoSave(); + cy.RunAPI(); + cy.ResponseStatusCheck("204 NO_CONTENT"); + cy.log("Response code check successful"); + }); + it("Test GET Action for mock API with header and pagination", function() { const apiname = "FirstAPI"; cy.CreateAPI(apiname); @@ -138,7 +154,7 @@ describe("API Panel Test Functionality", function() { cy.log("Response data check successful"); }); - it.skip("API check with Invalid Header", function() { + it("API check with Invalid Header", function() { cy.CreateAPI("FirstAPI"); cy.log("Creation of SecondAPI Action successful"); cy.EnterSourceDetailsWithQueryParam( diff --git a/app/client/cypress/integration/Smoke_TestSuite/ApiPaneTests/API_Edit_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ApiPaneTests/API_Edit_spec.js index da8d3c1ee5..c18a6bdc62 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/ApiPaneTests/API_Edit_spec.js +++ b/app/client/cypress/integration/Smoke_TestSuite/ApiPaneTests/API_Edit_spec.js @@ -9,8 +9,8 @@ describe("API Panel Test Functionality", function() { cy.CreateAPI("FirstAPI"); cy.log("Creation of FirstAPI Action successful"); cy.EnterSourceDetailsWithHeader( - testdata.baseUrl2, - testdata.methods1, + testdata.baseUrl, + testdata.methods, testdata.headerKey, testdata.headerValue, ); @@ -24,7 +24,7 @@ describe("API Panel Test Functionality", function() { cy.ClearSearch(); cy.SearchAPIandClick("SecondAPI"); //invalid api end point check - cy.EditSourceDetail(testdata.baseUrl3, testdata.invalidPath); + cy.EditSourceDetail(testdata.baseUrl, testdata.invalidPath); cy.RunAPI(); cy.ResponseStatusCheck("404 NOT_FOUND"); cy.DeleteAPI(); diff --git a/app/client/cypress/support/commands.js b/app/client/cypress/support/commands.js index 6ebe260ead..9f8cd2e352 100644 --- a/app/client/cypress/support/commands.js +++ b/app/client/cypress/support/commands.js @@ -176,7 +176,7 @@ Cypress.Commands.add("CreateAPI", apiname => { .first() .click({ force: true }); cy.get(apiwidget.createapi).click({ force: true }); - cy.wait("@createNewApi"); + //cy.wait("@createNewApi"); //cy.wait("@getUser"); cy.get(apiwidget.resourceUrl).should("be.visible"); cy.xpath(apiwidget.EditApiName).click(); @@ -184,7 +184,7 @@ Cypress.Commands.add("CreateAPI", apiname => { .clear() .type(apiname) .should("have.value", apiname); - cy.WaitAutoSave(); + //cy.WaitAutoSave(); // Added because api name edit takes some time to // reflect in api sidebar after the call passes. cy.wait(4000); @@ -214,8 +214,8 @@ Cypress.Commands.add("EditApiName", apiname => { }); Cypress.Commands.add("WaitAutoSave", () => { - //cy.wait("@saveQuery"); - // cy.wait("@postExecute"); + cy.wait("@saveQuery"); + //cy.wait("@postExecute"); }); Cypress.Commands.add("RunAPI", () => { @@ -439,11 +439,6 @@ Cypress.Commands.add("DeleteAPI", apiname => { .first() .click({ force: true }); cy.get(apiwidget.delete).click({ force: true }); - cy.wait("@deleteAction").should( - "have.nested.property", - "response.body.responseMeta.status", - 200, - ); }); Cypress.Commands.add("CreateModal", () => { @@ -913,15 +908,6 @@ Cypress.Commands.add("testSaveDeleteDatasource", () => { ); }); -Cypress.Commands.add("testDeleteApi", () => { - cy.get(ApiEditor.createBlankApiCard).click({ force: true }); - cy.wait("@deleteAction").should( - "have.nested.property", - "response.body.responseMeta.status", - 200, - ); -}); - Cypress.Commands.add("importCurl", () => { cy.get(ApiEditor.curlImportBtn).click({ force: true }); cy.wait("@curlImport").should(