Browse Source

[test] cypress: user role validation, reduce context switch

Signed-off-by: Raju Udava <sivadstala@gmail.com>
pull/693/head
Raju Udava 3 years ago
parent
commit
a1a417efec
  1. 76
      cypress/integration/common/00_pre_configurations.js
  2. 2
      cypress/integration/common/2a_table_with_belongs_to_colulmn.js
  3. 435
      cypress/integration/common/5a_user_role.js
  4. 8
      cypress/integration/test/masterSuiteGql.js
  5. 8
      cypress/integration/test/masterSuiteRest.js
  6. 25
      cypress/support/page_objects/mainPage.js

76
cypress/integration/common/00_pre_configurations.js

@ -32,44 +32,44 @@ export const genTest = (type, xcdb) => {
if (isTestSuiteActive('graphql', false)) createProject(staticProjects.externalGQL) if (isTestSuiteActive('graphql', false)) createProject(staticProjects.externalGQL)
}) })
describe('Static user creations (different roles)', () => { // describe('Static user creations (different roles)', () => {
beforeEach(() => { // beforeEach(() => {
loginPage.signIn(roles.owner.credentials) // loginPage.signIn(roles.owner.credentials)
projectsPage.openProject(getPrimarySuite().basic.name) // projectsPage.openProject(getPrimarySuite().basic.name)
}) // })
const addUser = (user) => { // const addUser = (user) => {
it(`RoleType: ${user.name}`, () => { // it(`RoleType: ${user.name}`, () => {
mainPage.addNewUserToProject(user.credentials, user.name) // mainPage.addNewUserToProject(user.credentials, user.name)
}) // })
} // }
addUser(roles.creator) // addUser(roles.creator)
addUser(roles.editor) // addUser(roles.editor)
addUser(roles.commenter) // addUser(roles.commenter)
addUser(roles.viewer) // addUser(roles.viewer)
}) // })
describe('Static users- add to other static projects', () => { // describe('Static users- add to other static projects', () => {
const addUserToProject = (proj) => { // const addUserToProject = (proj) => {
it(`Add users to ${proj.basic.name}`, () => { // it(`Add users to ${proj.basic.name}`, () => {
loginPage.signIn(roles.owner.credentials) // loginPage.signIn(roles.owner.credentials)
projectsPage.openProject(proj.basic.name) // projectsPage.openProject(proj.basic.name)
mainPage.addExistingUserToProject(roles.creator.credentials.username, roles.creator.name) // mainPage.addExistingUserToProject(roles.creator.credentials.username, roles.creator.name)
mainPage.addExistingUserToProject(roles.editor.credentials.username, roles.editor.name) // mainPage.addExistingUserToProject(roles.editor.credentials.username, roles.editor.name)
mainPage.addExistingUserToProject(roles.commenter.credentials.username, roles.commenter.name) // mainPage.addExistingUserToProject(roles.commenter.credentials.username, roles.commenter.name)
mainPage.addExistingUserToProject(roles.viewer.credentials.username, roles.viewer.name) // mainPage.addExistingUserToProject(roles.viewer.credentials.username, roles.viewer.name)
}) // })
} // }
if (isSecondarySuite('rest', true)) addUserToProject(staticProjects.sampleREST) // if (isSecondarySuite('rest', true)) addUserToProject(staticProjects.sampleREST)
if (isSecondarySuite('graphql', true)) addUserToProject(staticProjects.sampleGQL) // if (isSecondarySuite('graphql', true)) addUserToProject(staticProjects.sampleGQL)
if (isSecondarySuite('rest', false)) addUserToProject(staticProjects.externalREST) // if (isSecondarySuite('rest', false)) addUserToProject(staticProjects.externalREST)
if (isSecondarySuite('graphql', false)) addUserToProject(staticProjects.externalGQL) // if (isSecondarySuite('graphql', false)) addUserToProject(staticProjects.externalGQL)
}) // })
} }

2
cypress/integration/common/2a_table_with_belongs_to_colulmn.js

@ -14,7 +14,7 @@ export const genTest = (type, xcdb) => {
// column name validation // column name validation
cy.get(`.project-tab:contains(Country):visible`).should('exist') cy.get(`.project-tab:contains(Country):visible`).should('exist')
// URL validation // URL validation
cy.url().should('contain', `?name=Country&`) cy.url().should('contain', `name=Country`)
}) })
it('Expand belongs-to column', () => { it('Expand belongs-to column', () => {

435
cypress/integration/common/5a_user_role.js

@ -3,244 +3,291 @@ import { mainPage } from "../../support/page_objects/mainPage"
import { roles, staticProjects } from "../../support/page_objects/projectConstants" import { roles, staticProjects } from "../../support/page_objects/projectConstants"
import { isTestSuiteActive } from "../../support/page_objects/projectConstants" import { isTestSuiteActive } from "../../support/page_objects/projectConstants"
export const genTest = (type, roleType) => { // let roleURL = {}
if(!isTestSuiteActive(type, false)) return;
export const genTest = (type, xcdb) => {
describe(`User role validation`, () => { if (!isTestSuiteActive(type, xcdb)) return;
// project configuration settings describe('Static user creations (different roles)', () => {
// // beforeEach(() => {
const advancedSettings = (roleType) => { // loginPage.signIn(roles.owner.credentials)
// projectsPage.openProject(getPrimarySuite().basic.name)
// let validationString = (true == roleValidation[roleIdx].advSettings) ? 'exist' : 'not.exist' // })
let validationString = (true == roles[roleType].validations.advSettings) ? 'exist' : 'not.exist' before(() => {
mainPage.navigationDraw(mainPage.TEAM_N_AUTH).click()
// 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) const addUser = (user) => {
it(`RoleType: ${user.name}`, () => {
//let cred = { username: 'user4@nocodb.com', password: 'Password123.' }
//mainPage.addNewUserToProject(cred, user.name)
mainPage.addNewUserToProject(user.credentials, user.name)
})
} }
addUser(roles.creator)
addUser(roles.editor)
addUser(roles.commenter)
addUser(roles.viewer)
// Schema related validations it(`Logging purpose`, () => {
// - Add/delete table cy.log(mainPage.roleURL)
// - Add/Update/delete column })
// })
const editSchema = (roleType) => {
const roleValidation = (roleType) => {
let columnName = 'City' describe(`User role validation`, () => {
let validationString = (true == roles[roleType].validations.editSchema) ? 'exist' : 'not.exist'
if (roleType != 'owner') {
// create table options it(`[${roles[roleType].name}] SignIn, Open project`, () => {
// cy.visit(mainPage.roleURL[roleType])
cy.get('.add-btn').should(validationString) cy.wait(3000)
cy.get('.v-tabs-bar').eq(0).find('button.mdi-plus-box').should(validationString)
// Redirected to new URL, feed details
// open existing table-column //
// cy.get('input[type="text"]').type(roles[roleType].credentials.username)
cy.openTableTab(columnName) cy.get('input[type="password"]').type(roles[roleType].credentials.password)
cy.get('button:contains("SIGN UP")').click()
// delete table option
// cy.url({ timeout: 6000 }).should('contain', '#/project')
cy.get('.nc-table-delete-btn').should(validationString) cy.wait(1000)
// add new column option if('rest' == type)
// projectsPage.openProject(staticProjects.externalREST.basic.name)
cy.get('.new-column-header').should(validationString) else
projectsPage.openProject(staticProjects.externalGQL.basic.name)
})
}
// update column (edit/ delete menu) ///////////////////////////////////////////////////////
// // Test suite
cy.get(`th:contains(${columnName}) .mdi-menu-down`).should(validationString)
} // 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`, () => {
advancedSettings(roleType)
})
// Table data related validations it(`[${roles[roleType].name}] Schema: create table, add/modify/delete column`, () => {
// - Add/delete/modify row editSchema(roleType)
// })
const editData = (roleType) => {
let columnName = 'City' it(`[${roles[roleType].name}] Data: add/modify/delete row, update cell contents`, (/*done*/) => {
let validationString = (true == roles[roleType].validations.editData) ? 'exist' : 'not.exist'
cy.openTableTab(columnName) // known issue: to be fixed
// right click raising alarm 'not allowed' for viewer
// add new row option (from menu header) //
// // cy.on('uncaught:exception', (err, runnable) => {
cy.get('.nc-add-new-row-btn').should(validationString) // 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)
})
after(() => {
if ('viewer' == roleType) {
loginPage.loginAndOpenProject(type)
}
})
})
}
// skip owner validation as rest of the cases pretty much cover the same
// roleValidation('owner')
roleValidation('creator')
roleValidation('editor')
roleValidation('commenter')
roleValidation('viewer')
}
// update row option (right click) // project configuration settings
// //
cy.get(`tbody > :nth-child(8) > [data-col="City"]`).rightclick() const advancedSettings = (roleType) => {
cy.get('.menuable__content__active').should(validationString) // let validationString = (true == roleValidation[roleIdx].advSettings) ? 'exist' : 'not.exist'
let validationString = (true == roles[roleType].validations.advSettings) ? 'exist' : 'not.exist'
if (validationString == 'exist') { // hardwired to be enabled for all roles
mainPage.navigationDraw(mainPage.AUDIT).should('exist')
// right click options will exist (only for 'exist' case) mainPage.navigationDraw(mainPage.APPSTORE).should(validationString)
// mainPage.navigationDraw(mainPage.TEAM_N_AUTH).should(validationString)
cy.getActiveMenu().contains('Insert New Row').should(validationString) mainPage.navigationDraw(mainPage.PROJ_METADATA).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 // mainPage.navigationDraw(mainPage.ROLE_VIEW).should(validationString)
// if ('exist' == validationString) {
//cy.get('.nc-row-expand-icon').eq(4).click({ force: true }) mainPage.navigationDraw(mainPage.ROLE_VIEW).contains('editor')
cy.get('.v-input.row-checkbox').eq(4).next().next().click({ force: true }) mainPage.navigationDraw(mainPage.ROLE_VIEW).contains('commenter')
cy.getActiveModal().find('button').contains('Save Row').should('exist') mainPage.navigationDraw(mainPage.ROLE_VIEW).contains('viewer')
cy.get('body').type('{esc}') }
} cy.get('button:contains("New User")').should(validationString)
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)
}
// read &/ update comment // Schema related validations
// Viewer: only allowed to read // - Add/delete table
// Everyone else: read &/ update // - Add/Update/delete column
// //
const editComment = (roleType) => { const editSchema = (roleType) => {
let columnName = 'City' let columnName = 'City'
let validationString = (true == roles[roleType].validations.editComment) ? 'Comment added successfully' : 'Not allowed' let validationString = (true == roles[roleType].validations.editSchema) ? 'exist' : 'not.exist'
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)
// click on comment icon & type comment // open existing table-column
// //
cy.openTableTab(columnName)
cy.get('.v-input.row-checkbox').eq(8).next().next().click({ force: true }) // delete table option
//cy.get('.nc-row-expand-icon').eq(4).click({ force: true }) //
cy.getActiveModal().find('.mdi-comment-multiple-outline').should('exist').click() cy.get('.nc-table-delete-btn').should(validationString)
cy.getActiveModal().find('.comment-box').type('Comment-1{enter}')
// Expected response: // add new column option
// Viewer: Not allowed //
// Everyone else: Comment added successfully cy.get('.new-column-header').should(validationString)
//
cy.get('body').contains(validationString, { timeout: 2000 }).should('exist')
cy.get('body').type('{esc}')
}
// right navigation menu bar // update column (edit/ delete menu)
// Editor/Viewer/Commenter : can only view 'existing' views //
// Rest: can create/edit cy.get(`th:contains(${columnName}) .mdi-menu-down`).should(validationString)
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
navDrawListItemCnt = 13
}
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 // Table data related validations
// cy.get('.v-navigation-drawer__content').eq(1).find('.v-list-item').eq(0).contains('Views').should('exist') // - Add/delete/modify row
// cy.get('.v-navigation-drawer__content').eq(1).find('.v-list-item').eq(1).contains('City').should('exist') //
const editData = (roleType) => {
// cy.get(`.nc-create-grid-view`).should(validationString) let columnName = 'City'
// cy.get(`.nc-create-gallery-view`).should(validationString) 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)
// Test suite //
cy.get(`tbody > :nth-child(8) > [data-col="City"]`).rightclick()
it(`[${roles[roleType].name}] SignIn, Open project`, () => { cy.get('.menuable__content__active').should(validationString)
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`, () => { if (validationString == 'exist') {
advancedSettings(roleType)
})
it(`[${roles[roleType].name}] Schema: create table, add/modify/delete column`, () => { // right click options will exist (only for 'exist' case)
editSchema(roleType) //
}) 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}')
it(`[${roles[roleType].name}] Data: add/modify/delete row, update cell contents`, (/*done*/) => { // 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)
}
// 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') // read &/ update comment
editData(roleType) // 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'
it(`[${roles[roleType].name}] Comments: view/add`, () => { cy.openTableTab(columnName)
// Fix me! // click on comment icon & type comment
if (roleType != 'viewer') //
editComment(roleType)
})
it(`[${roles[roleType].name}] Right navigation menu, share view`, () => { cy.get('.v-input.row-checkbox').eq(8).next().next().click({ force: true })
viewMenu(roleType) //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}')
after(() => { // Expected response:
loginPage.loginAndOpenProject(type) // Viewer: Not allowed
}) // Everyone else: Comment added successfully
}) //
cy.get('body').contains(validationString, { timeout: 2000 }).should('exist')
cy.get('body').type('{esc}')
} }
// genTest('rest', 'owner') // right navigation menu bar
// genTest('rest', 'creator') // Editor/Viewer/Commenter : can only view 'existing' views
// genTest('rest', 'editor') // Rest: can create/edit
// genTest('rest', 'commenter') const viewMenu = (roleType) => {
// genTest('rest', 'viewer')
// genTest('graphql', 'owner') let columnName = 'City'
// genTest('graphql', 'creator') let navDrawListCnt = 2
// genTest('graphql', 'editor') let navDrawListItemCnt = 5
// genTest('graphql', 'commenter') cy.openTableTab(columnName)
// genTest('graphql', 'viewer') 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
navDrawListItemCnt = 13
}
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)
}
/** /**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd * @copyright Copyright (c) 2021, Xgene Cloud Ltd

8
cypress/integration/test/masterSuiteGql.js

@ -51,13 +51,7 @@ const nocoTestSuite = (type, xcdb) => {
t4d.genTest(type, xcdb) t4d.genTest(type, xcdb)
t4e.genTest(type, xcdb) t4e.genTest(type, xcdb)
t4f.genTest(type, xcdb) t4f.genTest(type, xcdb)
t5a.genTest(type, xcdb)
t5a.genTest(type, 'owner')
t5a.genTest(type, 'creator')
t5a.genTest(type, 'editor')
t5a.genTest(type, 'commenter')
t5a.genTest(type, 'viewer')
t5b.genTest(type, xcdb) t5b.genTest(type, xcdb)
// merged with t1a: t6a.genTest(type, xcdb) // merged with t1a: t6a.genTest(type, xcdb)
t6c.genTest(type, xcdb) t6c.genTest(type, xcdb)

8
cypress/integration/test/masterSuiteRest.js

@ -51,13 +51,7 @@ const nocoTestSuite = (type, xcdb) => {
t4d.genTest(type, xcdb) t4d.genTest(type, xcdb)
t4e.genTest(type, xcdb) t4e.genTest(type, xcdb)
t4f.genTest(type, xcdb) t4f.genTest(type, xcdb)
t5a.genTest(type, xcdb)
t5a.genTest(type, 'owner')
t5a.genTest(type, 'creator')
t5a.genTest(type, 'editor')
t5a.genTest(type, 'commenter')
t5a.genTest(type, 'viewer')
t5b.genTest(type, xcdb) t5b.genTest(type, xcdb)
// merged with t1a: t6a.genTest(type, xcdb) // merged with t1a: t6a.genTest(type, xcdb)
t6c.genTest(type, xcdb) t6c.genTest(type, xcdb)

25
cypress/support/page_objects/mainPage.js

@ -23,8 +23,12 @@ export class _mainPage {
this.TEAM_N_AUTH = 3 this.TEAM_N_AUTH = 3
this.PROJ_METADATA = 4 this.PROJ_METADATA = 4
this.ROLE_VIEW = 5 this.ROLE_VIEW = 5
this.roleURL = {}
} }
toolBarTopLeft(toolBarItem) { toolBarTopLeft(toolBarItem) {
return cy.get('header.v-toolbar').eq(0).find('a').eq(toolBarItem) return cy.get('header.v-toolbar').eq(0).find('a').eq(toolBarItem)
} }
@ -64,19 +68,22 @@ export class _mainPage {
cy.getActiveModal().find('.v-alert').then(($obj) => { cy.getActiveModal().find('.v-alert').then(($obj) => {
linkText = $obj.text() linkText = $obj.text()
cy.log(linkText) cy.log(linkText)
this.roleURL[roleType] = linkText
cy.get('body').click('right')
cy.visit(linkText) // cy.visit(linkText)
cy.wait(3000) // cy.wait(3000)
// Redirected to new URL, feed details // // Redirected to new URL, feed details
// // //
cy.get('input[type="text"]').type(userCred.username) // cy.get('input[type="text"]').type(userCred.username)
cy.get('input[type="password"]').type(userCred.password) // cy.get('input[type="password"]').type(userCred.password)
cy.get('button:contains("SIGN UP")').click() // cy.get('button:contains("SIGN UP")').click()
cy.url({ timeout: 6000 }).should('contain', '#/project') // cy.url({ timeout: 6000 }).should('contain', '#/project')
cy.wait(1000) // cy.wait(1000)
}) })
} }

Loading…
Cancel
Save