Browse Source

test: [cypress] Share view

Signed-off-by: dstala <sivadstala@gmail.com>
pull/559/head
dstala 3 years ago
parent
commit
c5672da86c
  1. 157
      cypress/integration/common/share_view.js
  2. 51
      cypress/integration/ncTest.spec.js
  3. 18
      cypress/support/page_objects/navigation.js
  4. 9
      cypress/support/page_objects/projectConstants.js

157
cypress/integration/common/share_view.js

@ -0,0 +1,157 @@
import { loginPage, projectsPage } from "../../support/page_objects/navigation"
const shareViewWithPwd = (pwdCorrect, pwd) => {
cy.get('.v-navigation-drawer__content > .container')
.find('.v-list > .v-list-item')
.contains('Share View')
.click()
// No password- unprotected link
if(''==pwd) {
// copy link text, visit URL
cy.getActiveModal().find('.share-link-box')
.contains('http', {timeout: 2000})
.then(($obj) => {
let linkText = $obj.text()
cy.log(linkText)
cy.visit(linkText)
// wait for share view page to load!
cy.wait(5000)
cy.get('body').find('.v-dialog.v-dialog--active').should('not.exist')
})
// password protected link
} else {
// enable checkbox & feed pwd, save
cy.getActiveModal().find('[role="switch"][type="checkbox"]').click( {force: true} )
cy.getActiveModal().find('input[type="password"]').type('123456')
cy.getActiveModal().find('button:contains("Save password")').click()
// copy link text, visit URL
cy.getActiveModal().find('.share-link-box')
.then(($obj) => {
let linkText = $obj.text()
cy.log(linkText)
cy.visit(linkText)
// wait for share view page to load!
cy.wait(5000)
// feed password
cy.getActiveModal().find('input[type="password"]').type(pwd)
cy.getActiveModal().find('button:contains("Unlock")').click()
cy.wait(1000)
// if pwd is incorrect, active modal requesting to feed in password again
// will remain
if(pwdCorrect) {
cy.get('body').find('.v-dialog.v-dialog--active').should('not.exist')
}
else {
cy.get('body').find('.v-dialog.v-dialog--active').should('exist')
}
})
}
}
// delete created views
//
const deleteCreatedViews = () => {
cy.get('.v-navigation-drawer__content > .container')
.find('.v-list > .v-list-item')
.contains('Share View')
.parent().find('button.mdi-dots-vertical').click()
cy.getActiveMenu().find('.v-list-item').contains('Views List').click()
cy.get(1000)
cy.get('th:contains("View Link")').parent().parent()
.next().find('tr').each((tableRow) => {
cy.wrap(tableRow).find('button').last().click()
cy.wait(1000)
})
}
const genTest = (type) => {
describe(`${type.toUpperCase()} api - Clipboard access`, () => {
let projectName
// create project with default credentials to work with
//
before( () => {
loginPage.signIn({ username: 'user@nocodb.com', password: 'Password123.' })
if(type == 'rest')
projectName = projectsPage.createDefaulRestProject()
else
projectName = projectsPage.createDefaultGraphQlProject()
})
// Run once before test- create project (rest/graphql)
//
beforeEach(() => {
loginPage.signIn({ username: 'user@nocodb.com', password: 'Password123.' })
projectsPage.openProject(projectName)
cy.openTableTab('City');
})
it('Share view without password', () => {
shareViewWithPwd(true, '')
})
it('Share view with correct password', () => {
shareViewWithPwd(true, '123456')
})
it('Share view with incorrect password', () => {
shareViewWithPwd(false, 'abc')
})
it('Delete view', deleteCreatedViews )
// clean up
after( () => {
loginPage.signIn({ username: 'user@nocodb.com', password: 'Password123.' })
projectsPage.deleteProject(projectName)
})
})
}
genTest('rest')
genTest('graphql')
/**
* @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/>.
*
*/

51
cypress/integration/ncTest.spec.js

@ -1,10 +1,3 @@
/**
* file: ncTest.Spec.js
* purpose: test-suite-1
* author: raju udava
* date: 06 Sep 2020
*
**/
import { loginPage, projectsPage } from "../support/page_objects/navigation"
@ -45,9 +38,53 @@ describe('Login & project page', () => {
projectsPage.deleteProject(projectName)
})
it('3. Create project: NC_DB_EXTERNAL, NC_REST', () => {
const projectParams = { dbType: 1, apiType: 1, name: 'externalREST' }
const databaseParams = {
databaseType: 0,
hostAddress: 'localhost',
portNumber: '3306',
username: 'root',
password: 'password',
databaseName: 'sakila'
}
projectName = projectsPage.createProject(projectParams, databaseParams)
})
it('3a. Delete project: NC_DB_EXTERNAL, NC_REST', () => {
projectsPage.deleteProject(projectName)
})
// Needs to be conditionally triggered if required
//
// it('N. Clean up: Delete call projects', () => {
// projectsPage.deleteAllProject()
// })
})
/**
* @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/>.
*
*/

18
cypress/support/page_objects/navigation.js

@ -1,3 +1,6 @@
import { defaultDbParams } from "./projectConstants"
///////////////////////////////////////////////////////////
// Sign in/ Sign up page
@ -23,7 +26,7 @@ export class _loginPage {
signIn(userCredentials) {
this.go(urlPool.ncUrlSignIn)
cy.get('input[type="text"]').type(userCredentials.username)
cy.get('input[type="text"]', {timeout: 6000}).type(userCredentials.username)
cy.get('input[type="password"]').type(userCredentials.password)
cy.get('button:contains("SIGN IN")').click()
@ -35,7 +38,7 @@ export class _loginPage {
signUp(userCredentials) {
this.go(urlPool.ncUrlSignUp)
cy.get('input[type="text"]').type(userCredentials.username)
cy.get('input[type="text"]', {timeout: 6000}).type(userCredentials.username)
cy.get('input[type="password"]').type(userCredentials.password)
cy.get('button:contains("SIGN UP")').click()
@ -162,6 +165,17 @@ export class _projectsPage {
}
}
// create REST default project (sakila DB)
//
createDefaulRestProject() {
return this.createProject({ dbType: 1, apiType: 0, name: '' }, defaultDbParams )
}
// create GraphQL default project (sakila DB)
//
createDefaultGraphQlProject() {
return this.createProject({ dbType: 1, apiType: 1, name: '' }, defaultDbParams )
}
// Click on refresh key on projects page
//

9
cypress/support/page_objects/projectConstants.js

@ -0,0 +1,9 @@
export const defaultDbParams = {
databaseType: 0,
hostAddress: 'localhost',
portNumber: '3306',
username: 'root',
password: 'password',
databaseName: 'sakila'
}
Loading…
Cancel
Save