From 0235c474fad0494b20fa700b23aeb66700b0036c Mon Sep 17 00:00:00 2001 From: Nandan Date: Wed, 30 Sep 2020 01:04:50 +0530 Subject: [PATCH 1/2] Add ShareApp test --- .../OrganisationTests/ShareAppTests_spec.js | 32 +++++++++++++++++++ app/client/cypress/support/commands.js | 20 ++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 app/client/cypress/integration/Smoke_TestSuite/OrganisationTests/ShareAppTests_spec.js diff --git a/app/client/cypress/integration/Smoke_TestSuite/OrganisationTests/ShareAppTests_spec.js b/app/client/cypress/integration/Smoke_TestSuite/OrganisationTests/ShareAppTests_spec.js new file mode 100644 index 000000000000..28cd070674e7 --- /dev/null +++ b/app/client/cypress/integration/Smoke_TestSuite/OrganisationTests/ShareAppTests_spec.js @@ -0,0 +1,32 @@ +/// + +const homePage = require("../../../locators/HomePage.json"); +const commonlocators = require("../../../locators/commonlocators.json"); +const dsl = require("../../../fixtures/newFormDsl.json"); +describe("Create new org and share with a user", function() { + let appname; + + before(() => { + appname = localStorage.getItem("AppName"); + cy.addDsl(dsl); + }); + + it("create org and then share with a user from Application share option within application", function() { + cy.get(commonlocators.homeIcon).click({ force: true }); + cy.SearchApp(appname); + cy.openPropertyPane("buttonwidget"); + cy.get(".t--application-share-btn").click(); + cy.shareApp(Cypress.env("TESTUSERNAME1"), homePage.viewerRole); + cy.LogOut(); + }); + + it("login as invited user and then validate viewer privilage", function() { + cy.LogintoApp(Cypress.env("TESTUSERNAME1"), Cypress.env("TESTPASSWORD1")); + cy.SearchApp(appname); + cy.xpath(homePage.ShareBtn).should("not.exist"); + cy.get(homePage.applicationCard).trigger("mouseover"); + cy.get(homePage.appEditIcon).should("not.exist"); + cy.launchApp(appname); + cy.LogOut(); + }); +}); diff --git a/app/client/cypress/support/commands.js b/app/client/cypress/support/commands.js index 33941a3bd5ec..57e691adf4b7 100644 --- a/app/client/cypress/support/commands.js +++ b/app/client/cypress/support/commands.js @@ -88,6 +88,26 @@ Cypress.Commands.add("inviteUserForOrg", (orgName, email, role) => { .click(); }); +Cypress.Commands.add("shareApp", (email, role) => { + cy.xpath(homePage.email) + .click({ force: true }) + .type(email); + cy.xpath(homePage.selectRole).click({ force: true }); + cy.xpath(role).click({ force: true }); + cy.xpath(homePage.inviteBtn).click({ force: true }); + cy.wait("@postInvite").should( + "have.nested.property", + "response.body.responseMeta.status", + 200, + ); + cy.contains(email); + cy.get(homePage.manageUsers).click({ force: true }); + cy.xpath(homePage.appHome) + .first() + .should("be.visible") + .click(); +}); + Cypress.Commands.add("deleteUserFromOrg", (orgName, email) => { cy.get(homePage.orgList.concat(orgName).concat(")")) .scrollIntoView() From 36dbc500278dad8d377550f3f31e172c18f4d0cf Mon Sep 17 00:00:00 2001 From: Nandan Date: Thu, 1 Oct 2020 00:37:56 +0530 Subject: [PATCH 2/2] Sharing app tests and public access --- .../OrganisationTests/ShareAppTests_spec.js | 126 +++++++++++++++--- app/client/cypress/locators/HomePage.json | 6 +- .../cypress/locators/publishWidgetspage.json | 7 +- app/client/cypress/support/commands.js | 33 ++++- 4 files changed, 148 insertions(+), 24 deletions(-) diff --git a/app/client/cypress/integration/Smoke_TestSuite/OrganisationTests/ShareAppTests_spec.js b/app/client/cypress/integration/Smoke_TestSuite/OrganisationTests/ShareAppTests_spec.js index 28cd070674e7..4046207d8ebb 100644 --- a/app/client/cypress/integration/Smoke_TestSuite/OrganisationTests/ShareAppTests_spec.js +++ b/app/client/cypress/integration/Smoke_TestSuite/OrganisationTests/ShareAppTests_spec.js @@ -1,32 +1,128 @@ /// const homePage = require("../../../locators/HomePage.json"); -const commonlocators = require("../../../locators/commonlocators.json"); -const dsl = require("../../../fixtures/newFormDsl.json"); -describe("Create new org and share with a user", function() { - let appname; +const publish = require("../../../locators/publishWidgetspage.json"); - before(() => { - appname = localStorage.getItem("AppName"); - cy.addDsl(dsl); - }); +describe("Create new org and share with a user", function() { + let orgid; + let appid; + let currentUrl; it("create org and then share with a user from Application share option within application", function() { - cy.get(commonlocators.homeIcon).click({ force: true }); - cy.SearchApp(appname); - cy.openPropertyPane("buttonwidget"); - cy.get(".t--application-share-btn").click(); - cy.shareApp(Cypress.env("TESTUSERNAME1"), homePage.viewerRole); + cy.NavigateToHome(); + cy.generateUUID().then(uid => { + orgid = uid; + appid = uid; + localStorage.setItem("OrgName", orgid); + cy.createOrg(orgid); + cy.CreateAppForOrg(orgid, appid); + cy.wait("@getPagesForApp").should( + "have.nested.property", + "response.body.responseMeta.status", + 200, + ); + cy.get("h2").contains("Drag and drop a widget here"); + cy.get(homePage.shareApp).click(); + cy.shareApp(Cypress.env("TESTUSERNAME1"), homePage.viewerRole); + }); cy.LogOut(); }); it("login as invited user and then validate viewer privilage", function() { cy.LogintoApp(Cypress.env("TESTUSERNAME1"), Cypress.env("TESTPASSWORD1")); - cy.SearchApp(appname); + cy.get(homePage.searchInput).type(appid); + cy.wait(2000); + cy.get(homePage.appsContainer).contains(orgid); cy.xpath(homePage.ShareBtn).should("not.exist"); cy.get(homePage.applicationCard).trigger("mouseover"); cy.get(homePage.appEditIcon).should("not.exist"); - cy.launchApp(appname); + cy.launchApp(appid); + cy.LogOut(); + }); + + it("Enable public access to Application", function() { + cy.LoginFromAPI(Cypress.env("USERNAME"), Cypress.env("PASSWORD")); + cy.visit("/applications"); + cy.wait("@applications").should( + "have.nested.property", + "response.body.responseMeta.status", + 200, + ); + cy.SearchApp(appid); + cy.wait("@getPagesForApp").should( + "have.nested.property", + "response.body.responseMeta.status", + 200, + ); + cy.get("h2").contains("Drag and drop a widget here"); + cy.get(homePage.shareApp).click(); + cy.enablePublicAccess(); + cy.PublishtheApp(); + currentUrl = cy.url(); + cy.url().then(url => { + currentUrl = url; + cy.log(currentUrl); + }); + cy.get(publish.backToEditor).click(); + cy.LogOut(); + }); + + it("login as uninvited user and then validate public access of Application", function() { + cy.LogintoApp(Cypress.env("TESTUSERNAME2"), Cypress.env("TESTPASSWORD2")); + cy.visit(currentUrl); + cy.wait("@getPagesForApp").should( + "have.nested.property", + "response.body.responseMeta.status", + 200, + ); + cy.get(publish.pageInfo) + .invoke("text") + .then(text => { + const someText = text; + expect(someText).to.equal("This page seems to be blank"); + }); + cy.LogOut(); + }); + it("login as Owner and disable public access", function() { + cy.LoginFromAPI(Cypress.env("USERNAME"), Cypress.env("PASSWORD")); + cy.visit("/applications"); + cy.wait("@applications").should( + "have.nested.property", + "response.body.responseMeta.status", + 200, + ); + cy.SearchApp(appid); + cy.wait("@getPagesForApp").should( + "have.nested.property", + "response.body.responseMeta.status", + 200, + ); + cy.get("h2").contains("Drag and drop a widget here"); + cy.get(homePage.shareApp).click(); + cy.enablePublicAccess(); + cy.LogOut(); + }); + + it("login as uninvited user and then validate public access disable feature", function() { + cy.LogintoApp(Cypress.env("TESTUSERNAME2"), Cypress.env("TESTPASSWORD2")); + cy.visit(currentUrl); + cy.wait("@getPagesForApp").should( + "have.nested.property", + "response.body.responseMeta.status", + 404, + ); cy.LogOut(); }); + + it("login as owner and delete App ", function() { + cy.LoginFromAPI(Cypress.env("USERNAME"), Cypress.env("PASSWORD")); + cy.visit("/applications"); + cy.wait("@applications").should( + "have.nested.property", + "response.body.responseMeta.status", + 200, + ); + cy.SearchApp(appid); + cy.get("#loading").should("not.exist"); + }); }); diff --git a/app/client/cypress/locators/HomePage.json b/app/client/cypress/locators/HomePage.json index 67231dedb214..a6f5c9ec5f07 100644 --- a/app/client/cypress/locators/HomePage.json +++ b/app/client/cypress/locators/HomePage.json @@ -42,5 +42,9 @@ "orgSectionBtn": ".t--org-section .bp3-button", "shareOrg": ") a:contains('Share')", "orgSection": "a:contains(", - "createAppFrOrg": ") .t--create-app-popup" + "createAppFrOrg": ") .t--create-app-popup", + "shareApp": ".t--application-share-btn", + "enablePublicAccess": ".bp3-control-indicator", + "closeBtn": ".bp3-dialog-close-button" + } \ No newline at end of file diff --git a/app/client/cypress/locators/publishWidgetspage.json b/app/client/cypress/locators/publishWidgetspage.json index 2383588e7ee9..1474aa3dd171 100644 --- a/app/client/cypress/locators/publishWidgetspage.json +++ b/app/client/cypress/locators/publishWidgetspage.json @@ -19,8 +19,8 @@ "tableLength": ".t--widget-tablewidget .tbody", "mapSearch": ".t--widget-mapwidget input", "pickMyLocation": ".t--widget-mapwidget div[title='Pick My Location']", - "rectChart":".t--widget-chartwidget g rect", - "chartLab":".t--widget-chartwidget g:nth-child(5) text", + "rectChart": ".t--widget-chartwidget g rect", + "chartLab": ".t--widget-chartwidget g:nth-child(5) text", "searchInput": "input", "downloadBtn": ".t--table-download-btn", "filterBtn": ".t--table-filter-toggle-btn", @@ -34,5 +34,6 @@ "compactOpt": ".t--table-compact-mode-option", "visibilityMode": ".t--table-column-visibility-toggle-btn", "visibilityOpt": ".option-title", - "containerWidget": ".t--widget-containerwidget" + "containerWidget": ".t--widget-containerwidget", + "pageInfo": ".bp3-heading" } \ No newline at end of file diff --git a/app/client/cypress/support/commands.js b/app/client/cypress/support/commands.js index 57e691adf4b7..324e72417d33 100644 --- a/app/client/cypress/support/commands.js +++ b/app/client/cypress/support/commands.js @@ -101,11 +101,33 @@ Cypress.Commands.add("shareApp", (email, role) => { 200, ); cy.contains(email); - cy.get(homePage.manageUsers).click({ force: true }); - cy.xpath(homePage.appHome) - .first() - .should("be.visible") - .click(); + cy.get(homePage.closeBtn).click(); +}); + +Cypress.Commands.add("shareAndPublic", (email, role) => { + cy.xpath(homePage.email) + .click({ force: true }) + .type(email); + cy.xpath(homePage.selectRole).click({ force: true }); + cy.xpath(role).click({ force: true }); + cy.xpath(homePage.inviteBtn).click({ force: true }); + cy.wait("@postInvite").should( + "have.nested.property", + "response.body.responseMeta.status", + 200, + ); + cy.contains(email); + cy.enablePublicAccess(); +}); + +Cypress.Commands.add("enablePublicAccess", () => { + cy.get(homePage.enablePublicAccess).click(); + cy.wait("@changeAccess").should( + "have.nested.property", + "response.body.responseMeta.status", + 200, + ); + cy.get(homePage.closeBtn).click(); }); Cypress.Commands.add("deleteUserFromOrg", (orgName, email) => { @@ -1606,6 +1628,7 @@ Cypress.Commands.add("startServerAndRoutes", () => { cy.route("GET", "/api/v1/users/me").as("getUser"); cy.route("POST", "/api/v1/pages").as("createPage"); cy.route("POST", "/api/v1/pages/clone/*").as("clonePage"); + cy.route("PUT", "/api/v1/applications/*/changeAccess").as("changeAccess"); }); Cypress.Commands.add("alertValidate", text => {