Browse Source

test(cypress): disable app store test for non-super admin

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/3796/head
Pranav C 2 years ago
parent
commit
67efde6f6b
  1. 269
      scripts/cypress/integration/spec/roleValidation.spec.js

269
scripts/cypress/integration/spec/roleValidation.spec.js

@ -1,5 +1,5 @@
import { mainPage, settingsPage } from "../../support/page_objects/mainPage"; import { mainPage, settingsPage } from '../../support/page_objects/mainPage';
import { roles } from "../../support/page_objects/projectConstants"; import { roles } from '../../support/page_objects/projectConstants';
// Left hand navigation bar, validation for // Left hand navigation bar, validation for
// 1. Audit menu // 1. Audit menu
@ -9,61 +9,62 @@ import { roles } from "../../support/page_objects/projectConstants";
export function _advSettings(roleType, mode) { export function _advSettings(roleType, mode) {
cy.log(roleType, mode); cy.log(roleType, mode);
if (mode === "baseShare") { if (mode === 'baseShare') {
// open modal // open modal
cy.get(".nc-project-menu").should("exist").click(); cy.get('.nc-project-menu').should('exist').click();
cy.getActiveMenu(".nc-dropdown-project-menu") cy.getActiveMenu('.nc-dropdown-project-menu')
.find(`[data-menu-id="language"]`) .find(`[data-menu-id="language"]`)
.should("exist"); .should('exist');
// click again to close modal // click again to close modal
cy.get(".nc-project-menu").should("exist").click(); cy.get('.nc-project-menu').should('exist').click();
return; return;
} }
let validationString = let validationString =
true == roles[roleType].validations.advSettings ? "exist" : "not.exist"; true == roles[roleType].validations.advSettings ? 'exist' : 'not.exist';
// cy.get(".nc-team-settings").should(validationString); // cy.get(".nc-team-settings").should(validationString);
cy.get(".nc-project-menu").should("exist").click(); cy.get('.nc-project-menu').should('exist').click();
cy.getActiveMenu(".nc-dropdown-project-menu") cy.getActiveMenu('.nc-dropdown-project-menu')
.find(`[data-menu-id="preview-as"]`) .find(`[data-menu-id="preview-as"]`)
.should(validationString); .should(validationString);
cy.getActiveMenu(".nc-dropdown-project-menu") cy.getActiveMenu('.nc-dropdown-project-menu')
.find(`[data-menu-id="teamAndSettings"]:visible`) .find(`[data-menu-id="teamAndSettings"]:visible`)
.should(validationString); .should(validationString);
if (true === roles[roleType].validations.advSettings) { if (true === roles[roleType].validations.advSettings) {
cy.getActiveMenu(".nc-dropdown-project-menu") cy.getActiveMenu('.nc-dropdown-project-menu')
.find(`[data-menu-id="teamAndSettings"]:visible`) .find(`[data-menu-id="teamAndSettings"]:visible`)
.should(validationString) .should(validationString)
.click(); .click();
cy.get(`[data-menu-id="teamAndAuth"]`).should("exist"); cy.get(`[data-menu-id="teamAndAuth"]`).should('exist');
cy.get(`[data-menu-id="appStore"]`).should("exist"); if (roleType === 'owner')
cy.get(`[data-menu-id="projMetaData"]`).should("exist"); cy.get(`[data-menu-id="appStore"]`).should('exist');
cy.get(`[data-menu-id="audit"]`).should("exist"); cy.get(`[data-menu-id="projMetaData"]`).should('exist');
cy.get(`[data-menu-id="audit"]`).should('exist');
settingsPage.closeMenu(); settingsPage.closeMenu();
} else { } else {
cy.get(".nc-project-menu").should("exist").click(); cy.get('.nc-project-menu').should('exist').click();
} }
// float menu in preview mode // float menu in preview mode
if ("preview" === mode) { if ('preview' === mode) {
cy.get(".nc-floating-preview-btn").should("exist"); cy.get('.nc-floating-preview-btn').should('exist');
cy.get(".nc-floating-preview-btn") cy.get('.nc-floating-preview-btn')
.find(`[type="radio"][value="${roles[roleType].name}"]`) .find(`[type="radio"][value="${roles[roleType].name}"]`)
.should("be.checked"); .should('be.checked');
} }
// cy.get("body").click("bottomRight"); // cy.get("body").click("bottomRight");
} }
export function _editSchema(roleType, mode) { export function _editSchema(roleType, mode) {
let columnName = "City"; let columnName = 'City';
let validationString = let validationString =
true === roles[roleType].validations.editSchema ? "exist" : "not.exist"; true === roles[roleType].validations.editSchema ? 'exist' : 'not.exist';
cy.openTableTab(columnName, 25); cy.openTableTab(columnName, 25);
@ -71,18 +72,18 @@ export function _editSchema(roleType, mode) {
cy.get(`.nc-add-new-table`).should(validationString); cy.get(`.nc-add-new-table`).should(validationString);
// delete table option // delete table option
cy.get(`.nc-project-tree-tbl-City`).should("exist").rightclick(); cy.get(`.nc-project-tree-tbl-City`).should('exist').rightclick();
cy.get(".ant-dropdown-content:visible").should(validationString); cy.get('.ant-dropdown-content:visible').should(validationString);
if (validationString === "exist") { if (validationString === 'exist') {
cy.getActiveMenu(".nc-dropdown-tree-view-context-menu") cy.getActiveMenu('.nc-dropdown-tree-view-context-menu')
.find('[role="menuitem"]') .find('[role="menuitem"]')
.contains("Delete") .contains('Delete')
.should("exist"); .should('exist');
cy.getActiveMenu(".nc-dropdown-tree-view-context-menu") cy.getActiveMenu('.nc-dropdown-tree-view-context-menu')
.find('[role="menuitem"]') .find('[role="menuitem"]')
.contains("Rename") .contains('Rename')
.should("exist"); .should('exist');
// click on a cell to close table context menu // click on a cell to close table context menu
mainPage.getCell(columnName, 3).click(); mainPage.getCell(columnName, 3).click();
@ -90,104 +91,104 @@ export function _editSchema(roleType, mode) {
// add new column option // add new column option
// //
cy.get(".nc-column-add").should(validationString); cy.get('.nc-column-add').should(validationString);
// update column (edit/ delete menu) // update column (edit/ delete menu)
cy.get(".nc-ui-dt-dropdown").should(validationString); cy.get('.nc-ui-dt-dropdown').should(validationString);
if (validationString === "exist") { if (validationString === 'exist') {
cy.get(".nc-import-menu").should("exist").click(); cy.get('.nc-import-menu').should('exist').click();
cy.getActiveMenu(".nc-dropdown-import-menu").should("exist"); cy.getActiveMenu('.nc-dropdown-import-menu').should('exist');
cy.getActiveMenu(".nc-dropdown-import-menu") cy.getActiveMenu('.nc-dropdown-import-menu')
.find(".ant-dropdown-menu-item") .find('.ant-dropdown-menu-item')
.contains("Airtable"); .contains('Airtable');
cy.getActiveMenu(".nc-dropdown-import-menu") cy.getActiveMenu('.nc-dropdown-import-menu')
.find(".ant-dropdown-menu-item") .find('.ant-dropdown-menu-item')
.contains("CSV file"); .contains('CSV file');
cy.getActiveMenu(".nc-dropdown-import-menu") cy.getActiveMenu('.nc-dropdown-import-menu')
.find(".ant-dropdown-menu-item") .find('.ant-dropdown-menu-item')
.contains("JSON file"); .contains('JSON file');
cy.getActiveMenu(".nc-dropdown-import-menu") cy.getActiveMenu('.nc-dropdown-import-menu')
.find(".ant-dropdown-menu-item") .find('.ant-dropdown-menu-item')
.contains("Microsoft Excel"); .contains('Microsoft Excel');
} }
} }
export function _editData(roleType, mode) { export function _editData(roleType, mode) {
let columnName = "City"; let columnName = 'City';
let validationString = let validationString =
true === roles[roleType].validations.editData ? "exist" : "not.exist"; true === roles[roleType].validations.editData ? 'exist' : 'not.exist';
cy.openTableTab(columnName, 25); cy.openTableTab(columnName, 25);
// add row button // add row button
cy.get(".nc-add-new-row-btn:visible").should(validationString); cy.get('.nc-add-new-row-btn:visible').should(validationString);
// add button at bottom of page // add button at bottom of page
mainPage.getCell(columnName, 25).scrollIntoView(); mainPage.getCell(columnName, 25).scrollIntoView();
cy.get(".nc-grid-add-new-cell:visible").should(validationString); cy.get('.nc-grid-add-new-cell:visible').should(validationString);
// update row option (right click) // update row option (right click)
// //
mainPage.getCell("City", 5).rightclick(); mainPage.getCell('City', 5).rightclick();
cy.wait(100); cy.wait(100);
cy.get(".ant-dropdown-content:visible").should(validationString); cy.get('.ant-dropdown-content:visible').should(validationString);
if (validationString === "exist") { if (validationString === 'exist') {
// right click options will exist (only for 'exist' case) // right click options will exist (only for 'exist' case)
// //
cy.getActiveMenu(".nc-dropdown-grid-context-menu") cy.getActiveMenu('.nc-dropdown-grid-context-menu')
.contains("Insert New Row") .contains('Insert New Row')
.should(validationString); .should(validationString);
cy.getActiveMenu(".nc-dropdown-grid-context-menu") cy.getActiveMenu('.nc-dropdown-grid-context-menu')
.contains("Clear cell") .contains('Clear cell')
.should(validationString); .should(validationString);
cy.getActiveMenu(".nc-dropdown-grid-context-menu") cy.getActiveMenu('.nc-dropdown-grid-context-menu')
.contains("Delete Row") .contains('Delete Row')
.should(validationString); .should(validationString);
cy.getActiveMenu(".nc-dropdown-grid-context-menu") cy.getActiveMenu('.nc-dropdown-grid-context-menu')
.contains("Delete Selected Rows") .contains('Delete Selected Rows')
.should(validationString); .should(validationString);
// cy.get("body").type("{esc}"); // cy.get("body").type("{esc}");
mainPage.getCell("City", 13).click(); mainPage.getCell('City', 13).click();
// update cell contents option using row expander should be enabled // update cell contents option using row expander should be enabled
// //
mainPage mainPage
.getRow(1) .getRow(1)
.find(".nc-row-no") .find('.nc-row-no')
.should("exist") .should('exist')
.eq(0) .eq(0)
.trigger("mouseover", { force: true }); .trigger('mouseover', { force: true });
cy.get(".nc-row-expand").should("exist").eq(10).click({ force: true }); cy.get('.nc-row-expand').should('exist').eq(10).click({ force: true });
cy.getActiveDrawer(".nc-drawer-expanded-form") cy.getActiveDrawer('.nc-drawer-expanded-form')
.find("button") .find('button')
.contains("Save row") .contains('Save row')
.should("exist"); .should('exist');
cy.getActiveDrawer(".nc-drawer-expanded-form") cy.getActiveDrawer('.nc-drawer-expanded-form')
.find("button") .find('button')
.contains("Cancel") .contains('Cancel')
.should("exist") .should('exist')
.click(); .click();
} else { } else {
// update cell contents option using row expander should be disabled // update cell contents option using row expander should be disabled
// //
cy.get(".nc-row-expand").should("exist").eq(10).click({ force: true }); cy.get('.nc-row-expand').should('exist').eq(10).click({ force: true });
cy.getActiveDrawer(".nc-drawer-expanded-form") cy.getActiveDrawer('.nc-drawer-expanded-form')
.find("button:disabled") .find('button:disabled')
.contains("Save row") .contains('Save row')
.should("exist"); .should('exist');
cy.getActiveDrawer(".nc-drawer-expanded-form") cy.getActiveDrawer('.nc-drawer-expanded-form')
.find("button") .find('button')
.contains("Cancel") .contains('Cancel')
.should("exist") .should('exist')
.click(); .click();
} }
// double click cell entries to edit // double click cell entries to edit
// //
mainPage.getCell("City", 5).dblclick().find("input").should(validationString); mainPage.getCell('City', 5).dblclick().find('input').should(validationString);
} }
// read &/ update comment // read &/ update comment
@ -195,11 +196,11 @@ export function _editData(roleType, mode) {
// Everyone else: read &/ update // Everyone else: read &/ update
// //
export function _editComment(roleType, mode) { export function _editComment(roleType, mode) {
let columnName = "City"; let columnName = 'City';
let validationString = let validationString =
true === roles[roleType].validations.editComment true === roles[roleType].validations.editComment
? "Comment added successfully" ? 'Comment added successfully'
: "Not allowed"; : 'Not allowed';
cy.openTableTab(columnName, 25); cy.openTableTab(columnName, 25);
@ -207,7 +208,7 @@ export function _editComment(roleType, mode) {
// click on comment icon & type comment // click on comment icon & type comment
// //
cy.get(".nc-row-expand").should("exist").eq(10).click({ force: true }); cy.get('.nc-row-expand').should('exist').eq(10).click({ force: true });
// Expected response: // Expected response:
// Viewer: Not able to see comment option // Viewer: Not able to see comment option
@ -216,32 +217,32 @@ export function _editComment(roleType, mode) {
cy.wait(3000); cy.wait(3000);
if ("viewer" === roleType) { if ('viewer' === roleType) {
cy.getActiveDrawer(".nc-drawer-expanded-form") cy.getActiveDrawer('.nc-drawer-expanded-form')
.should("exist") .should('exist')
.find(".nc-toggle-comments") .find('.nc-toggle-comments')
.should("not.exist"); .should('not.exist');
} else { } else {
cy.getActiveDrawer(".nc-drawer-expanded-form") cy.getActiveDrawer('.nc-drawer-expanded-form')
.should("exist") .should('exist')
.find(".nc-toggle-comments") .find('.nc-toggle-comments')
.should("exist") .should('exist')
.click(); .click();
cy.getActiveDrawer(".nc-drawer-expanded-form") cy.getActiveDrawer('.nc-drawer-expanded-form')
.find(".nc-comment-box") .find('.nc-comment-box')
.should("exist") .should('exist')
.type("Comment-1{enter}"); .type('Comment-1{enter}');
// cy.toastWait('Comment added successfully') // cy.toastWait('Comment added successfully')
cy.getActiveDrawer(".nc-drawer-expanded-form") cy.getActiveDrawer('.nc-drawer-expanded-form')
.find(".nc-toggle-comments") .find('.nc-toggle-comments')
.click(); .click();
} }
cy.getActiveDrawer(".nc-drawer-expanded-form") cy.getActiveDrawer('.nc-drawer-expanded-form')
.find("button") .find('button')
.contains("Cancel") .contains('Cancel')
.should("exist") .should('exist')
.click(); .click();
} }
@ -249,7 +250,7 @@ export function _editComment(roleType, mode) {
// Editor/Viewer/Commenter : can only view 'existing' views // Editor/Viewer/Commenter : can only view 'existing' views
// Rest: can create/edit // Rest: can create/edit
export function _viewMenu(roleType, mode) { export function _viewMenu(roleType, mode) {
let columnName = "City"; let columnName = 'City';
// Lock, Download, Upload // Lock, Download, Upload
let menuWithSubmenuCount = 3; let menuWithSubmenuCount = 3;
@ -260,16 +261,16 @@ export function _viewMenu(roleType, mode) {
cy.openTableTab(columnName, 25); cy.openTableTab(columnName, 25);
let validationString = let validationString =
true === roles[roleType].validations.shareView ? "exist" : "not.exist"; true === roles[roleType].validations.shareView ? 'exist' : 'not.exist';
if (roleType === "editor") { if (roleType === 'editor') {
// Download / Upload CSV // Download / Upload CSV
menuWithSubmenuCount = 2; menuWithSubmenuCount = 2;
// Get API Snippet and ERD // Get API Snippet and ERD
menuWithoutSubmenuCount = 2; menuWithoutSubmenuCount = 2;
// ERD // ERD
if (mode === "baseShare") menuWithoutSubmenuCount = 1; if (mode === 'baseShare') menuWithoutSubmenuCount = 1;
} else if (roleType === "commenter" || roleType === "viewer") { } else if (roleType === 'commenter' || roleType === 'viewer') {
// Download CSV & Download excel // Download CSV & Download excel
menuWithSubmenuCount = 0; menuWithSubmenuCount = 0;
// Get API Snippet and ERD // Get API Snippet and ERD
@ -277,7 +278,7 @@ export function _viewMenu(roleType, mode) {
} }
// view list field (default GRID view) // view list field (default GRID view)
cy.get(`.nc-view-item`).should("exist"); cy.get(`.nc-view-item`).should('exist');
// view create option, exists only for owner/ creator // view create option, exists only for owner/ creator
cy.get(`.nc-create-grid-view`).should(validationString); cy.get(`.nc-create-grid-view`).should(validationString);
@ -287,47 +288,47 @@ export function _viewMenu(roleType, mode) {
// share view permissions are role specific // share view permissions are role specific
// actions menu (more), only download csv should be visible for non-previlaged users // actions menu (more), only download csv should be visible for non-previlaged users
cy.get(".nc-actions-menu-btn").click(); cy.get('.nc-actions-menu-btn').click();
cy.getActiveMenu(".nc-dropdown-actions-menu") cy.getActiveMenu('.nc-dropdown-actions-menu')
.find(".ant-dropdown-menu-submenu:visible") .find('.ant-dropdown-menu-submenu:visible')
.should("have.length", menuWithSubmenuCount); .should('have.length', menuWithSubmenuCount);
cy.getActiveMenu(".nc-dropdown-actions-menu") cy.getActiveMenu('.nc-dropdown-actions-menu')
.find(".ant-dropdown-menu-item:visible") .find('.ant-dropdown-menu-item:visible')
.should("have.length", menuWithoutSubmenuCount); .should('have.length', menuWithoutSubmenuCount);
// click again to close menu // click again to close menu
cy.get(".nc-actions-menu-btn").click(); cy.get('.nc-actions-menu-btn').click();
} }
export function _topRightMenu(roleType, mode) { export function _topRightMenu(roleType, mode) {
// kludge; download csv menu persists until clicked // kludge; download csv menu persists until clicked
let columnName = "City"; let columnName = 'City';
// cy.closeTableTab(columnName); // cy.closeTableTab(columnName);
// cy.openTableTab(columnName, 25); // cy.openTableTab(columnName, 25);
let validationString = let validationString =
true == roles[roleType].validations.shareView ? "exist" : "not.exist"; true == roles[roleType].validations.shareView ? 'exist' : 'not.exist';
cy.get(`.nc-share-base`).should(validationString); cy.get(`.nc-share-base`).should(validationString);
cy.get(".nc-menu-translate").should("exist"); cy.get('.nc-menu-translate').should('exist');
cy.get(".nc-menu-accounts").should("exist"); cy.get('.nc-menu-accounts').should('exist');
} }
// Access control list // Access control list
// //
export function disableTableAccess(tbl, role) { export function disableTableAccess(tbl, role) {
const cls = `.nc-acl-${tbl}-${role}-chkbox`; const cls = `.nc-acl-${tbl}-${role}-chkbox`;
cy.get(cls).find("input").should("be.checked").click({ force: true }); cy.get(cls).find('input').should('be.checked').click({ force: true });
cy.get(cls).find("input").should("not.be.checked"); cy.get(cls).find('input').should('not.be.checked');
} }
export function enableTableAccess(tbl, role) { export function enableTableAccess(tbl, role) {
const cls = `.nc-acl-${tbl}-${role}-chkbox`; const cls = `.nc-acl-${tbl}-${role}-chkbox`;
cy.get(cls).find("input").should("not.be.checked").click({ force: true }); cy.get(cls).find('input').should('not.be.checked').click({ force: true });
cy.get(cls).find("input").should("be.checked"); cy.get(cls).find('input').should('be.checked');
} }
export function _accessControl(roleType, previewMode) { export function _accessControl(roleType, previewMode) {
let validationString = roleType === "creator" ? "exist" : "not.exist"; let validationString = roleType === 'creator' ? 'exist' : 'not.exist';
cy.get(`.nc-project-tree-tbl-Language`).should(validationString); cy.get(`.nc-project-tree-tbl-Language`).should(validationString);
cy.get(`.nc-project-tree-tbl-CustomerList`).should(validationString); cy.get(`.nc-project-tree-tbl-CustomerList`).should(validationString);

Loading…
Cancel
Save