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

Loading…
Cancel
Save