Feature/share app test (#843)

* Add ShareApp test

* Sharing app tests and public access
This commit is contained in:
NandanAnantharamu 2020-10-02 14:30:33 +05:30 committed by GitHub
parent 032426b4ed
commit 2fe1c8a5de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 180 additions and 4 deletions

View File

@ -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");
});
});

View File

@ -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"
}

View File

@ -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"
}

View File

@ -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()
@ -1585,6 +1627,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 => {