From a102ca9d6fabb5dfbf2a9b8b820f497b6c85efb6 Mon Sep 17 00:00:00 2001 From: Nandan H A Date: Wed, 27 May 2020 11:21:11 +0000 Subject: [PATCH] Removed redundant tests. Added all verb tests to same spec file. Added pagination test. updated beforeEach in index file. --- app/client/cypress/fixtures/testdata.json | 4 +- .../ApiFlow/AddBlankApi_spec.js | 17 -- .../ApiFlow/CreateApiAndDelete_spec.js | 25 --- .../ApiFlow/CreateApiAndRun_spec.js | 33 ---- .../ApiFlow/CurlImportApiAndDelete_spec.js | 29 ---- .../ApiFlow/CurlImportApiAndRun.js | 35 ---- .../ApiFlow/CurlImportFlow_spec.js | 16 +- .../ApiPaneTests/API_All_Verb_spec.js | 152 ++++++++++++++++++ .../ApiPaneTests/API_Copy_spec.js | 13 -- .../ApiPaneTests/API_Delete_spec.js | 13 -- .../ApiPaneTests/API_Move_to_home.js | 13 -- .../ApiPaneTests/API_PUT_Action_spec.js | 31 ---- .../ApiPaneTests/API_Patch_Action_spec.js | 31 ---- .../ApiPaneTests/API_Post_Action_spec.js | 31 ---- .../ApiPaneTests/API_Query_spec.js | 39 ----- .../ApiPaneTests/API_With_Headers_spec.js | 23 --- ...ess.js => API_all_sidebar_actions_spec.js} | 8 +- .../CommonWidgets/Table_spec.js | 9 ++ .../cypress/locators/apiWidgetslocator.json | 11 +- app/client/cypress/support/commands.js | 113 +++++++++++++ app/client/cypress/support/index.js | 62 +------ 21 files changed, 312 insertions(+), 396 deletions(-) delete mode 100644 app/client/cypress/integration/Smoke_TestSuite/ApiFlow/AddBlankApi_spec.js delete mode 100644 app/client/cypress/integration/Smoke_TestSuite/ApiFlow/CreateApiAndDelete_spec.js delete mode 100644 app/client/cypress/integration/Smoke_TestSuite/ApiFlow/CreateApiAndRun_spec.js delete mode 100644 app/client/cypress/integration/Smoke_TestSuite/ApiFlow/CurlImportApiAndDelete_spec.js delete mode 100644 app/client/cypress/integration/Smoke_TestSuite/ApiFlow/CurlImportApiAndRun.js create mode 100644 app/client/cypress/integration/Smoke_TestSuite/ApiPaneTests/API_All_Verb_spec.js delete mode 100644 app/client/cypress/integration/Smoke_TestSuite/ApiPaneTests/API_Copy_spec.js delete mode 100644 app/client/cypress/integration/Smoke_TestSuite/ApiPaneTests/API_Delete_spec.js delete mode 100644 app/client/cypress/integration/Smoke_TestSuite/ApiPaneTests/API_Move_to_home.js delete mode 100644 app/client/cypress/integration/Smoke_TestSuite/ApiPaneTests/API_PUT_Action_spec.js delete mode 100644 app/client/cypress/integration/Smoke_TestSuite/ApiPaneTests/API_Patch_Action_spec.js delete mode 100644 app/client/cypress/integration/Smoke_TestSuite/ApiPaneTests/API_Post_Action_spec.js delete mode 100644 app/client/cypress/integration/Smoke_TestSuite/ApiPaneTests/API_Query_spec.js delete mode 100644 app/client/cypress/integration/Smoke_TestSuite/ApiPaneTests/API_With_Headers_spec.js rename app/client/cypress/integration/Smoke_TestSuite/ApiPaneTests/{API_Name_Uniqueness.js => API_all_sidebar_actions_spec.js} (63%) diff --git a/app/client/cypress/fixtures/testdata.json b/app/client/cypress/fixtures/testdata.json index f07f7d3492..fa12a4d4f8 100644 --- a/app/client/cypress/fixtures/testdata.json +++ b/app/client/cypress/fixtures/testdata.json @@ -30,5 +30,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')]", - "moustacheMethod": "{{Api.text}}" + "moustacheMethod": "{{Api.text}}", + "nextUrl": ".data.next}}", + "prevUrl": ".data.previous}}" } diff --git a/app/client/cypress/integration/Smoke_TestSuite/ApiFlow/AddBlankApi_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ApiFlow/AddBlankApi_spec.js deleted file mode 100644 index d8a1eb4420..0000000000 --- a/app/client/cypress/integration/Smoke_TestSuite/ApiFlow/AddBlankApi_spec.js +++ /dev/null @@ -1,17 +0,0 @@ -const ApiEditor = require("../../../locators/ApiEditor.json"); - -describe("Test Add blank API flow", function() { - it("Test Add blank API flow", function() { - localStorage.setItem("ApiPaneV2", "ApiPaneV2"); - cy.NavigateToApiEditor(); - cy.testCreateApiButton(); - cy.get("@createNewApi").then(response => { - cy.get(ApiEditor.ApiNameField).should("be.visible"); - cy.expect(response.response.body.responseMeta.success).to.eq(true); - cy.get(ApiEditor.ApiNameField).should( - "have.value", - response.response.body.data.name, - ); - }); - }); -}); diff --git a/app/client/cypress/integration/Smoke_TestSuite/ApiFlow/CreateApiAndDelete_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ApiFlow/CreateApiAndDelete_spec.js deleted file mode 100644 index 812b19f887..0000000000 --- a/app/client/cypress/integration/Smoke_TestSuite/ApiFlow/CreateApiAndDelete_spec.js +++ /dev/null @@ -1,25 +0,0 @@ -const ApiEditor = require("../../../locators/ApiEditor.json"); - -describe("Test Add blank API and delete flow", function() { - it("Test Add blank API and delete flow", function() { - localStorage.setItem("ApiPaneV2", "ApiPaneV2"); - cy.NavigateToApiEditor(); - cy.testCreateApiButton(); - cy.get("@createNewApi").then(httpResponse => { - cy.expect(httpResponse.response.body.responseMeta.success).to.eq(true); - cy.get(ApiEditor.ApiNameField).should( - "have.value", - httpResponse.response.body.data.name, - ); - }); - cy.get(ApiEditor.ApiNameField).should("be.visible"); - cy.get(ApiEditor.ApiDeleteBtn).click(); - cy.get(ApiEditor.ApiDeleteBtn).should("be.disabled"); - cy.testDeleteApi(); - cy.get(ApiEditor.ApiHomePage).should("be.visible"); - cy.get(ApiEditor.formActionButtons).should("not.be.visible"); - cy.get("@deleteAction").then(httpResponse => { - cy.expect(httpResponse.response.body.responseMeta.success).to.eq(true); - }); - }); -}); diff --git a/app/client/cypress/integration/Smoke_TestSuite/ApiFlow/CreateApiAndRun_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ApiFlow/CreateApiAndRun_spec.js deleted file mode 100644 index f7841d8fe8..0000000000 --- a/app/client/cypress/integration/Smoke_TestSuite/ApiFlow/CreateApiAndRun_spec.js +++ /dev/null @@ -1,33 +0,0 @@ -const ApiEditor = require("../../../locators/ApiEditor.json"); - -describe("Test Add api blank and execute api flow", function() { - it("Test Add blank api and execute api by selecting available datasource", function() { - localStorage.setItem("ApiPaneV2", "ApiPaneV2"); - cy.NavigateToApiEditor(); - cy.testCreateApiButton(); - cy.get("@createNewApi").then(response => { - cy.get(ApiEditor.ApiNameField).should("be.visible"); - cy.expect(response.response.body.responseMeta.success).to.eq(true); - cy.get(ApiEditor.ApiNameField).should( - "have.value", - response.response.body.data.name, - ); - }); - cy.get(ApiEditor.dataSourceField).click(); - cy.contains("https://jsonplaceholder.typicode.com/posts/1/comments").click({ - force: true, - }); - /* - cy.get(ApiEditor.ApiRunBtn).click(); - //cy.get(ApiEditor.ApiRunBtn).should("be.disabled"); - cy.wait("@postExecute").should( - "have.nested.property", - "response.body.responseMeta.status", - 200, - ); - */ - cy.SaveAPI(); - cy.get(ApiEditor.formActionButtons).should("be.visible"); - cy.get(ApiEditor.ApiRunBtn).should("not.be.disabled"); - }); -}); diff --git a/app/client/cypress/integration/Smoke_TestSuite/ApiFlow/CurlImportApiAndDelete_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ApiFlow/CurlImportApiAndDelete_spec.js deleted file mode 100644 index 4a325c0349..0000000000 --- a/app/client/cypress/integration/Smoke_TestSuite/ApiFlow/CurlImportApiAndDelete_spec.js +++ /dev/null @@ -1,29 +0,0 @@ -const ApiEditor = require("../../../locators/ApiEditor.json"); - -describe("Test curl import api and delete flow", function() { - it("Test curl import api and delete flow", function() { - localStorage.setItem("ApiPaneV2", "ApiPaneV2"); - cy.NavigateToApiEditor(); - cy.get(ApiEditor.curlImage).click({ force: true }); - cy.get("textarea").type( - "curl -X GET http://app.appsmith.com/scrap/api?slugifiedName=Freshdesk&ownerName=volodimir.kudriachenko", - ); - cy.importCurl(); - cy.get(ApiEditor.ApiNameField).should("be.visible"); - cy.get("@curlImport").then(response => { - cy.expect(response.response.body.responseMeta.success).to.eq(true); - cy.get(ApiEditor.ApiNameField).should( - "have.value", - response.response.body.data.name, - ); - }); - cy.get(ApiEditor.ApiDeleteBtn).click(); - cy.get(ApiEditor.ApiDeleteBtn).should("be.disabled"); - cy.testDeleteApi(); - cy.get("@deleteAction").then(response => { - cy.expect(response.response.body.responseMeta.success).to.eq(true); - }); - cy.get(ApiEditor.ApiHomePage).should("be.visible"); - cy.get(ApiEditor.formActionButtons).should("not.be.visible"); - }); -}); diff --git a/app/client/cypress/integration/Smoke_TestSuite/ApiFlow/CurlImportApiAndRun.js b/app/client/cypress/integration/Smoke_TestSuite/ApiFlow/CurlImportApiAndRun.js deleted file mode 100644 index ba22b38b20..0000000000 --- a/app/client/cypress/integration/Smoke_TestSuite/ApiFlow/CurlImportApiAndRun.js +++ /dev/null @@ -1,35 +0,0 @@ -const ApiEditor = require("../../../locators/ApiEditor.json"); - -describe("Test curl import api and run flow", function() { - it("Test curl import api and run flow", function() { - localStorage.setItem("ApiPaneV2", "ApiPaneV2"); - cy.NavigateToApiEditor(); - cy.get(ApiEditor.curlImage).click({ force: true }); - cy.get("textarea").type( - "curl -X GET http://app.appsmith.com/scrap/api?slugifiedName=Freshdesk&ownerName=volodimir.kudriachenko", - ); - cy.importCurl(); - cy.get(ApiEditor.ApiNameField).should("be.visible"); - cy.get("@curlImport").then(httpResponse => { - cy.expect(httpResponse.response.body.responseMeta.success).to.eq(true); - cy.get(ApiEditor.ApiNameField).should( - "have.value", - httpResponse.response.body.data.name, - ); - }); - /* - cy.get(ApiEditor.ApiRunBtn).click(); - cy.get(ApiEditor.ApiRunBtn).should("be.disabled"); - cy.wait("@postExecute").should( - "have.nested.property", - "response.body.responseMeta.status", - 200, - ); - */ - cy.SaveAPI(); - cy.get(ApiEditor.formActionButtons).should("be.visible"); - cy.get("@postExecute").then(httpResponse => { - cy.expect(httpResponse.response.body.responseMeta.success).to.eq(true); - }); - }); -}); 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 f5fb827bf2..76124cc9c9 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/ApiFlow/CurlImportFlow_spec.js +++ b/app/client/cypress/integration/Smoke_TestSuite/ApiFlow/CurlImportFlow_spec.js @@ -1,7 +1,8 @@ const ApiEditor = require("../../../locators/ApiEditor.json"); +const apiwidget = require("../../../locators/apiWidgetslocator.json"); describe("Test curl import flow", function() { - it("Test curl import flow", function() { + it("Test curl import flow Run and Delete", function() { localStorage.setItem("ApiPaneV2", "ApiPaneV2"); cy.NavigateToApiEditor(); cy.get(ApiEditor.curlImage).click({ force: true }); @@ -17,5 +18,18 @@ describe("Test curl import flow", function() { response.response.body.data.name, ); }); + cy.SaveAPI(); + cy.get(ApiEditor.formActionButtons).should("be.visible"); + cy.get("@postExecute").then(httpResponse => { + cy.expect(httpResponse.response.body.responseMeta.success).to.eq(true); + }); + cy.get(ApiEditor.ApiDeleteBtn).click(); + cy.get(ApiEditor.ApiDeleteBtn).should("be.disabled"); + cy.testDeleteApi(); + cy.get("@deleteAction").then(response => { + cy.expect(response.response.body.responseMeta.success).to.eq(true); + }); + cy.get(ApiEditor.ApiHomePage).should("be.visible"); + cy.get(ApiEditor.formActionButtons).should("not.be.visible"); }); }); 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 new file mode 100644 index 0000000000..7a5ed07a57 --- /dev/null +++ b/app/client/cypress/integration/Smoke_TestSuite/ApiPaneTests/API_All_Verb_spec.js @@ -0,0 +1,152 @@ +const testdata = require("../../../fixtures/testdata.json"); +const apiwidget = require("../../../locators/apiWidgetslocator.json"); + +describe("API Panel Test Functionality", function() { + afterEach(function() { + cy.get(".t--apiFormDeleteBtn").click(); + cy.wait("@deleteAction").should( + "have.nested.property", + "response.body.responseMeta.status", + 200, + ); + }); + + it("PUT Action test API fetaure", function() { + cy.log("Login Successful"); + cy.NavigateToAPI_Panel(); + cy.log("Navigation to API Panel screen successful"); + cy.CreateAPI("FirstAPI"); + cy.log("Creation of FirstAPI Action successful"); + cy.SelectAction(testdata.putAction); + cy.EnterSourceDetailsWithbody( + testdata.baseUrl2, + testdata.methodput, + testdata.headerKey, + testdata.headerValue, + ); + cy.readFile("cypress/fixtures/putjson.txt").then(json => { + cy.log(json); + cy.xpath(apiwidget.postbody) + .click({ force: true }) + .focus() + .type(json, { force: true }); + }); + cy.SaveAPI(); + cy.ResponseStatusCheck("200 OK"); + cy.log("Response code check successful"); + cy.ResponseCheck("updatedAt"); + cy.log("Response data check successful"); + }); + + it("Post Action test API fetaure", function() { + cy.CreateSubsequentAPI("FirstAPI"); + cy.log("Creation of FirstAPI Action successful"); + cy.SelectAction(testdata.postAction); + cy.EnterSourceDetailsWithbody( + testdata.baseUrl2, + testdata.methodpost, + testdata.headerKey, + testdata.headerValue, + ); + cy.readFile("cypress/fixtures/postjson.txt").then(json => { + cy.log(json); + cy.xpath(apiwidget.postbody) + .click({ force: true }) + .focus() + .type(json, { force: true }); + }); + cy.SaveAPI(); + cy.ResponseStatusCheck("201 CREATED"); + cy.log("Response code check successful"); + cy.ResponseCheck("createdAt"); + cy.log("Response data check successful"); + }); + + it("PATCH Action test API fetaure", function() { + cy.CreateSubsequentAPI("FirstAPI"); + cy.log("Creation of FirstAPI Action successful"); + cy.SelectAction(testdata.patchAction); + cy.EnterSourceDetailsWithbody( + testdata.baseUrl2, + testdata.methodpatch, + testdata.headerKey, + testdata.headerValue, + ); + cy.readFile("cypress/fixtures/patchjson.txt").then(json => { + cy.log(json); + cy.xpath(apiwidget.postbody) + .click({ force: true }) + .focus() + .type(json, { force: true }); + }); + cy.SaveAPI(); + cy.ResponseStatusCheck("200 OK"); + cy.log("Response code check successful"); + cy.ResponseCheck("updatedAt"); + cy.log("Response data check successful"); + }); + + it("Test GET Action for mock API with header and pagination", function() { + const apiname = "FirstAPI"; + cy.CreateSubsequentAPI(apiname); + cy.log("Creation of API Action successful"); + cy.EnterSourceDetailsWithHeader( + testdata.baseUrl, + testdata.methods, + testdata.headerKey, + testdata.headerValue, + ); + cy.ResponseStatusCheck(testdata.successStatusCode); + cy.log("Response code check successful"); + cy.ResponseCheck(testdata.responsetext); + cy.log("Response data check successful"); + cy.switchToPaginationTab(); + cy.selectPaginationType(apiwidget.paginationWithUrl); + cy.enterUrl(apiname, apiwidget.panigationNextUrl, testdata.nextUrl); + cy.clickTest(apiwidget.TestNextUrl); + cy.ResponseStatusCheck(testdata.successStatusCode); + cy.log("Response code check successful"); + cy.ResponseCheck("Josh M Krantz"); + cy.log("Response data check successful"); + cy.enterUrl(apiname, apiwidget.panigationPrevUrl, testdata.prevUrl); + cy.clickTest(apiwidget.TestPreUrl); + cy.ResponseStatusCheck(testdata.successStatusCode); + cy.log("Response code check successful"); + cy.ResponseCheck(testdata.responsetext); + cy.log("Response data check successful"); + }); + + it("API check with query params test API fetaure", function() { + cy.CreateSubsequentAPI("FirstAPI"); + cy.log("Creation of FirstAPI Action successful"); + cy.EnterSourceDetailsWithQueryParam( + testdata.baseUrl, + testdata.methods, + testdata.headerKey, + testdata.headerValue, + testdata.queryKey, + testdata.queryValue, + ); + cy.ResponseStatusCheck("200 OK"); + cy.log("Response code check successful"); + cy.ResponseCheck(testdata.responsetext3); + cy.log("Response data check successful"); + }); + + it("API check with Invalid Header", function() { + cy.CreateSubsequentAPI("FirstAPI"); + cy.log("Creation of SecondAPI Action successful"); + cy.EnterSourceDetailsWithQueryParam( + testdata.baseUrl, + testdata.methods, + testdata.headerKey, + testdata.headerValueBlank, + testdata.queryKey, + testdata.queryValue, + ); + cy.ResponseStatusCheck("5000"); + cy.log("Response code check successful"); + cy.ResponseCheck("Invalid value for Content-Type"); + cy.log("Response data check successful"); + }); +}); diff --git a/app/client/cypress/integration/Smoke_TestSuite/ApiPaneTests/API_Copy_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ApiPaneTests/API_Copy_spec.js deleted file mode 100644 index ad0ba14ca2..0000000000 --- a/app/client/cypress/integration/Smoke_TestSuite/ApiPaneTests/API_Copy_spec.js +++ /dev/null @@ -1,13 +0,0 @@ -const testdata = require("../../../fixtures/testdata.json"); - -describe("API Panel Test Functionality ", function() { - it("Test API copy fetaure", function() { - cy.log("Login Successful"); - cy.viewport("macbook-15"); //To avoid screen Resize issues - cy.NavigateToAPI_Panel(); - cy.log("Navigation to API Panel screen successful"); - cy.CreateAPI("FirstAPI"); - cy.log("Creation of FirstAPI Action successful"); - cy.CopyAPIToHome("FirstAPI"); - }); -}); diff --git a/app/client/cypress/integration/Smoke_TestSuite/ApiPaneTests/API_Delete_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ApiPaneTests/API_Delete_spec.js deleted file mode 100644 index 13f89283ef..0000000000 --- a/app/client/cypress/integration/Smoke_TestSuite/ApiPaneTests/API_Delete_spec.js +++ /dev/null @@ -1,13 +0,0 @@ -const testdata = require("../../../fixtures/testdata.json"); - -describe("API Panel Test Functionality ", function() { - it("Test API delete fetaure", function() { - cy.log("Login Successful"); - cy.viewport("macbook-15"); //To avoid screen Resize issues - cy.NavigateToAPI_Panel(); - cy.log("Navigation to API Panel screen successful"); - cy.CreateAPI("FirstAPI"); - cy.log("Creation of FirstAPI Action successful"); - cy.DeleteAPI("FirstAPI"); - }); -}); diff --git a/app/client/cypress/integration/Smoke_TestSuite/ApiPaneTests/API_Move_to_home.js b/app/client/cypress/integration/Smoke_TestSuite/ApiPaneTests/API_Move_to_home.js deleted file mode 100644 index fb2854b4d6..0000000000 --- a/app/client/cypress/integration/Smoke_TestSuite/ApiPaneTests/API_Move_to_home.js +++ /dev/null @@ -1,13 +0,0 @@ -const testdata = require("../../../fixtures/testdata.json"); - -describe("API Panel Test Functionality ", function() { - it("Test API Move To Home fetaure", function() { - cy.log("Login Successful"); - cy.viewport("macbook-15"); //To avoid screen Resize issues - cy.NavigateToAPI_Panel(); - cy.log("Navigation to API Panel screen successful"); - cy.CreateAPI("FirstAPI"); - cy.log("Creation of FirstAPI Action successful"); - cy.MoveAPIToHome("FirstAPI"); - }); -}); diff --git a/app/client/cypress/integration/Smoke_TestSuite/ApiPaneTests/API_PUT_Action_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ApiPaneTests/API_PUT_Action_spec.js deleted file mode 100644 index 476cb149f3..0000000000 --- a/app/client/cypress/integration/Smoke_TestSuite/ApiPaneTests/API_PUT_Action_spec.js +++ /dev/null @@ -1,31 +0,0 @@ -const testdata = require("../../../fixtures/testdata.json"); -const apiwidget = require("../../../locators/apiWidgetslocator.json"); - -describe("API Panel Test Functionality", function() { - it("PUT Action test API fetaure", function() { - cy.log("Login Successful"); - cy.NavigateToAPI_Panel(); - cy.log("Navigation to API Panel screen successful"); - cy.CreateAPI("FirstAPI"); - cy.log("Creation of FirstAPI Action successful"); - cy.SelectAction(testdata.putAction); - cy.EnterSourceDetailsWithbody( - testdata.baseUrl2, - testdata.methodput, - testdata.headerKey, - testdata.headerValue, - ); - cy.readFile("cypress/fixtures/putjson.txt").then(json => { - cy.log(json); - cy.xpath(apiwidget.postbody) - .click({ force: true }) - .focus() - .type(json, { force: true }); - }); - cy.SaveAPI(); - cy.ResponseStatusCheck("200 OK"); - cy.log("Response code check successful"); - cy.ResponseCheck("updatedAt"); - cy.log("Response data check successful"); - }); -}); diff --git a/app/client/cypress/integration/Smoke_TestSuite/ApiPaneTests/API_Patch_Action_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ApiPaneTests/API_Patch_Action_spec.js deleted file mode 100644 index a410b35463..0000000000 --- a/app/client/cypress/integration/Smoke_TestSuite/ApiPaneTests/API_Patch_Action_spec.js +++ /dev/null @@ -1,31 +0,0 @@ -const testdata = require("../../../fixtures/testdata.json"); -const apiwidget = require("../../../locators/apiWidgetslocator.json"); - -describe("API Panel Test Functionality", function() { - it("PATCH Action test API fetaure", function() { - cy.log("Login Successful"); - cy.NavigateToAPI_Panel(); - cy.log("Navigation to API Panel screen successful"); - cy.CreateAPI("FirstAPI"); - cy.log("Creation of FirstAPI Action successful"); - cy.SelectAction(testdata.patchAction); - cy.EnterSourceDetailsWithbody( - testdata.baseUrl2, - testdata.methodpatch, - testdata.headerKey, - testdata.headerValue, - ); - cy.readFile("cypress/fixtures/patchjson.txt").then(json => { - cy.log(json); - cy.xpath(apiwidget.postbody) - .click({ force: true }) - .focus() - .type(json, { force: true }); - }); - cy.SaveAPI(); - cy.ResponseStatusCheck("200 OK"); - cy.log("Response code check successful"); - cy.ResponseCheck("updatedAt"); - cy.log("Response data check successful"); - }); -}); diff --git a/app/client/cypress/integration/Smoke_TestSuite/ApiPaneTests/API_Post_Action_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ApiPaneTests/API_Post_Action_spec.js deleted file mode 100644 index 14ce4af57f..0000000000 --- a/app/client/cypress/integration/Smoke_TestSuite/ApiPaneTests/API_Post_Action_spec.js +++ /dev/null @@ -1,31 +0,0 @@ -const testdata = require("../../../fixtures/testdata.json"); -const apiwidget = require("../../../locators/apiWidgetslocator.json"); - -describe("API Panel Test Functionality", function() { - it("Post Action test API fetaure", function() { - cy.log("Login Successful"); - cy.NavigateToAPI_Panel(); - cy.log("Navigation to API Panel screen successful"); - cy.CreateAPI("FirstAPI"); - cy.log("Creation of FirstAPI Action successful"); - cy.SelectAction(testdata.postAction); - cy.EnterSourceDetailsWithbody( - testdata.baseUrl2, - testdata.methodpost, - testdata.headerKey, - testdata.headerValue, - ); - cy.readFile("cypress/fixtures/postjson.txt").then(json => { - cy.log(json); - cy.xpath(apiwidget.postbody) - .click({ force: true }) - .focus() - .type(json, { force: true }); - }); - cy.SaveAPI(); - cy.ResponseStatusCheck("201 CREATED"); - cy.log("Response code check successful"); - cy.ResponseCheck("createdAt"); - cy.log("Response data check successful"); - }); -}); diff --git a/app/client/cypress/integration/Smoke_TestSuite/ApiPaneTests/API_Query_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ApiPaneTests/API_Query_spec.js deleted file mode 100644 index 27b74ac899..0000000000 --- a/app/client/cypress/integration/Smoke_TestSuite/ApiPaneTests/API_Query_spec.js +++ /dev/null @@ -1,39 +0,0 @@ -const testdata = require("../../../fixtures/testdata.json"); -const apiwidget = require("../../../locators/apiWidgetslocator.json"); - -describe("API Panel Test Functionality", function() { - it("API check with query params test API fetaure", function() { - cy.log("Login Successful"); - cy.NavigateToAPI_Panel(); - cy.log("Navigation to API Panel screen successful"); - cy.CreateAPI("FirstAPI"); - cy.log("Creation of FirstAPI Action successful"); - cy.EnterSourceDetailsWithQueryParam( - testdata.baseUrl, - testdata.methods, - testdata.headerKey, - testdata.headerValue, - testdata.queryKey, - testdata.queryValue, - ); - cy.ResponseStatusCheck("200 OK"); - cy.log("Response code check successful"); - cy.ResponseCheck(testdata.responsetext3); - cy.log("Response data check successful"); - cy.DeleteAPI(); - cy.CreateAPI("SecondAPI"); - cy.log("Creation of SecondAPI Action successful"); - cy.EnterSourceDetailsWithQueryParam( - testdata.baseUrl, - testdata.methods, - testdata.headerKey, - testdata.headerValueBlank, - testdata.queryKey, - testdata.queryValue, - ); - cy.ResponseStatusCheck("5000"); - cy.log("Response code check successful"); - cy.ResponseCheck("Invalid value for Content-Type"); - cy.log("Response data check successful"); - }); -}); diff --git a/app/client/cypress/integration/Smoke_TestSuite/ApiPaneTests/API_With_Headers_spec.js b/app/client/cypress/integration/Smoke_TestSuite/ApiPaneTests/API_With_Headers_spec.js deleted file mode 100644 index 3a48b346c6..0000000000 --- a/app/client/cypress/integration/Smoke_TestSuite/ApiPaneTests/API_With_Headers_spec.js +++ /dev/null @@ -1,23 +0,0 @@ -/// -const testdata = require("../../../fixtures/testdata.json"); - -describe("API Panel Test Functionality ", function() { - it("Test GET Action for mock API with header", function() { - cy.log("Login Successful"); - cy.viewport("macbook-15"); - cy.NavigateToAPI_Panel(); - cy.log("Navigation to API Panel screen successful"); - cy.CreateAPI("TestAPINew"); - cy.log("Creation of API Action successful"); - cy.EnterSourceDetailsWithHeader( - testdata.baseUrl, - testdata.methods, - testdata.headerKey, - testdata.headerValue, - ); - cy.ResponseStatusCheck(testdata.successStatusCode); - cy.log("Response code check successful"); - cy.ResponseCheck(testdata.responsetext); - cy.log("Response data check successful"); - }); -}); diff --git a/app/client/cypress/integration/Smoke_TestSuite/ApiPaneTests/API_Name_Uniqueness.js b/app/client/cypress/integration/Smoke_TestSuite/ApiPaneTests/API_all_sidebar_actions_spec.js similarity index 63% rename from app/client/cypress/integration/Smoke_TestSuite/ApiPaneTests/API_Name_Uniqueness.js rename to app/client/cypress/integration/Smoke_TestSuite/ApiPaneTests/API_all_sidebar_actions_spec.js index 85b3b1dacf..36e8eee5ee 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/ApiPaneTests/API_Name_Uniqueness.js +++ b/app/client/cypress/integration/Smoke_TestSuite/ApiPaneTests/API_all_sidebar_actions_spec.js @@ -1,13 +1,19 @@ const testdata = require("../../../fixtures/testdata.json"); describe("API Panel Test Functionality ", function() { - it("Test API Name uniqueness fetaure", function() { + it("Test API copy/Move/delete feature", function() { cy.log("Login Successful"); cy.viewport("macbook-15"); //To avoid screen Resize issues cy.NavigateToAPI_Panel(); cy.log("Navigation to API Panel screen successful"); cy.CreateAPI("FirstAPI"); cy.log("Creation of FirstAPI Action successful"); + cy.CopyAPIToHome("FirstAPI"); + cy.DeleteAPI("FirstAPI"); + cy.MoveAPIToPage(); + cy.DeleteAPI("FirstAPI"); + cy.CreateAPI("FirstAPI"); + cy.log("Creation of FirstAPI Action successful"); cy.CreationOfUniqueAPIcheck("FirstAPI"); }); }); diff --git a/app/client/cypress/integration/Smoke_TestSuite/CommonWidgets/Table_spec.js b/app/client/cypress/integration/Smoke_TestSuite/CommonWidgets/Table_spec.js index db690b04a4..ac9dba8c88 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/CommonWidgets/Table_spec.js +++ b/app/client/cypress/integration/Smoke_TestSuite/CommonWidgets/Table_spec.js @@ -32,3 +32,12 @@ describe("Table Widget Functionality", function() { // put your clean up code if any }); }); + +Cypress.on("test:after:run", attributes => { + /* eslint-disable no-console */ + console.log( + 'Test "%s" has finished in %dms', + attributes.title, + attributes.duration, + ); +}); diff --git a/app/client/cypress/locators/apiWidgetslocator.json b/app/client/cypress/locators/apiWidgetslocator.json index a6b59b9f90..4e6ae0f353 100644 --- a/app/client/cypress/locators/apiWidgetslocator.json +++ b/app/client/cypress/locators/apiWidgetslocator.json @@ -23,5 +23,14 @@ "marketPlaceapi": ".t--eachProviderCard p", "addPageButton": ".t--addToPageBtn", "apidocumentaionLink": ".linkStyles", - "postbody": "(//div[contains(@class,'CodeMirror-wrap')]//textarea)[1]" + "postbody": "(//div[contains(@class,'CodeMirror-wrap')]//textarea)[1]", + "paginationTab": "li:contains('Pagination')", + "apiInputTab": "li:contains('API Input')", + "paginationOption": ".t--apiFormPaginationType div>input", + "paginationWithTable": "//div[contains(@id,'react') and contains(text(),'Paginate with Table Page No')] ", + "paginationWithUrl": "//div[contains(@id,'react') and contains(text(),'Paginate with Response Url')]", + "panigationNextUrl": ".t--apiFormPaginationNext div>textarea", + "panigationPrevUrl": ".t--apiFormPaginationPrev div>textarea", + "TestNextUrl": ".t--apiFormPaginationNextTest", + "TestPreUrl": ".t--apiFormPaginationPrevTest" } \ No newline at end of file diff --git a/app/client/cypress/support/commands.js b/app/client/cypress/support/commands.js index 3bb7817b02..affb1c0560 100644 --- a/app/client/cypress/support/commands.js +++ b/app/client/cypress/support/commands.js @@ -11,6 +11,7 @@ const LayoutPage = require("../locators/Layout.json"); const formWidgetsPage = require("../locators/FormWidgets.json"); const ApiEditor = require("../locators/ApiEditor.json"); const apiwidget = require("../locators/apiWidgetslocator.json"); +let pageidcopy = " "; Cypress.Commands.add("CreateApp", appname => { cy.get(homePage.CreateApp) @@ -241,6 +242,40 @@ Cypress.Commands.add("EditSourceDetail", (baseUrl, v1method) => { cy.SaveAPI(); }); +Cypress.Commands.add("switchToPaginationTab", () => { + cy.get(apiwidget.paginationTab) + .first() + .click({ force: true }); +}); + +Cypress.Commands.add("switchToAPIInputTab", () => { + cy.get(apiwidget.apiInputTab) + .first() + .click({ force: true }); +}); + +Cypress.Commands.add("selectPaginationType", option => { + cy.get(apiwidget.paginationOption) + .first() + .click({ force: true }); + cy.xpath(option).click({ force: true }); +}); + +Cypress.Commands.add("clickTest", testbutton => { + cy.get(testbutton) + .first() + .click({ force: true }); +}); + +Cypress.Commands.add("enterUrl", (apiname, url, value) => { + cy.get(url) + .first() + .type("{{".concat(apiname).concat(value), { + force: true, + parseSpecialCharSequences: false, + }); +}); + Cypress.Commands.add( "EnterSourceDetailsWithQueryParam", (baseUrl, v1method, hKey, hValue, qKey, qValue) => { @@ -309,6 +344,21 @@ Cypress.Commands.add("MoveAPIToHome", apiname => { ); }); +Cypress.Commands.add("MoveAPIToPage", () => { + cy.get(apiwidget.popover) + .first() + .click({ force: true }); + cy.get(apiwidget.moveTo).click({ force: true }); + cy.get( + ".single-select >div:contains('".concat(pageidcopy).concat("')"), + ).click({ force: true }); + cy.wait("@createNewApi").should( + "have.nested.property", + "response.body.responseMeta.status", + 201, + ); +}); + Cypress.Commands.add("CopyAPIToHome", apiname => { cy.get(apiwidget.popover) .first() @@ -507,6 +557,7 @@ Cypress.Commands.add("Createpage", Pagename => { cy.get(pages.editInput) .type(Pagename) .type("{Enter}"); + pageidcopy = Pagename; cy.get("#loading").should("not.exist"); cy.wait(2000); }); @@ -539,6 +590,7 @@ Cypress.Commands.add("addDsl", dsl => { const myRegexp = /pages(.*)/; const match = myRegexp.exec(currentURL); pageid = match[1].split("/")[1]; + cy.log(pageidcopy + "page id copy"); cy.log(pageid + "page id"); //Fetch the layout id cy.server(); @@ -888,6 +940,67 @@ Cypress.Commands.add("pageNoValidate", index => { const pageVal = cy.get(data); return pageVal; }); + +Cypress.Commands.add("startServerAndRoutes", () => { + cy.server(); + cy.route("GET", "/api/v1/applications").as("applications"); + cy.route("GET", "/api/v1/users/profile").as("getUser"); + cy.route("GET", "/api/v1/plugins").as("getPlugins"); + cy.route("POST", "/api/v1/logout").as("postLogout"); + + cy.route("GET", "/api/v1/configs/name/propertyPane").as("getPropertyPane"); + cy.route("GET", "/api/v1/datasources").as("getDataSources"); + cy.route("GET", "/api/v1/pages/application/*").as("getPagesForApp"); + cy.route("GET", "/api/v1/pages/*").as("getPage"); + cy.route("GET", "/api/v1/actions*").as("getActions"); + cy.route("GET", "api/v1/providers/categories").as("getCategories"); + cy.route("GET", "api/v1/import/templateCollections").as( + "getTemplateCollections", + ); + cy.route("DELETE", "/api/v1/actions/*").as("deleteAPI"); + cy.route("DELETE", "/api/v1/applications/*").as("deleteApp"); + cy.route("DELETE", "/api/v1/actions/*").as("deleteAction"); + cy.route("DELETE", "/api/v1/pages/*").as("deletePage"); + + cy.route("GET", "/api/v1/plugins/*/form").as("getPluginForm"); + cy.route("POST", "/api/v1/datasources").as("createDatasource"); + cy.route("POST", "/api/v1/datasources/test").as("testDatasource"); + cy.route("PUT", "/api/v1/datasources/*").as("saveDatasource"); + cy.route("DELETE", "/api/v1/datasources/*").as("deleteDatasource"); + + cy.route("GET", "/api/v1/organizations").as("organizations"); + cy.route("POST", "/api/v1/actions/execute").as("executeAction"); + cy.route("POST", "/api/v1/applications/publish/*").as("publishApp"); + cy.route("PUT", "/api/v1/layouts/*/pages/*").as("updateLayout"); + + cy.route("POST", "/v1/t").as("postSave"); + cy.route("PUT", "/api/v1/actions/*").as("putActions"); + cy.route("POST", "/track/*").as("postTrack"); + cy.route("POST", "/v1/m").as("postexe"); + cy.route("POST", "/api/v1/actions/execute").as("postExecute"); + cy.route("POST", "/api/v1/actions").as("postaction"); + + cy.route("POST", "/api/v1/actions").as("createNewApi"); + cy.route("POST", "/api/v1/import?type=CURL&pageId=*&name=*").as("curlImport"); + cy.route("DELETE", "/api/v1/actions/*").as("deleteAction"); + cy.route("GET", "/api/v1/marketplace/providers?category=*&page=*&size=*").as( + "get3PProviders", + ); + cy.route("GET", "/api/v1/marketplace/templates?providerId=*").as( + "get3PProviderTemplates", + ); + cy.route("POST", "/api/v1/items/addToPage").as("add3PApiToPage"); + + cy.route("GET", "/api/v1/plugins/*/form").as("getPluginForm"); + cy.route("POST", "/api/v1/datasources").as("createDatasource"); + cy.route("POST", "/api/v1/datasources/test").as("testDatasource"); + cy.route("PUT", "/api/v1/datasources/*").as("saveDatasource"); + cy.route("DELETE", "/api/v1/datasources/*").as("deleteDatasource"); + cy.route("DELETE", "/api/v1/applications/*").as("deleteApplication"); + + cy.route("PUT", "/api/v1/actions/*").as("saveQuery"); +}); + Cypress.Commands.add("alertValidate", text => { cy.get(commonlocators.success) .should("be.visible") diff --git a/app/client/cypress/support/index.js b/app/client/cypress/support/index.js index 6bba739494..de02bf483e 100644 --- a/app/client/cypress/support/index.js +++ b/app/client/cypress/support/index.js @@ -22,65 +22,8 @@ let appId; import "./commands"; before(function() { console.log("**** Got Cypress base URL as: ", process.env.CYPRESS_BASE_URL); - - cy.server(); - cy.route("GET", "/api/v1/applications").as("applications"); - cy.route("GET", "/api/v1/users/profile").as("getUser"); - cy.route("GET", "/api/v1/plugins").as("getPlugins"); - cy.route("POST", "/api/v1/logout").as("postLogout"); - - cy.route("GET", "/api/v1/configs/name/propertyPane").as("getPropertyPane"); - cy.route("GET", "/api/v1/datasources").as("getDataSources"); - cy.route("GET", "/api/v1/pages/application/*").as("getPagesForApp"); - cy.route("GET", "/api/v1/pages/*").as("getPage"); - cy.route("GET", "/api/v1/actions*").as("getActions"); - cy.route("GET", "api/v1/providers/categories").as("getCategories"); - cy.route("GET", "api/v1/import/templateCollections").as( - "getTemplateCollections", - ); - cy.route("DELETE", "/api/v1/actions/*").as("deleteAPI"); - cy.route("DELETE", "/api/v1/applications/*").as("deleteApp"); - cy.route("DELETE", "/api/v1/actions/*").as("deleteAction"); - cy.route("DELETE", "/api/v1/pages/*").as("deletePage"); - - cy.route("GET", "/api/v1/plugins/*/form").as("getPluginForm"); - cy.route("POST", "/api/v1/datasources").as("createDatasource"); - cy.route("POST", "/api/v1/datasources/test").as("testDatasource"); - cy.route("PUT", "/api/v1/datasources/*").as("saveDatasource"); - cy.route("DELETE", "/api/v1/datasources/*").as("deleteDatasource"); - - cy.route("GET", "/api/v1/organizations").as("organizations"); - cy.route("POST", "/api/v1/actions/execute").as("executeAction"); - cy.route("POST", "/api/v1/applications/publish/*").as("publishApp"); - cy.route("PUT", "/api/v1/layouts/*/pages/*").as("updateLayout"); - - cy.route("POST", "/v1/t").as("postSave"); - cy.route("PUT", "/api/v1/actions/*").as("putActions"); - cy.route("POST", "/track/*").as("postTrack"); - cy.route("POST", "/v1/m").as("postexe"); - cy.route("POST", "/api/v1/actions/execute").as("postExecute"); - cy.route("POST", "/api/v1/actions").as("postaction"); - - cy.route("POST", "/api/v1/actions").as("createNewApi"); - cy.route("POST", "/api/v1/import?type=CURL&pageId=*&name=*").as("curlImport"); - cy.route("DELETE", "/api/v1/actions/*").as("deleteAction"); - cy.route("GET", "/api/v1/marketplace/providers?category=*&page=*&size=*").as( - "get3PProviders", - ); - cy.route("GET", "/api/v1/marketplace/templates?providerId=*").as( - "get3PProviderTemplates", - ); - cy.route("POST", "/api/v1/items/addToPage").as("add3PApiToPage"); - - cy.route("GET", "/api/v1/plugins/*/form").as("getPluginForm"); - cy.route("POST", "/api/v1/datasources").as("createDatasource"); - cy.route("POST", "/api/v1/datasources/test").as("testDatasource"); - cy.route("PUT", "/api/v1/datasources/*").as("saveDatasource"); - cy.route("DELETE", "/api/v1/datasources/*").as("deleteDatasource"); - cy.route("DELETE", "/api/v1/applications/*").as("deleteApplication"); - - cy.route("PUT", "/api/v1/actions/*").as("saveQuery"); - + cy.viewport("macbook-15"); + cy.startServerAndRoutes(); cy.LogintoApp(loginData.username, loginData.password); // cy.SearchApp(inputData.appname) cy.generateUUID().then(id => { @@ -103,6 +46,7 @@ before(function() { beforeEach(function() { Cypress.Cookies.preserveOnce("SESSION", "remember_token"); + cy.startServerAndRoutes(); }); after(function() {