Browse Source

(test) cypress: role validation fix/ clean-up

Signed-off-by: Raju Udava <sivadstala@gmail.com>
pull/769/head
Raju Udava 3 years ago
parent
commit
205b18ce56
  1. 10
      packages/nc-gui/components/ProjectTreeView.vue
  2. 300
      scripts/cypress/integration/common/5a_user_role.js
  3. 304
      scripts/cypress/integration/common/5b_preview_role.js
  4. 174
      scripts/cypress/integration/spec/roleValidation.spec.js
  5. 33
      scripts/cypress/support/page_objects/mainPage.js

10
packages/nc-gui/components/ProjectTreeView.vue

@ -375,7 +375,7 @@
<template v-if="_isUIAllowed('treeViewProjectSettings')">
<v-tooltip bottom>
<template #activator="{ on }">
<v-list-item dense class="body-2" @click="appsTabAdd" v-on="on">
<v-list-item dense class="body-2 nc-settings-appstore" @click="appsTabAdd" v-on="on">
<v-list-item-icon>
<v-icon x-small>
mdi-storefront-outline
@ -395,7 +395,7 @@
<v-tooltip bottom>
<template #activator="{ on }">
<v-list-item dense class="body-2" @click="rolesTabAdd" v-on="on">
<v-list-item dense class="body-2 nc-settings-teamauth" @click="rolesTabAdd" v-on="on">
<v-list-item-icon>
<v-icon x-small>
mdi-account-group
@ -414,7 +414,7 @@
</v-tooltip>
<v-tooltip bottom>
<template #activator="{ on }">
<v-list-item dense class="body-2" @click="disableOrEnableModelTabAdd" v-on="on">
<v-list-item dense class="body-2 nc-settings-projmeta" @click="disableOrEnableModelTabAdd" v-on="on">
<v-list-item-icon>
<v-icon x-small>
mdi-table-multiple
@ -507,7 +507,7 @@
<v-divider v-if="i" :key="i" vertical class="mx-2 caption grey--text" />
<div
:key="role.title"
class="pointer text-center"
:class="`pointer text-center nc-preview-${role.title}`"
@click="setPreviewUSer(role.title)"
>
<v-icon
@ -531,7 +531,7 @@
mdi-close
</v-icon>
<!-- Reset Preview -->
<span class="caption">{{ $t('treeview.reset_review') }}</span>
<span class="caption nc-preview-reset">{{ $t('treeview.reset_review') }}</span>
</v-list-item>
</template>
</v-list>

300
scripts/cypress/integration/common/5a_user_role.js

@ -2,8 +2,7 @@ import { loginPage, projectsPage } from "../../support/page_objects/navigation"
import { mainPage } from "../../support/page_objects/mainPage"
import { roles, staticProjects } from "../../support/page_objects/projectConstants"
import { isTestSuiteActive } from "../../support/page_objects/projectConstants"
// let roleURL = {}
import { _advSettings, _editSchema, _editData, _editComment, _viewMenu } from "../spec/roleValidation.spec"
export const genTest = (type, xcdb) => {
if (!isTestSuiteActive(type, xcdb)) return;
@ -38,10 +37,6 @@ export const genTest = (type, xcdb) => {
addUser(roles.editor)
addUser(roles.commenter)
addUser(roles.viewer)
// it(`Logging purpose`, () => {
// cy.log(mainPage.roleURL)
// })
})
const roleValidation = (roleType) => {
@ -72,34 +67,36 @@ export const genTest = (type, xcdb) => {
///////////////////////////////////////////////////////
// Test suite
// it(`[${roles[roleType].name}] SignIn, Open project`, () => {
// loginPage.signIn(roles[roleType].credentials)
// if('rest' == type)
// projectsPage.openProject(staticProjects.externalREST.basic.name)
// else
// projectsPage.openProject(staticProjects.externalGQL.basic.name)
// })
it(`[${roles[roleType].name}] Left navigation menu, New User add`, (done) => {
cy.on('uncaught:exception', (err, runnable) => {
const errHndl = (err, runnable, done) => {
expect(err.message).to.include('Not allowed')
done()
return false
})
advancedSettings(roleType, done)
}
it(`[${roles[roleType].name}] Left navigation menu, New User add`, (done) => {
cy.on('uncaught:exception', (err, runnable) => errHndl(err, runnable, done))
//done()
// project configuration settings
//
_advSettings(roleType, false)
cy.wait(2000).then(() => {
done()
})
})
it(`[${roles[roleType].name}] Schema: create table, add/modify/delete column`, (done) => {
cy.on('uncaught:exception', (err, runnable) => {
expect(err.message).to.include('Not allowed')
done()
return false
})
editSchema(roleType, done)
cy.on('uncaught:exception', (err, runnable) => errHndl(err, runnable, done))
// Schema related validations
// - Add/delete table
// - Add/Update/delete column
//
_editSchema(roleType, false)
// done()
cy.wait(2000).then(() => {
done()
})
})
it(`[${roles[roleType].name}] Data: add/modify/delete row, update cell contents`, (done) => {
@ -107,42 +104,47 @@ export const genTest = (type, xcdb) => {
// known issue: to be fixed
// right click raising alarm 'not allowed' for viewer
//
cy.on('uncaught:exception', (err, runnable) => {
expect(err.message).to.include('Not allowed')
done()
return false
})
cy.on('uncaught:exception', (err, runnable) => errHndl(err, runnable, done))
// Table data related validations
// - Add/delete/modify row
//
if (roleType != 'editor')
_editData(roleType, false)
if (roleType != 'editor')
editData(roleType, done)
else
cy.wait(2000).then(() => {
done()
})
})
it(`[${roles[roleType].name}] Comments: view/add`, (done) => {
cy.on('uncaught:exception', (err, runnable) => {
expect(err.message).to.include('Not allowed')
done()
return false
})
// Fix me!
cy.on('uncaught:exception', (err, runnable) => errHndl(err, runnable, done))
// read &/ update comment
// Viewer: only allowed to read
// Everyone else: read &/ update
//
if (roleType != 'viewer')
editComment(roleType, done)
else
_editComment(roleType, false)
cy.wait(2000).then(() => {
done()
})
})
it(`[${roles[roleType].name}] Right navigation menu, share view`, (done) => {
cy.on('uncaught:exception', (err, runnable) => {
expect(err.message).to.include('Not allowed')
cy.on('uncaught:exception', (err, runnable) => errHndl(err, runnable, done))
// right navigation menu bar
// Editor/Viewer/Commenter : can only view 'existing' views
// Rest: can create/edit
_viewMenu(roleType, false)
cy.wait(2000).then(() => {
done()
return false
})
viewMenu(roleType, done)
//done()
})
it(`[${roles[roleType].name}] Download files`, () => {
@ -167,18 +169,6 @@ export const genTest = (type, xcdb) => {
mainPage.downloadAndVerifyCsv(`City_exported_1.csv`, verifyCsv)
mainPage.hideUnhideField('LastUpdate')
})
// after(() => {
// if ('viewer' == roleType) {
// loginPage.loginAndOpenProject('graphql', false)
// }
// })
// it(`Reset`, () => {
// if ('viewer' == roleType) {
// loginPage.loginAndOpenProject('graphql', false)
// }
// })
})
}
@ -190,194 +180,6 @@ export const genTest = (type, xcdb) => {
roleValidation('viewer')
}
// project configuration settings
//
const advancedSettings = (roleType, done) => {
// let validationString = (true == roleValidation[roleIdx].advSettings) ? 'exist' : 'not.exist'
let validationString = (true == roles[roleType].validations.advSettings) ? 'exist' : 'not.exist'
// hardwired to be enabled for all roles
mainPage.navigationDraw(mainPage.AUDIT).should('exist')
mainPage.navigationDraw(mainPage.APPSTORE).should(validationString)
mainPage.navigationDraw(mainPage.TEAM_N_AUTH).should(validationString)
mainPage.navigationDraw(mainPage.PROJ_METADATA).should(validationString)
// mainPage.navigationDraw(mainPage.ROLE_VIEW).should(validationString)
if ('exist' == validationString) {
mainPage.navigationDraw(mainPage.ROLE_VIEW).contains('editor')
mainPage.navigationDraw(mainPage.ROLE_VIEW).contains('commenter')
mainPage.navigationDraw(mainPage.ROLE_VIEW).contains('viewer')
}
cy.get('button:contains("New User")').should(validationString)
cy.wait(2000).then(() => {
done()
})
}
// Schema related validations
// - Add/delete table
// - Add/Update/delete column
//
const editSchema = (roleType, done) => {
let columnName = 'City'
let validationString = (true == roles[roleType].validations.editSchema) ? 'exist' : 'not.exist'
// create table options
//
cy.get('.add-btn').should(validationString)
cy.get('.v-tabs-bar').eq(0).find('button.mdi-plus-box').should(validationString)
// open existing table-column
//
cy.openTableTab(columnName)
// delete table option
//
cy.get('.nc-table-delete-btn').should(validationString)
// add new column option
//
cy.get('.new-column-header').should(validationString)
// update column (edit/ delete menu)
//
cy.get(`th:contains(${columnName}) .mdi-menu-down`).should(validationString)
cy.wait(2000).then(() => {
done()
})
}
// Table data related validations
// - Add/delete/modify row
//
const editData = (roleType, done) => {
let columnName = 'City'
let validationString = (true == roles[roleType].validations.editData) ? 'exist' : 'not.exist'
cy.openTableTab(columnName)
// add new row option (from menu header)
//
cy.get('.nc-add-new-row-btn').should(validationString)
// update row option (right click)
//
cy.get(`tbody > :nth-child(8) > [data-col="City"]`).rightclick()
cy.get('.menuable__content__active').should(validationString)
if (validationString == 'exist') {
// right click options will exist (only for 'exist' case)
//
cy.getActiveMenu().contains('Insert New Row').should(validationString)
cy.getActiveMenu().contains('Delete Row').should(validationString)
cy.getActiveMenu().contains('Delete Selected Rows').should(validationString)
cy.get('body').type('{esc}')
// update cell contents option using row expander should be enabled
//
//cy.get('.nc-row-expand-icon').eq(4).click({ force: true })
cy.get('.v-input.row-checkbox').eq(4).next().next().click({ force: true })
cy.getActiveModal().find('button').contains('Save Row').should('exist')
cy.get('body').type('{esc}')
}
else {
// update cell contents option using row expander should be disabled
//
//cy.get('.nc-row-expand-icon').eq(4).click({ force: true })
cy.get('.v-input.row-checkbox').eq(4).next().next().click({ force: true })
cy.getActiveModal().find('button:disabled').contains('Save Row').should('exist')
cy.get('body').type('{esc}')
}
// double click cell entries to edit
//
cy.get(`tbody > :nth-child(8) > [data-col="City"]`).dblclick().find('input').should(validationString)
cy.wait(2000).then(() => {
done()
})
}
// read &/ update comment
// Viewer: only allowed to read
// Everyone else: read &/ update
//
const editComment = (roleType, done) => {
let columnName = 'City'
let validationString = (true == roles[roleType].validations.editComment) ? 'Comment added successfully' : 'Not allowed'
cy.openTableTab(columnName)
// click on comment icon & type comment
//
cy.get('.v-input.row-checkbox').eq(8).next().next().click({ force: true })
//cy.get('.nc-row-expand-icon').eq(4).click({ force: true })
cy.getActiveModal().find('.mdi-comment-multiple-outline').should('exist').click()
cy.getActiveModal().find('.comment-box').type('Comment-1{enter}')
// Expected response:
// Viewer: Not allowed
// Everyone else: Comment added successfully
//
cy.get('body').contains(validationString, { timeout: 2000 }).should('exist')
cy.get('body').type('{esc}')
cy.wait(2000).then(() => {
done()
})
}
// right navigation menu bar
// Editor/Viewer/Commenter : can only view 'existing' views
// Rest: can create/edit
const viewMenu = (roleType, done) => {
let columnName = 'City'
let navDrawListCnt = 2
cy.openTableTab(columnName)
let validationString = (true == roles[roleType].validations.shareView) ? 'exist' : 'not.exist'
// validate if Share button is visible at header tool bar
cy.get('header.v-toolbar').eq(0).find('button:contains("Share")').should(validationString)
// Owner, Creator will have two navigation drawer (on each side of center panel)
if (roleType == 'owner' || roleType == 'creator') {
navDrawListCnt = 4
}
cy.get('.v-navigation-drawer__content').eq(1).find('[role="list"]').should('have.length', navDrawListCnt)
// view list field (default GRID view)
cy.get(`.nc-view-item`).should('exist')
// view create option, exists only for owner/ creator
cy.get(`.nc-create-gallery-view`).should(validationString)
cy.get(`.nc-create-grid-view`).should(validationString)
cy.get(`.nc-create-form-view`).should(validationString)
// share view & automations, exists only for owner/creator
cy.get(`.nc-share-view`).should(validationString)
cy.get(`.nc-automations`).should(validationString)
cy.wait(2000).then(() => {
done()
})
}
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd

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

@ -5,244 +5,13 @@
import { loginPage, projectsPage } from "../../support/page_objects/navigation"
import { mainPage } from "../../support/page_objects/mainPage"
import { roles } from "../../support/page_objects/projectConstants"
import { isTestSuiteActive } from "../../support/page_objects/projectConstants"
import { _advSettings, _editSchema, _editData, _editComment, _viewMenu } from "../spec/roleValidation.spec"
// should we reverify permissions after preview reset?
const reVerificationAfterReset = false
// should we verify permissions in owner mode before preview?
const baseVerificationBeforePreview = false
export const genTest = (type, xcdb, roleType) => {
if(!isTestSuiteActive(type, xcdb)) return;
// project configuration settings
//
const advancedSettings = (roleType) => {
cy.log(`##### advancedSettings: ${roleType}`)
let validationString = (true == roles[roleType].validations.advSettings) ? 'exist' : 'not.exist'
// restricted mode has only 3 lists & 3 items
let vListLength = (true == roles[roleType].validations.advSettings) ? 4 : 3
let vListItemLength = (true == roles[roleType].validations.advSettings) ? 6 : 3
cy.get('.nc-nav-drawer').find('.v-list').should('has.length', vListLength)
cy.get('.nc-nav-drawer').find('.v-list > .v-list-item').should('has.length', vListItemLength)
cy.get('.nc-nav-drawer').find('.v-list > .v-list-item').contains('Audit').should('exist')
cy.get('.nc-nav-drawer').find('.v-list > .v-list-item').contains('App Store').should(validationString)
cy.get('.nc-nav-drawer').find('.v-list > .v-list-item').contains('Team & Auth').should(validationString)
cy.get('.nc-nav-drawer').find('.v-list > .v-list-item').contains('Project Metadata').should(validationString)
// preview mode- common across all
cy.get('.nc-nav-drawer').find('.v-list').last().contains('editor').should('exist')
cy.get('.nc-nav-drawer').find('.v-list').last().contains('commenter').should('exist')
cy.get('.nc-nav-drawer').find('.v-list').last().contains('viewer').should('exist')
// Reset preview option available only in 'preview mode'
// Open team & auth after reset-preview to ensure 'New User' button is visible again
//
if (true == roles[roleType].validations.advSettings) {
cy.get('.nc-nav-drawer').find('.v-list').last().contains('Reset Preview').should('not.exist')
cy.get('.nc-nav-drawer').find('.v-list > .v-list-item').contains('Team & Auth').click()
}
else {
cy.get('.nc-nav-drawer').find('.v-list').last().contains('Reset Preview').should('exist')
}
cy.get('button:contains("New User")').should(validationString)
}
// Table data related validations
// - Add/delete/modify row
//
const editData = (roleType) => {
cy.log(`##### editData: ${roleType}`)
// TODO: to be fixed for roleType = 'editor'
// Some of the expected buttons are invisible
if (roleType == 'editor')
return false
// TODO: to be fixed for roleType = 'editor'
// Unhandled exception
if (roleType == 'viewer')
return false
let columnName = 'City'
let validationString = (true == roles[roleType].validations.editData) ? 'exist' : 'not.exist'
cy.openTableTab(columnName)
// add new row option (from menu header)
//
cy.get('.nc-add-new-row-btn').should(validationString)
// update row option (right click)
//
// TODO: roleType = viewer has an unhandled exception for rightClick
if (roleType != 'viewer') {
cy.get(`tbody > :nth-child(4) > [data-col="City"]`).rightclick()
cy.get('.menuable__content__active').should(validationString)
}
if (validationString == 'exist') {
// right click options will exist (only for 'exist' case)
//
cy.getActiveMenu().contains('Insert New Row').should(validationString)
cy.getActiveMenu().contains('Delete Row').should(validationString)
cy.getActiveMenu().contains('Delete Selected Rows').should(validationString)
cy.get('body').type('{esc}')
// update cell contents option using row expander should be enabled
//
//cy.get('.nc-row-expand-icon').eq(4).click({ force: true })
cy.get('.v-input.row-checkbox').eq(4).next().next().click({ force: true })
cy.getActiveModal().find('button').contains('Save Row').should('exist')
cy.get('body').type('{esc}')
}
else {
// update cell contents option using row expander should be disabled
//
//cy.get('.nc-row-expand-icon').eq(4).click({ force: true })
cy.get('.v-input.row-checkbox').eq(4).next().next().click({ force: true })
cy.getActiveModal().find('button:disabled').contains('Save Row').should('exist')
cy.getActiveModal().find('button').contains('Cancel').click()
cy.get('body').type('{esc}')
}
// double click cell entries to edit
//
cy.get(`tbody > :nth-child(4) > [data-col="City"]`).dblclick().find('input').should(validationString)
}
// Schema related validations
// - Add/delete table
// - Add/Update/delete column
//
const editSchema = (roleType) => {
cy.log(`##### editSchema: ${roleType}`)
let columnName = 'City'
let validationString = (true == roles[roleType].validations.editSchema) ? 'exist' : 'not.exist'
// create table options
//
cy.get('.add-btn').should(validationString)
cy.get('.v-tabs-bar').eq(0).find('button.mdi-plus-box').should(validationString)
// delete table option
//
cy.get('.nc-table-delete-btn').should(validationString)
// add new column option
//
cy.get('.new-column-header').should(validationString)
// update column (edit/ delete menu)
//
cy.get(`th:contains(${columnName}) .mdi-menu-down`).should(validationString)
}
// read &/ update comment
// Viewer: only allowed to read
// Everyone else: read &/ update
//
const editComment = (roleType) => {
cy.log(`##### editComment: ${roleType}`)
// TODO: to be fixed for roleType = 'editor'
// Unhandled exception
if (roleType == 'viewer')
return false
let columnName = 'City'
let validationString = (true == roles[roleType].validations.editComment) ? 'Comment added successfully' : 'Not allowed'
cy.openTableTab(columnName)
// click on comment icon & type comment
//
cy.get('.v-input.row-checkbox').eq(4).next().next().click({ force: true })
//cy.get('.nc-row-expand-icon').eq(4).click({ force: true })
cy.getActiveModal().find('.mdi-comment-multiple-outline').should('exist').click()
cy.getActiveModal().find('.comment-box').type('Comment-1{enter}')
cy.getActiveModal().find('.mdi-door-open').click()
// Expected response:
// Viewer: Not allowed
// Everyone else: Comment added successfully
//
cy.get('body').contains(validationString, { timeout: 2000 }).should('exist')
cy.wait(1000)
cy.getActiveModal().find('button').contains('Cancel').click()
cy.get('body').type('{esc}')
}
// right navigation menu bar
// Editor/Viewer/Commenter : can only view 'existing' views
// Rest: can create/edit
const viewMenu = (roleType) => {
cy.log(`##### viewMenu: ${roleType}`)
// TODO: to be fixed for roleType = 'editor'
// Unhandled exception
if (roleType == 'viewer')
return false
let columnName = 'City'
let navDrawListCnt = 2
cy.openTableTab(columnName)
let validationString = (true == roles[roleType].validations.shareView) ? 'exist' : 'not.exist'
// validate if Share button is visible at header tool bar
cy.get('header.v-toolbar').eq(0).find('button:contains("Share")').should(validationString)
// Owner, Creator will have two navigation drawer (on each side of center panel)
if (roleType == 'owner' || roleType == 'creator') {
navDrawListCnt = 4
}
cy.get('.v-navigation-drawer__content').eq(1).find('[role="list"]').should('have.length', navDrawListCnt)
// view list field (default GRID view)
cy.get(`.nc-view-item`).should('exist')
// view create option, exists only for owner/ creator
cy.get(`.nc-create-gallery-view`).should(validationString)
cy.get(`.nc-create-grid-view`).should(validationString)
cy.get(`.nc-create-form-view`).should(validationString)
// share view & automations, exists only for owner/creator
cy.get(`.nc-share-view`).should(validationString)
cy.get(`.nc-automations`).should(validationString)
// redundant
// cy.get('.v-navigation-drawer__content').eq(1).find('.v-list-item').eq(0).contains('Views').should('exist')
// cy.get('.v-navigation-drawer__content').eq(1).find('.v-list-item').eq(1).contains('City').should('exist')
// cy.get(`.nc-create-grid-view`).should(validationString)
// cy.get(`.nc-create-gallery-view`).should(validationString)
}
///////////////////////////////////////////////////////////
//// Test Suite
@ -251,56 +20,69 @@ export const genTest = (type, xcdb, roleType) => {
before(() => {
loginPage.loginAndOpenProject(type, xcdb)
})
// before(() => {
// loginPage.signIn(roles.owner.credentials)
// projectsPage.openProject('externalREST')
// })
after(() => {
mainPage.navigationDraw(mainPage.ROLE_VIEW).contains('Reset Preview').click()
cy.wait(3000)
cy.get('.nc-preview-reset').click({ force: true })
cy.wait(20000)
mainPage.navigationDraw(mainPage.ROLE_VIEW).contains('Reset Preview').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')
})
const genTestSub = (roleType) => {
it(`Role type: ${roleType}`, (done) => {
// known issue: to be fixed
// right click raising alarm 'not allowed' for viewer
//
cy.on('uncaught:exception', (err, runnable) => {
expect(err.message).to.include('Not allowed')
done()
return false
})
mainPage.navigationDraw(mainPage.ROLE_VIEW).contains(roleType).click()
it(`Role preview: ${roleType}: Enable preview`, () => {
cy.get(`.nc-preview-${roleType}`).click()
cy.wait(3000)
cy.openTableTab('City')
})
advancedSettings(roleType)
editData(roleType)
editComment(roleType)
viewMenu(roleType)
editSchema(roleType)
it(`Role preview: ${roleType}: Advance settings`, () => {
// project configuration settings
//
_advSettings(roleType, true)
})
cy.wait(100).then(() => {
done()
})
it(`Role preview: ${roleType}: Edit data`, () => {
// Table data related validations
// - Add/delete/modify row
//
_editData(roleType, true)
})
it(`Role preview: ${roleType}: Edit comment`, () => {
// read &/ update comment
// Viewer: only allowed to read
// Everyone else: read &/ update
//
_editComment(roleType, true)
})
it(`Role preview: ${roleType}: Preview menu`, () => {
// right navigation menu bar
// Editor/Viewer/Commenter : can only view 'existing' views
// Rest: can create/edit
_viewMenu(roleType, true)
})
it(`Role preview: ${roleType}: Edit Schema`, () => {
// Schema related validations
// - Add/delete table
// - Add/Update/delete column
//
_editSchema(roleType, true)
})
}
genTestSub('editor')
genTestSub('commenter')
// disabled, to be fixed.
// genTestSub('viewer')
})
}
// genTest('rest', false)
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd

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

@ -0,0 +1,174 @@
import { mainPage } from "../../support/page_objects/mainPage"
import { roles } from "../../support/page_objects/projectConstants"
// Left hand navigation bar, validation for
// 1. Audit menu
// 2. Advance settings menu
// 3. Preview mode menu
//
export function _advSettings(roleType, previewMode) {
let validationString = (true == roles[roleType].validations.advSettings) ? 'exist' : 'not.exist'
// audit/advance settings menu visible only for owner/ creator
mainPage.navigationDraw(mainPage.AUDIT).should(validationString)
mainPage.navigationDraw(mainPage.APPSTORE).should(validationString)
mainPage.navigationDraw(mainPage.TEAM_N_AUTH).should(validationString)
mainPage.navigationDraw(mainPage.PROJ_METADATA).should(validationString)
// option to add new user conditionally visible only to owner/ creator
cy.get('button:contains("New User")').should(validationString)
if (true == previewMode) {
// preview mode, role toggle menubar is visible
mainPage.navigationDraw(mainPage.ROLE_VIEW_EDITOR).should('exist')
mainPage.navigationDraw(mainPage.ROLE_VIEW_COMMENTER).should('exist')
mainPage.navigationDraw(mainPage.ROLE_VIEW_VIEWER).should('exist')
mainPage.navigationDraw(mainPage.ROLE_VIEW_RESET).should('exist')
} else {
// normal mode, role toggle menubar is visible only for owner/ creator
mainPage.navigationDraw(mainPage.ROLE_VIEW_EDITOR).should(validationString)
mainPage.navigationDraw(mainPage.ROLE_VIEW_COMMENTER).should(validationString)
mainPage.navigationDraw(mainPage.ROLE_VIEW_VIEWER).should(validationString)
}
}
export function _editSchema(roleType, previewMode) {
let columnName = 'City'
let validationString = (true == roles[roleType].validations.editSchema) ? 'exist' : 'not.exist'
if (false == previewMode) {
cy.openTableTab(columnName)
}
// create table options
//
cy.get('.add-btn').should(validationString)
cy.get('.v-tabs-bar').eq(0).find('button.mdi-plus-box').should(validationString)
// delete table option
//
cy.get('.nc-table-delete-btn').should(validationString)
// add new column option
//
cy.get('.new-column-header').should(validationString)
// update column (edit/ delete menu)
//
cy.get(`th:contains(${columnName}) .mdi-menu-down`).should(validationString)
}
export function _editData(roleType, previewMode) {
let columnName = 'City'
let validationString = (true == roles[roleType].validations.editData) ? 'exist' : 'not.exist'
cy.openTableTab(columnName)
// add new row option (from menu header)
//
cy.get('.nc-add-new-row-btn').should(validationString)
// update row option (right click)
//
cy.get(`tbody > :nth-child(4) > [data-col="City"]`).rightclick()
cy.get('.menuable__content__active').should(validationString)
if (validationString == 'exist') {
// right click options will exist (only for 'exist' case)
//
cy.getActiveMenu().contains('Insert New Row').should(validationString)
cy.getActiveMenu().contains('Delete Row').should(validationString)
cy.getActiveMenu().contains('Delete Selected Rows').should(validationString)
cy.get('body').type('{esc}')
// update cell contents option using row expander should be enabled
//
//cy.get('.nc-row-expand-icon').eq(4).click({ force: true })
cy.get('.v-input.row-checkbox').eq(4).next().next().click({ force: true })
cy.getActiveModal().find('button').contains('Save Row').should('exist')
cy.get('body').type('{esc}')
}
else {
// update cell contents option using row expander should be disabled
//
//cy.get('.nc-row-expand-icon').eq(4).click({ force: true })
cy.get('.v-input.row-checkbox').eq(4).next().next().click({ force: true })
cy.getActiveModal().find('button:disabled').contains('Save Row').should('exist')
cy.getActiveModal().find('button').contains('Cancel').click()
cy.get('body').type('{esc}')
}
// double click cell entries to edit
//
cy.get(`tbody > :nth-child(4) > [data-col="City"]`).dblclick().find('input').should(validationString)
}
// read &/ update comment
// Viewer: only allowed to read
// Everyone else: read &/ update
//
export function _editComment(roleType, previewMode) {
let columnName = 'City'
let validationString = (true == roles[roleType].validations.editComment) ? 'Comment added successfully' : 'Not allowed'
cy.openTableTab(columnName)
// click on comment icon & type comment
//
cy.get('.v-input.row-checkbox').eq(4).next().next().click({ force: true })
//cy.get('.nc-row-expand-icon').eq(4).click({ force: true })
cy.getActiveModal().find('.mdi-comment-multiple-outline').should('exist').click()
cy.getActiveModal().find('.comment-box').type('Comment-1{enter}')
cy.getActiveModal().find('.mdi-door-open').click()
// Expected response:
// Viewer: Not allowed
// Everyone else: Comment added successfully
//
cy.get('body').contains(validationString, { timeout: 2000 }).should('exist')
cy.wait(1000)
cy.getActiveModal().find('button').contains('Cancel').click()
cy.get('body').type('{esc}')
}
// right navigation menu bar
// Editor/Viewer/Commenter : can only view 'existing' views
// Rest: can create/edit
export function _viewMenu(roleType, previewMode) {
let columnName = 'City'
let navDrawListCnt = 2
cy.openTableTab(columnName)
let validationString = (true == roles[roleType].validations.shareView) ? 'exist' : 'not.exist'
// validate if Share button is visible at header tool bar
cy.get('header.v-toolbar').eq(0).find('button:contains("Share")').should(validationString)
// Owner, Creator will have two navigation drawer (on each side of center panel)
if (roleType == 'owner' || roleType == 'creator') {
navDrawListCnt = 4
}
cy.get('.v-navigation-drawer__content').eq(1).find('[role="list"]').should('have.length', navDrawListCnt)
// view list field (default GRID view)
cy.get(`.nc-view-item`).should('exist')
// view create option, exists only for owner/ creator
cy.get(`.nc-create-gallery-view`).should(validationString)
cy.get(`.nc-create-grid-view`).should(validationString)
cy.get(`.nc-create-form-view`).should(validationString)
// share view & automations, exists only for owner/creator
cy.get(`.nc-share-view`).should(validationString)
cy.get(`.nc-automations`).should(validationString)
}

33
scripts/cypress/support/page_objects/mainPage.js

@ -35,12 +35,14 @@ export class _mainPage {
this.TEAM_N_AUTH = 3
this.PROJ_METADATA = 4
this.ROLE_VIEW = 5
this.ROLE_VIEW_EDITOR = 6
this.ROLE_VIEW_COMMENTER = 7
this.ROLE_VIEW_VIEWER = 8
this.ROLE_VIEW_RESET = 9
this.roleURL = {}
}
toolBarTopLeft(toolBarItem) {
return cy.get('header.v-toolbar', {timeout: 20000}).eq(0).find('a').eq(toolBarItem)
}
@ -50,10 +52,29 @@ export class _mainPage {
}
navigationDraw(item) {
if (item == this.ROLE_VIEW)
return cy.get('.nc-nav-drawer').find('.v-list').last()
else
return cy.get('.nc-nav-drawer').find('.v-list > .v-list-item').eq(item)
// if (item == this.ROLE_VIEW)
// return cy.get('.nc-nav-drawer').find('.v-list').last()
// else
// return cy.get('.nc-nav-drawer').find('.v-list > .v-list-item').eq(item)
switch (item) {
case this.AUDIT:
return cy.get('.nc-treeview-item-Audit')
case this.APPSTORE:
return cy.get('.nc-settings-appstore')
case this.TEAM_N_AUTH:
return cy.get('.nc-settings-teamauth')
case this.PROJ_METADATA:
return cy.get('.nc-settings-projmeta')
case this.ROLE_VIEW_EDITOR:
return cy.get('.nc-preview-editor')
case this.ROLE_VIEW_COMMENTER:
return cy.get('.nc-preview-commenter')
case this.ROLE_VIEW_VIEWER:
return cy.get('.nc-preview-viewer')
case this.ROLE_VIEW_RESET:
return cy.get('.nc-preview-reset')
}
}

Loading…
Cancel
Save