Browse Source

(test) cypress: base share validation suite, first revision

Signed-off-by: Raju Udava <sivadstala@gmail.com>
pull/765/head
Raju Udava 3 years ago
parent
commit
f8e5fe53f8
  1. 4
      packages/nc-gui/components/notification.vue
  2. 12
      packages/nc-gui/layouts/default.vue
  3. 59
      scripts/cypress/integration/common/5a_user_role.js
  4. 13
      scripts/cypress/integration/common/5b_preview_role.js
  5. 91
      scripts/cypress/integration/common/6g_base_share.js
  6. 12
      scripts/cypress/integration/spec/roleValidation.spec.js
  7. 2
      scripts/cypress/integration/test/gqlMisc.js
  8. 2
      scripts/cypress/integration/test/restMisc.js
  9. 10
      scripts/cypress/support/index.js

4
packages/nc-gui/components/notification.vue

@ -10,11 +10,11 @@
mdi-exclamation
</v-icon>
</template>
<v-icon v-ripple="{class : 'nc-ripple'}" size="20" v-on="on">
<v-icon v-ripple="{class : 'nc-ripple'}" size="20" class="nc-menu-alert" v-on="on">
mdi-bell-ring
</v-icon>
</v-badge>
<v-icon v-else v-ripple="{class : 'nc-ripple'}" size="20" v-on="on">
<v-icon v-else v-ripple="{class : 'nc-ripple'}" size="20" class="nc-menu-alert" v-on="on">
mdi-bell-ring
</v-icon>
<v-progress-circular

12
packages/nc-gui/layouts/default.vue

@ -99,12 +99,12 @@
<v-spacer />
<v-toolbar-items class="hidden-sm-and-down">
<v-toolbar-items class="hidden-sm-and-down nc-topright-menu">
<release-info />
<template v-if="isDashboard">
<div>
<x-btn v-if="_isUIAllowed('add-user')" small color="white" btn-class="primary--text" @click="rolesTabAdd">
<x-btn v-if="_isUIAllowed('add-user')" small color="white" btn-class="primary--text nc-menu-share" @click="rolesTabAdd">
<v-icon small class="mr-1">
mdi-account-supervisor-outline
</v-icon>
@ -114,7 +114,7 @@
<v-tooltip bottom>
<template #activator="{ on }">
<v-icon v-ripple="{class : 'nc-ripple'}" class="mt-1 ml-3" size="22" v-on="on" @click="$store.commit('windows/MutToggleTheme')">
<v-icon v-ripple="{class : 'nc-ripple'}" class="mt-1 ml-3 nc-menu-theme" size="22" v-on="on" @click="$store.commit('windows/MutToggleTheme')">
mdi-format-color-fill
</v-icon>
</template>
@ -130,7 +130,7 @@
<v-icon
v-ripple="{class : 'nc-ripple'}"
size="20"
class="ml-3"
class="ml-3 nc-menu-dark-theme"
@click="changeTheme"
v-on="on"
>
@ -287,7 +287,7 @@
open-on-hover
>
<template #activator="{ on }">
<v-btn v-ge="['Profile','']" text class="font-weight-bold" v-on="on">
<v-btn v-ge="['Profile','']" text class="font-weight-bold nc-menu-account" v-on="on">
<v-icon v-if="role && roleIcon[role]" size="20">
{{ roleIcon[role] }}
</v-icon>
@ -403,7 +403,7 @@
</v-menu>
<v-menu v-else offset-y open-on-hover>
<template #activator="{ on }">
<v-btn v-ge="['Profile','']" text class=" font-weight-bold" v-on="on">
<v-btn v-ge="['Profile','']" text class=" font-weight-bold nc-menu-account" v-on="on">
<!-- Menu-->
<v-icon>mdi-account</v-icon>
<v-icon>arrow_drop_down</v-icon>

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

@ -2,7 +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"
import { _advSettings, _editSchema, _editData, _editComment, _viewMenu } from "../spec/roleValidation.spec"
import { _advSettings, _editSchema, _editData, _editComment, _viewMenu, _topRightMenu } from "../spec/roleValidation.spec"
export const genTest = (type, xcdb) => {
if (!isTestSuiteActive(type, xcdb)) return;
@ -67,83 +67,48 @@ export const genTest = (type, xcdb) => {
///////////////////////////////////////////////////////
// Test suite
const errHndl = (err, runnable, done) => {
expect(err.message).to.include('Not allowed')
done()
return false
}
it(`[${roles[roleType].name}] Left navigation menu, New User add`, (done) => {
cy.on('uncaught:exception', (err, runnable) => errHndl(err, runnable, done))
it(`[${roles[roleType].name}] Left navigation menu, New User add`, () => {
// 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) => errHndl(err, runnable, done))
it(`[${roles[roleType].name}] Schema: create table, add/modify/delete column`, () => {
// Schema related validations
// - Add/delete table
// - Add/Update/delete column
//
_editSchema(roleType, false)
cy.wait(2000).then(() => {
done()
})
})
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) => errHndl(err, runnable, done))
it(`[${roles[roleType].name}] Data: add/modify/delete row, update cell contents`, () => {
// Table data related validations
// - Add/delete/modify row
//
_editData(roleType, false)
cy.wait(2000).then(() => {
done()
})
})
it(`[${roles[roleType].name}] Comments: view/add`, (done) => {
cy.on('uncaught:exception', (err, runnable) => errHndl(err, runnable, done))
it(`[${roles[roleType].name}] Comments: view/add`, () => {
// read &/ update comment
// Viewer: only allowed to read
// Everyone else: read &/ update
//
if (roleType != 'viewer')
_editComment(roleType, false)
cy.wait(2000).then(() => {
done()
})
})
it(`[${roles[roleType].name}] Right navigation menu, share view`, (done) => {
cy.on('uncaught:exception', (err, runnable) => errHndl(err, runnable, done))
it(`[${roles[roleType].name}] Right navigation menu, share view`, () => {
// right navigation menu bar
// Editor/Viewer/Commenter : can only view 'existing' views
// Rest: can create/edit
_viewMenu(roleType, false)
})
cy.wait(2000).then(() => {
done()
})
it(`[${roles[roleType].name}] Top Right Menu bar`, () => {
// Share button is conditional
// Rest are static/ mandatory
//
_topRightMenu(roleType, false)
})
it(`[${roles[roleType].name}] Download files`, () => {

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

@ -6,7 +6,7 @@
import { loginPage, projectsPage } from "../../support/page_objects/navigation"
import { mainPage } from "../../support/page_objects/mainPage"
import { isTestSuiteActive } from "../../support/page_objects/projectConstants"
import { _advSettings, _editSchema, _editData, _editComment, _viewMenu } from "../spec/roleValidation.spec"
import { _advSettings, _editSchema, _editData, _editComment, _viewMenu, _topRightMenu } from "../spec/roleValidation.spec"
export const genTest = (type, xcdb, roleType) => {
@ -66,6 +66,13 @@ export const genTest = (type, xcdb, roleType) => {
_viewMenu(roleType, true)
})
it(`Role preview: ${roleType}: Top Right Menu bar`, () => {
// Share button is conditional
// Rest are static/ mandatory
//
_topRightMenu(roleType, false)
})
it(`Role preview: ${roleType}: Edit Schema`, () => {
// Schema related validations
// - Add/delete table
@ -77,9 +84,7 @@ export const genTest = (type, xcdb, roleType) => {
genTestSub('editor')
genTestSub('commenter')
// disabled, to be fixed.
// genTestSub('viewer')
genTestSub('viewer')
})
}

91
scripts/cypress/integration/common/6g_base_share.js

@ -0,0 +1,91 @@
import { mainPage } from "../../support/page_objects/mainPage"
import { projectsPage } from "../../support/page_objects/navigation"
import { isTestSuiteActive } from "../../support/page_objects/projectConstants"
import { _advSettings, _editSchema, _editData, _editComment, _viewMenu, _topRightMenu } from "../spec/roleValidation.spec"
let linkText = ''
export const genTest = (type, xcdb) => {
if(!isTestSuiteActive(type, xcdb)) return;
describe(`${type.toUpperCase()} Columns of type attachment`, () => {
// before(() => {
// cy.openTableTab('Country');
// })
// after(() => {
// cy.closeTableTab('Country')
// })
it(`Generate base share URL`, () => {
// click SHARE
cy.get('.nc-topright-menu')
.find('.nc-menu-share')
.click()
// Click on readonly base text
cy.getActiveModal()
.find('.nc-container')
.contains('Generate publicly shareable readonly base')
.click()
// Select 'Readonly link'
cy.getActiveMenu()
.find('.caption')
.contains('Readonly link')
.click()
// Copy URL
cy.getActiveModal()
.find('.nc-url')
.then(($obj) => {
cy.log($obj[0])
linkText = $obj[0].innerText
})
})
it(`Visit base shared URL`, () => {
cy.log(linkText)
// visit URL & wait for page load to complete
cy.visit(linkText)
projectsPage.waitHomePageLoad()
})
it(`Validate access permissions`, () => {
let roleType = 'viewer'
cy.get(`[href="#roles||||Team & Auth "]`).find('button.mdi-close').click()
_advSettings(roleType, false)
_editSchema(roleType, false)
_editData(roleType, false)
_editComment(roleType, false)
_viewMenu(roleType, false)
_topRightMenu(roleType, false)
})
})
}
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
*
* @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/>.
*
*/

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

@ -172,3 +172,15 @@ export function _viewMenu(roleType, previewMode) {
cy.get(`.nc-share-view`).should(validationString)
cy.get(`.nc-automations`).should(validationString)
}
export function _topRightMenu(roleType, previewMode) {
let validationString = (true == roles[roleType].validations.shareView) ? 'exist' : 'not.exist'
cy.get('.nc-topright-menu').find('.nc-menu-share').should(validationString)
cy.get('.nc-topright-menu').find('.nc-menu-theme').should('exist')
cy.get('.nc-topright-menu').find('.nc-menu-dark-theme').should('exist')
cy.get('.nc-topright-menu').find('.nc-menu-translate').should('exist')
cy.get('.nc-topright-menu').find('.nc-menu-account').should('exist')
cy.get('.nc-topright-menu').find('.nc-menu-alert').should('exist')
}

2
scripts/cypress/integration/test/gqlMisc.js

@ -6,6 +6,7 @@ let t6c = require('../common/6c_swagger_api')
let t6d = require('../common/6d_language_validation')
let t6e = require('../common/6e_project_operations')
let t6f = require('../common/6f_attachments')
let t6g = require('../common/6g_base_share')
// use 0 as mode to execute individual files (debug mode, skip pre-configs)
// use 1 mode if noco.db doesnt contain user credentials (full run over GIT)
@ -23,6 +24,7 @@ const nocoTestSuite = (type, xcdb) => {
t6c.genTest(type, xcdb)
t6d.genTest(type, xcdb)
t6f.genTest(type, xcdb)
t6g.genTest(type, xcdb)
// **deletes created project, hence place it @ end
t6e.genTest(type, xcdb)
}

2
scripts/cypress/integration/test/restMisc.js

@ -6,6 +6,7 @@ let t6c = require('../common/6c_swagger_api')
let t6d = require('../common/6d_language_validation')
let t6e = require('../common/6e_project_operations')
let t6f = require('../common/6f_attachments')
let t6g = require('../common/6g_base_share')
// use 0 as mode to execute individual files (debug mode, skip pre-configs)
// use 1 mode if noco.db doesnt contain user credentials (full run over GIT)
@ -23,6 +24,7 @@ const nocoTestSuite = (type, xcdb) => {
t6d.genTest(type, xcdb)
t6c.genTest(type, xcdb)
t6f.genTest(type, xcdb)
t6g.genTest(type, xcdb)
// **deletes created project, hence place it @ end
t6e.genTest(type, xcdb)
}

10
scripts/cypress/support/index.js

@ -18,3 +18,13 @@ import './commands'
// Alternatively you can use CommonJS syntax:
// require('./commands')
Cypress.on('uncaught:exception', (err, runnable) => {
// returning false here prevents Cypress from
// failing the test
console.log('uncaught:exception')
console.log(err)
console.log(runnable)
return false
})

Loading…
Cancel
Save