mirror of https://github.com/nocodb/nocodb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
260 lines
9.6 KiB
260 lines
9.6 KiB
3 years ago
|
import { loginPage } from "../../support/page_objects/navigation"
|
||
|
import { mainPage } from "../../support/page_objects/mainPage"
|
||
|
import { roles } from "../../support/page_objects/projectConstants"
|
||
3 years ago
|
|
||
3 years ago
|
const genTest = (apiType, roleType) => {
|
||
3 years ago
|
|
||
3 years ago
|
describe(`User role validation`, () => {
|
||
3 years ago
|
|
||
3 years ago
|
// project configuration settings
|
||
3 years ago
|
//
|
||
3 years ago
|
const advancedSettings = (roleType) => {
|
||
3 years ago
|
|
||
3 years ago
|
// let validationString = (true == roleValidation[roleIdx].advSettings) ? 'exist' : 'not.exist'
|
||
|
let validationString = (true == roles[roleType].validations.advSettings) ? 'exist' : 'not.exist'
|
||
3 years ago
|
|
||
3 years ago
|
// hardwired to be enabled for all roles
|
||
|
mainPage.navigationDraw(mainPage.AUDIT).should('exist')
|
||
3 years ago
|
|
||
3 years ago
|
mainPage.navigationDraw(mainPage.APPSTORE).should(validationString)
|
||
|
mainPage.navigationDraw(mainPage.TEAM_N_AUTH).should(validationString)
|
||
|
mainPage.navigationDraw(mainPage.PROJ_METADATA).should(validationString)
|
||
3 years ago
|
|
||
3 years ago
|
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')
|
||
|
}
|
||
3 years ago
|
|
||
3 years ago
|
cy.get('button:contains("New User")').should(validationString)
|
||
3 years ago
|
|
||
3 years ago
|
}
|
||
3 years ago
|
|
||
|
|
||
3 years ago
|
// Schema related validations
|
||
|
// - Add/delete table
|
||
|
// - Add/Update/delete column
|
||
3 years ago
|
//
|
||
3 years ago
|
const editSchema = (roleType) => {
|
||
3 years ago
|
|
||
3 years ago
|
let columnName = 'City'
|
||
|
let validationString = (true == roles[roleType].validations.editSchema) ? 'exist' : 'not.exist'
|
||
3 years ago
|
|
||
3 years ago
|
// create table options
|
||
|
//
|
||
|
cy.get('.add-btn').should(validationString)
|
||
|
cy.get('.v-tabs-bar').eq(0).find('button.mdi-plus-box').should(validationString)
|
||
3 years ago
|
|
||
3 years ago
|
// open existing table-column
|
||
3 years ago
|
//
|
||
3 years ago
|
cy.openTableTab(columnName)
|
||
3 years ago
|
|
||
3 years ago
|
// delete table option
|
||
3 years ago
|
//
|
||
3 years ago
|
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)
|
||
3 years ago
|
|
||
|
}
|
||
3 years ago
|
|
||
|
|
||
|
// Table data related validations
|
||
|
// - Add/delete/modify row
|
||
|
//
|
||
|
const editData = (roleType) => {
|
||
|
|
||
|
let columnName = 'City'
|
||
|
let validationString = (true == roles[roleType].validations.editData) ? 'exist' : 'not.exist'
|
||
|
|
||
|
cy.openTableTab(columnName)
|
||
|
|
||
|
// add new row option (from menu header)
|
||
3 years ago
|
//
|
||
3 years ago
|
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.get('body').type('{esc}')
|
||
|
}
|
||
|
|
||
|
// double click cell entries to edit
|
||
|
//
|
||
|
cy.get(`tbody > :nth-child(4) > [data-col="City"]`).dblclick().find('input').should(validationString)
|
||
3 years ago
|
}
|
||
|
|
||
3 years ago
|
|
||
|
// read &/ update comment
|
||
|
// Viewer: only allowed to read
|
||
|
// Everyone else: read &/ update
|
||
3 years ago
|
//
|
||
3 years ago
|
const editComment = (roleType) => {
|
||
3 years ago
|
|
||
3 years ago
|
let columnName = 'City'
|
||
|
let validationString = (true == roles[roleType].validations.editComment) ? 'Comment added successfully' : 'Not allowed'
|
||
3 years ago
|
|
||
3 years ago
|
cy.openTableTab(columnName)
|
||
3 years ago
|
|
||
3 years ago
|
// click on comment icon & type comment
|
||
|
//
|
||
3 years ago
|
|
||
3 years ago
|
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}')
|
||
3 years ago
|
|
||
3 years ago
|
// Expected response:
|
||
|
// Viewer: Not allowed
|
||
|
// Everyone else: Comment added successfully
|
||
|
//
|
||
|
cy.get('body').contains(validationString, { timeout: 2000 }).should('exist')
|
||
|
cy.get('body').type('{esc}')
|
||
|
}
|
||
3 years ago
|
|
||
3 years ago
|
// right navigation menu bar
|
||
|
// Editor/Viewer/Commenter : can only view 'existing' views
|
||
|
// Rest: can create/edit
|
||
|
const viewMenu = (roleType) => {
|
||
|
|
||
|
let columnName = 'City'
|
||
|
let navDrawListCnt = 2
|
||
|
let navDrawListItemCnt = 5
|
||
|
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 (validationString == 'exist') {
|
||
|
navDrawListCnt = 4
|
||
3 years ago
|
navDrawListItemCnt = 13
|
||
3 years ago
|
}
|
||
|
cy.get('.v-navigation-drawer__content').eq(1).find('[role="list"]').should('have.length', navDrawListCnt)
|
||
|
cy.get('.v-navigation-drawer__content').eq(1).find('.v-list-item').should('have.length', navDrawListItemCnt)
|
||
|
|
||
|
// 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)
|
||
|
}
|
||
3 years ago
|
|
||
|
|
||
|
|
||
3 years ago
|
///////////////////////////////////////////////////////
|
||
|
// Test suite
|
||
3 years ago
|
|
||
3 years ago
|
it(`[${roles[roleType].name}] SignIn, Open project`, () => {
|
||
|
//loginPage.signIn(roles[roleType].credentials)
|
||
|
//projectsPage.openProject('sakilaDb')
|
||
|
loginPage.loginAndOpenProject(apiType)
|
||
3 years ago
|
})
|
||
3 years ago
|
|
||
3 years ago
|
it(`[${roles[roleType].name}] Left navigation menu, New User add`, () => {
|
||
|
advancedSettings(roleType)
|
||
|
})
|
||
3 years ago
|
|
||
3 years ago
|
it(`[${roles[roleType].name}] Schema: create table, add/modify/delete column`, () => {
|
||
|
editSchema(roleType)
|
||
|
})
|
||
|
|
||
|
it(`[${roles[roleType].name}] Data: add/modify/delete row, update cell contents`, (/*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
|
||
|
// })
|
||
|
|
||
|
if (roleType != 'editor')
|
||
|
editData(roleType)
|
||
|
|
||
|
// done()
|
||
|
})
|
||
|
|
||
|
it(`[${roles[roleType].name}] Comments: view/add`, () => {
|
||
|
|
||
|
// Fix me!
|
||
|
if (roleType != 'viewer')
|
||
|
editComment(roleType)
|
||
|
})
|
||
|
|
||
|
it(`[${roles[roleType].name}] Right navigation menu, share view`, () => {
|
||
|
viewMenu(roleType)
|
||
|
})
|
||
|
})
|
||
|
}
|
||
3 years ago
|
|
||
3 years ago
|
genTest('rest', 'owner')
|
||
|
genTest('rest', 'creator')
|
||
|
genTest('rest', 'editor')
|
||
|
genTest('rest', 'commenter')
|
||
|
genTest('rest', 'viewer')
|
||
|
genTest('graphql', 'owner')
|
||
|
genTest('graphql', 'creator')
|
||
|
genTest('graphql', 'editor')
|
||
|
genTest('graphql', 'commenter')
|
||
|
genTest('graphql', 'viewer')
|
||
3 years ago
|
|
||
|
|
||
|
/**
|
||
|
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
|
||
|
*
|
||
|
* @author Pranav C Balan <pranavxc@gmail.com>
|
||
|
* @author Raju Udava <sivadstala@gmail.com>
|
||
|
*
|
||
|
* @license GNU AGPL version 3 or any later version
|
||
|
*
|
||
|
* This program is free software: you can redistribute it and/or modify
|
||
|
* it under the terms of the GNU Affero General Public License as
|
||
|
* published by the Free Software Foundation, either version 3 of the
|
||
|
* License, or (at your option) any later version.
|
||
|
*
|
||
|
* This program is distributed in the hope that it will be useful,
|
||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
* GNU Affero General Public License for more details.
|
||
|
*
|
||
|
* You should have received a copy of the GNU Affero General Public License
|
||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||
|
*
|
||
|
*/
|