Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
/// <reference types="Cypress" />

const homePage = require("../../../locators/HomePage.json");
const publish = require("../../../locators/publishWidgetspage.json");

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.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.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(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");
});
});
6 changes: 5 additions & 1 deletion app/client/cypress/locators/HomePage.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"

}
7 changes: 4 additions & 3 deletions app/client/cypress/locators/publishWidgetspage.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
}
43 changes: 43 additions & 0 deletions app/client/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,48 @@ 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.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) => {
cy.get(homePage.orgList.concat(orgName).concat(")"))
.scrollIntoView()
Expand Down Expand Up @@ -1586,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 => {
Expand Down