Browse Source

test: fix iFrame cell validation

Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com>
pull/3655/head
Raju Udava 2 years ago
parent
commit
1daba9050b
  1. 259
      scripts/cypress/integration/common/6g_base_share.js

259
scripts/cypress/integration/common/6g_base_share.js

@ -3,101 +3,101 @@ import { projectsPage } from "../../support/page_objects/navigation";
import { loginPage } from "../../support/page_objects/navigation";
import { isTestSuiteActive } from "../../support/page_objects/projectConstants";
import {
_advSettings,
_editSchema,
_editData,
_editComment,
_viewMenu,
_topRightMenu,
_advSettings,
_editSchema,
_editData,
_editComment,
_viewMenu,
_topRightMenu,
} from "../spec/roleValidation.spec";
import {linkSync} from "fs";
import { linkSync } from "fs";
// fix me
let linkText = "";
export const genTest = (apiType, dbType) => {
if (!isTestSuiteActive(apiType, dbType)) return;
const permissionValidation = (roleType) => {
it(`${roleType}: Visit base shared URL`, () => {
cy.log(linkText);
// visit URL & wait for page load to complete
cy.visit(linkText, {
baseUrl: null,
});
cy.wait(5000);
});
it(`${roleType}: Validate access permissions: advance menu`, () => {
// cy.restoreLocalStorage();
_advSettings(roleType, "baseShare");
});
if (!isTestSuiteActive(apiType, dbType)) return;
it(`${roleType}: Validate access permissions: edit schema`, () => {
// cy.restoreLocalStorage();
_editSchema(roleType, "baseShare");
});
const permissionValidation = (roleType) => {
it(`${roleType}: Visit base shared URL`, () => {
cy.log(linkText);
it(`${roleType}: Validate access permissions: edit data`, () => {
// cy.restoreLocalStorage();
_editData(roleType, "baseShare");
});
// visit URL & wait for page load to complete
cy.visit(linkText, {
baseUrl: null,
});
cy.wait(5000);
});
it(`${roleType}: Validate access permissions: edit comments`, () => {
// cy.restoreLocalStorage();
_editComment(roleType, "baseShare");
});
it(`${roleType}: Validate access permissions: advance menu`, () => {
// cy.restoreLocalStorage();
_advSettings(roleType, "baseShare");
});
it(`${roleType}: Validate access permissions: view's menu`, () => {
// cy.restoreLocalStorage();
_viewMenu(roleType, "baseShare");
});
};
describe(`${apiType.toUpperCase()} Base VIEW share`, () => {
before(() => {
// loginPage.loginAndOpenProject(apiType, dbType);
cy.restoreLocalStorage();
cy.openTableTab("Country", 25);
cy.saveLocalStorage();
});
it(`${roleType}: Validate access permissions: edit schema`, () => {
// cy.restoreLocalStorage();
_editSchema(roleType, "baseShare");
});
it(`${roleType}: Validate access permissions: edit data`, () => {
// cy.restoreLocalStorage();
_editData(roleType, "baseShare");
});
it(`${roleType}: Validate access permissions: edit comments`, () => {
// cy.restoreLocalStorage();
_editComment(roleType, "baseShare");
});
it(`${roleType}: Validate access permissions: view's menu`, () => {
// cy.restoreLocalStorage();
_viewMenu(roleType, "baseShare");
});
};
describe(`${apiType.toUpperCase()} Base VIEW share`, () => {
before(() => {
// loginPage.loginAndOpenProject(apiType, dbType);
cy.restoreLocalStorage();
cy.openTableTab("Country", 25);
cy.saveLocalStorage();
});
beforeEach(() => {
cy.restoreLocalStorage();
})
beforeEach(() => {
cy.restoreLocalStorage();
});
afterEach(() => {
cy.saveLocalStorage();
})
afterEach(() => {
cy.saveLocalStorage();
});
it(`Generate base share URL`, () => {
// click SHARE
cy.get(".nc-share-base:visible").should('exist').click();
it(`Generate base share URL`, () => {
// click SHARE
cy.get(".nc-share-base:visible").should("exist").click();
// Click on readonly base text
cy.getActiveModal().find(".nc-disable-shared-base").click();
// Click on readonly base text
cy.getActiveModal().find(".nc-disable-shared-base").click();
cy.getActiveMenu(".nc-dropdown-shared-base-toggle")
.find(".ant-dropdown-menu-title-content")
.contains("Anyone with the link")
.click();
cy.getActiveMenu(".nc-dropdown-shared-base-toggle")
.find(".ant-dropdown-menu-title-content")
.contains("Anyone with the link")
.click();
cy.getActiveModal().find(".nc-shared-base-role").click();
cy.getActiveModal().find(".nc-shared-base-role").click();
cy.getActiveSelection('.nc-dropdown-share-base-role')
.find('.ant-select-item')
.eq(1)
.click();
cy.getActiveSelection(".nc-dropdown-share-base-role")
.find(".ant-select-item")
.eq(1)
.click();
// Copy URL
cy.getActiveModal(".nc-modal-invite-user-and-share-base")
.find(".nc-url")
.then(($obj) => {
cy.log($obj[0]);
linkText = $obj[0].innerText.trim();
// Copy URL
cy.getActiveModal(".nc-modal-invite-user-and-share-base")
.find(".nc-url")
.then(($obj) => {
cy.log($obj[0]);
linkText = $obj[0].innerText.trim();
const htmlFile = `
const htmlFile = `
<!DOCTYPE html>
<html>
<body>
@ -113,67 +113,72 @@ style="background: transparent; "></iframe>
</body>
</html>
`;
cy.writeFile(
"scripts/cypress/fixtures/sampleFiles/iFrame.html",
htmlFile
);
});
cy.log(linkText);
cy.signOut();
cy.writeFile(
"scripts/cypress/fixtures/sampleFiles/iFrame.html",
htmlFile
);
});
permissionValidation("viewer");
it("Update to EDITOR base share link", () => {
loginPage.loginAndOpenProject(apiType, dbType);
// click SHARE
cy.get(".nc-share-base:visible").should('exist').click();
cy.getActiveModal().find(".nc-shared-base-role").click();
cy.log(linkText);
cy.getActiveSelection('.nc-dropdown-share-base-role')
.find('.ant-select-item')
.eq(0)
.click();
cy.signOut();
});
permissionValidation("editor");
cy.signOut();
});
describe(`${apiType.toUpperCase()} iFrame Test`, () => {
// https://docs.cypress.io/api/commands/visit#Prefixes
it("Generate & verify embed HTML IFrame", {baseUrl: null}, () => {
permissionValidation("viewer");
let filePath = "scripts/cypress/fixtures/sampleFiles/iFrame.html";
cy.log(filePath);
cy.visit(filePath, {baseUrl: null});
it("Update to EDITOR base share link", () => {
loginPage.loginAndOpenProject(apiType, dbType);
// wait for iFrame to load
cy.frameLoaded(".nc-embed");
// click SHARE
cy.get(".nc-share-base:visible").should("exist").click();
// cy.openTableTab("Country", 25);
cy.iframe().find(`.nc-project-tree-tbl-Actor`, {timeout: 10000}).should("exist")
.first()
.click({force: true});
cy.getActiveModal().find(".nc-shared-base-role").click();
// validation for base menu opitons
cy.iframe().find(".nc-project-tree").should("exist");
cy.iframe().find(".nc-fields-menu-btn").should("exist");
cy.iframe().find(".nc-sort-menu-btn").should("exist");
cy.iframe().find(".nc-filter-menu-btn").should("exist");
cy.iframe().find(".nc-actions-menu-btn").should("exist");
cy.getActiveSelection(".nc-dropdown-share-base-role")
.find(".ant-select-item")
.eq(0)
.click();
// validate data (row-1)
cy.iframe().find(`.nc-grid-cell`).eq(1).contains("PENELOPE").should("exist");
cy.iframe().find(`.nc-grid-cell`).eq(2).contains("GUINESS").should("exist");
});
})
}
cy.signOut();
});
permissionValidation("editor");
});
describe(`${apiType.toUpperCase()} iFrame Test`, () => {
// https://docs.cypress.io/api/commands/visit#Prefixes
it("Generate & verify embed HTML IFrame", { baseUrl: null }, () => {
let filePath = "scripts/cypress/fixtures/sampleFiles/iFrame.html";
cy.log(filePath);
cy.visit(filePath, { baseUrl: null });
// wait for iFrame to load
cy.frameLoaded(".nc-embed");
// cy.openTableTab("Country", 25);
cy.iframe()
.find(`.nc-project-tree-tbl-Actor`, { timeout: 10000 })
.should("exist")
.first()
.click({ force: true });
// validation for base menu opitons
cy.iframe().find(".nc-project-tree").should("exist");
cy.iframe().find(".nc-fields-menu-btn").should("exist");
cy.iframe().find(".nc-sort-menu-btn").should("exist");
cy.iframe().find(".nc-filter-menu-btn").should("exist");
cy.iframe().find(".nc-actions-menu-btn").should("exist");
// validate data (row-1)
cy.iframe()
.find(`.nc-grid-cell:eq(1):contains("PENELOPE")`)
.should("exist");
cy.iframe()
.find(`.nc-grid-cell:eq(2):contains("GUINESS")`)
.should("exist");
});
});
};
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd

Loading…
Cancel
Save