diff --git a/app/client/cypress/integration/Smoke_TestSuite/UnitTest/CreateDeleteApp_spec.js b/app/client/cypress/integration/Smoke_TestSuite/UnitTest/CreateDeleteApp_spec.js new file mode 100644 index 0000000000..cc267dcd01 --- /dev/null +++ b/app/client/cypress/integration/Smoke_TestSuite/UnitTest/CreateDeleteApp_spec.js @@ -0,0 +1,10 @@ +describe("Create and Delete App Functionality", function() { + it("Delete App Functionality", function() { + cy.log("appname: " + localStorage.getItem("AppName")); + const appname = localStorage.getItem("AppName"); + cy.openPropertyPane("textwidget"); + cy.DeleteApp(appname); + cy.wait("@deleteApplication"); + cy.get("@deleteApplication").should("have.property", "status", 200); + }); +}); diff --git a/app/client/cypress/support/commands.js b/app/client/cypress/support/commands.js index 6815a20ed6..efa700e9b4 100644 --- a/app/client/cypress/support/commands.js +++ b/app/client/cypress/support/commands.js @@ -32,6 +32,21 @@ Cypress.Commands.add("CreateApp", appname => { cy.get("@getUser").should("have.property", "status", 200); }); +Cypress.Commands.add("DeleteApp", appName => { + cy.get(commonlocators.homeIcon).click({ force: true }); + cy.wait("@applications").should( + "have.nested.property", + "response.body.responseMeta.status", + 200, + ); + cy.get('button span[icon="chevron-down"]').should("be.visible"); + cy.get(homePage.searchInput).type(appName, { force: true }); + cy.get(homePage.appMoreIcon).should("have.length",1) + .first() + .click({ force: true }); + cy.get(homePage.deleteButton).should("be.visible").click({ force: true }); +}); + Cypress.Commands.add("LogintoApp", (uname, pword) => { cy.visit("/user/login"); cy.get(loginPage.username).should("be.visible"); @@ -458,12 +473,16 @@ Cypress.Commands.add("DeleteAppByApi", () => { const myRegexp = /applications(.*)/; const match = myRegexp.exec(currentURL); appId = match[1].split("/")[1]; - cy.log(appId + "appId"); - cy.request("DELETE", "api/v1/applications/" + appId).then(response => { - expect(response.status).equal(200); - }); + + if (appId != null) { + cy.log(appId + "appId"); + cy.request("DELETE", "api/v1/applications/" + appId).then(response => { + expect(response.status).equal(200); + }); + } }); }); + Cypress.Commands.add("togglebar", value => { cy.get(value) .check({ force: true }) diff --git a/app/client/cypress/support/index.js b/app/client/cypress/support/index.js index 03e4da6d60..29daf30a3e 100644 --- a/app/client/cypress/support/index.js +++ b/app/client/cypress/support/index.js @@ -76,6 +76,7 @@ before(function() { 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"); @@ -84,6 +85,7 @@ before(function() { cy.generateUUID().then(id => { appId = id; cy.CreateApp(id); + localStorage.setItem("AppName", appId); }); cy.generateUUID().then(uid => {