Browse Source

test: preview-mode corrections

Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com>
pull/3846/head
Raju Udava 2 years ago
parent
commit
0c542ee17a
  1. 4
      packages/nc-gui/components/general/PreviewAs.vue
  2. 88
      scripts/cypress/integration/common/5b_preview_role.js

4
packages/nc-gui/components/general/PreviewAs.vue

@ -82,7 +82,7 @@ watch(previewAs, (newRole) => {
<div class="divider -ml-4" /> <div class="divider -ml-4" />
<!-- Close --> <!-- Close -->
<div class="flex items-center gap-2 cursor-pointer" @click="previewAs = null"> <div class="flex items-center gap-2 cursor-pointer nc-preview-btn-exit-to-app" @click="previewAs = null">
<MdiExitToApp /> <MdiExitToApp />
{{ $t('general.close') }} {{ $t('general.close') }}
</div> </div>
@ -91,7 +91,7 @@ watch(previewAs, (newRole) => {
<template v-else> <template v-else>
<template v-for="role of roleList" :key="role.value"> <template v-for="role of roleList" :key="role.value">
<a-menu-item @click="previewAs = role.value"> <a-menu-item class="nc-role-preview-menu" @click="previewAs = role.value">
<div class="nc-project-menu-item group"> <div class="nc-project-menu-item group">
<component :is="roleIcon[role.value]" class="group-hover:text-accent" /> <component :is="roleIcon[role.value]" class="group-hover:text-accent" />

88
scripts/cypress/integration/common/5b_preview_role.js

@ -19,6 +19,7 @@ import {
_topRightMenu, _topRightMenu,
enableTableAccess, enableTableAccess,
_accessControl, _accessControl,
disableTableAccess,
} from "../spec/roleValidation.spec"; } from "../spec/roleValidation.spec";
export const genTest = (apiType, dbType, roleType) => { export const genTest = (apiType, dbType, roleType) => {
@ -29,10 +30,44 @@ export const genTest = (apiType, dbType, roleType) => {
let clear; let clear;
function configureAcl() {
// open Project metadata tab
//
settingsPage.openMenu(settingsPage.PROJ_METADATA);
settingsPage.openTab(settingsPage.UI_ACCESS_CONTROL);
// validate if it has 19 entries representing tables & views
if (isPostgres()) cy.get(".nc-acl-table-row").should("have.length", 24);
else if (isXcdb()) cy.get(".nc-acl-table-row").should("have.length", 19);
else cy.get(".nc-acl-table-row").should("have.length", 19);
// disable table & view access
//
disableTableAccess("Language", "editor");
disableTableAccess("Language", "commenter");
disableTableAccess("Language", "viewer");
disableTableAccess("CustomerList", "editor");
disableTableAccess("CustomerList", "commenter");
disableTableAccess("CustomerList", "viewer");
cy.get("button.nc-acl-save").click();
cy.toastWait("Updated UI ACL for tables successfully");
mainPage.closeMetaTab();
}
describe("Role preview validations", () => { describe("Role preview validations", () => {
// Sign in/ open project // Sign in/ open project
before(() => { before(() => {
// cy.restoreLocalStorage();
loginPage.loginAndOpenProject(apiType, dbType); loginPage.loginAndOpenProject(apiType, dbType);
clear = Cypress.LocalStorage.clear;
Cypress.LocalStorage.clear = () => {};
// configureAcl();
cy.openTableTab("City", 25); cy.openTableTab("City", 25);
settingsPage.openProjectMenu(); settingsPage.openProjectMenu();
@ -40,45 +75,25 @@ export const genTest = (apiType, dbType, roleType) => {
.find(`[data-submenu-id="preview-as"]`) .find(`[data-submenu-id="preview-as"]`)
.should("exist") .should("exist")
.click(); .click();
cy.get(".ant-dropdown-menu-submenu")
.eq(4) cy.get(".nc-role-preview-menu").should("have.length", 3);
.find(`[data-menu-id="editor"]`) cy.get(`.nc-role-preview-menu:contains("Editor")`)
.should("exist") .should("exist")
.click(); .click();
cy.saveLocalStorage();
clear = Cypress.LocalStorage.clear;
Cypress.LocalStorage.clear = () => {};
});
beforeEach(() => {
cy.restoreLocalStorage();
});
afterEach(() => {
cy.saveLocalStorage();
Cypress.LocalStorage.clear = clear;
}); });
after(() => { after(() => {
cy.restoreLocalStorage(); cy.get(".nc-preview-btn-exit-to-app").click();
// cy.get(".nc-preview-reset").click({ force: true });
cy.get(".mdi-exit-to-app").click();
// wait for page rendering to complete // wait for page rendering to complete
cy.get(".nc-grid-row", { timeout: 25000 }).should("have.length", 25); cy.get(".nc-grid-row", { timeout: 25000 }).should("have.length", 25);
// cy.get('.nc-preview-reset:visible').should('not-exist')
// mainPage.navigationDraw(mainPage.ROLE_VIEW).contains('Reset Preview').should('not.exist')
// cy.get('.nc-preview-reset').should('not-exist')
cy.closeTableTab("City"); cy.closeTableTab("City");
// open Project metadata tab // open Project metadata tab
// //
mainPage.navigationDraw(mainPage.PROJ_METADATA).click(); settingsPage.openMenu(settingsPage.PROJ_METADATA);
// cy.get(".nc-exp-imp-metadata").dblclick({ force: true }); settingsPage.openTab(settingsPage.UI_ACCESS_CONTROL);
cy.get(".nc-ui-acl-tab").click({ force: true });
// validate if it has 19 entries representing tables & views // validate if it has 19 entries representing tables & views
if (isPostgres()) cy.get(".nc-acl-table-row").should("have.length", 24); if (isPostgres()) cy.get(".nc-acl-table-row").should("have.length", 24);
@ -87,15 +102,15 @@ export const genTest = (apiType, dbType, roleType) => {
// restore access // restore access
// //
enableTableAccess("language", "editor"); enableTableAccess("Language", "editor");
enableTableAccess("language", "commenter"); enableTableAccess("Language", "commenter");
enableTableAccess("language", "viewer"); enableTableAccess("Language", "viewer");
enableTableAccess("customerlist", "editor");
enableTableAccess("customerlist", "commenter");
enableTableAccess("customerlist", "viewer");
enableTableAccess("Customerlist", "editor");
enableTableAccess("Customerlist", "commenter");
enableTableAccess("Customerlist", "viewer");
cy.saveLocalStorage(); cy.saveLocalStorage();
Cypress.LocalStorage.clear = clear;
}); });
const genTestSub = (roleType) => { const genTestSub = (roleType) => {
@ -141,13 +156,6 @@ export const genTest = (apiType, dbType, roleType) => {
_viewMenu(roleType, "preview"); _viewMenu(roleType, "preview");
}); });
it(`Role preview: ${roleType}: Top Right Menu bar`, () => {
// Share button is conditional
// Rest are static/ mandatory
//
_topRightMenu(roleType, "preview");
});
it(`Role preview: ${roleType}: Edit Schema`, () => { it(`Role preview: ${roleType}: Edit Schema`, () => {
// Schema related validations // Schema related validations
// - Add/delete table // - Add/delete table

Loading…
Cancel
Save