Browse Source

test: [cypress] file restructure & generic clean-up

Signed-off-by: Raju Udava <sivadstala@gmail.com>
pull/559/head
Raju Udava 3 years ago
parent
commit
c33d4b6f67
  1. 6
      cypress/integration/common/preview_role_spec.js
  2. 35
      cypress/integration/common/project_operations_spec.js
  3. 1
      cypress/integration/common/rollup_column.js
  4. 83
      cypress/integration/common/table_column_operations_spec.js
  5. 60
      cypress/integration/common/table_operations_spec.js
  6. 42
      cypress/integration/common/table_row_operations_spec.js
  7. 59
      cypress/integration/common/user_role_spec.js
  8. 37
      cypress/integration/common/users_spec.js
  9. 9
      cypress/support/commands.js
  10. 6
      cypress/support/page_objects/mainPage.js

6
cypress/integration/preview_role_spec.js → cypress/integration/common/preview_role_spec.js

@ -3,9 +3,9 @@
// user@nocodb.com signed up as admin
// sakilaDb database created already
import { loginPage, projectsPage } from "../support/page_objects/navigation"
import { mainPage } from "../support/page_objects/mainPage"
import { roles } from "../support/page_objects/projectConstants"
import { loginPage, projectsPage } from "../../support/page_objects/navigation"
import { mainPage } from "../../support/page_objects/mainPage"
import { roles } from "../../support/page_objects/projectConstants"
// should we reverify permissions after preview reset?
const reVerificationAfterReset = false

35
cypress/integration/common/project_operations_spec.js

@ -1,11 +1,14 @@
import { loginPage } from "../../support/page_objects/navigation"
import { roles } from "../../support/page_objects/projectConstants"
const genTest = (type) => {
describe(`${type.toUpperCase()} Project operations`, () => {
before(() => {
cy.waitForSpinners();
cy.signinOrSignup();
loginPage.signIn(roles.owner.credentials)
})
beforeEach(() => {
cy.restoreLocalStorage();
});
@ -30,7 +33,6 @@ const genTest = (type) => {
it('Stop Project', () => {
cy.visit('./#/projects')
// cy.get('.nc-rest-project-row .mdi-stop-circle-outline', {timeout: 10000}).last().trigger('onmouseover').trigger('mouseenter')
cy.get(`.nc-${type}-project-row .mdi-stop-circle-outline`, {timeout: 10000}).last().invoke('show').click();
cy.contains('Submit').closest('button').click();
});
@ -40,21 +42,42 @@ const genTest = (type) => {
cy.get(`.nc-${type}-project-row .mdi-play-circle-outline`, {timeout: 10000}).last().invoke('show').click();
cy.contains('Submit').closest('button').click();
});
it('Restart Project', () => {
cy.visit('./#/projects')
cy.get(`.nc-${type}-project-row .mdi-restart`, {timeout: 10000}).last().invoke('show').click();
cy.contains('Submit').closest('button').click();
});
it('Delete Project', () => {
cy.visit('./#/projects')
cy.get(`.nc-${type}-project-row .mdi-delete-circle-outline`, {timeout: 10000}).last().invoke('show').click();
cy.contains('Submit').closest('button').click();
});
})
}
genTest('rest')
genTest('graphql')
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
*
* @author Pranav C Balan <pranavxc@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/>.
*
*/

1
cypress/integration/common/rollup_column.js

@ -1,4 +1,3 @@
const genTest = (type) => {
describe(`${type.toUpperCase()} api - RollUp column`, () => {

83
cypress/integration/common/table_column_operations_spec.js

@ -1,9 +1,13 @@
import { loginPage } from "../../support/page_objects/navigation"
import { mainPage } from "../../support/page_objects/mainPage"
const genTest = (type) => {
describe(`${type.toUpperCase()} api - Table Column`, () => {
const name = 'Table' + Date.now();
const colName = 'column_name' + Date.now();
const updatedColName = 'updated_column_name' + Date.now();
const updatedColName = 'updated_column_name'
before(() => {
loginPage.loginAndOpenProject(type)
@ -16,33 +20,23 @@ const genTest = (type) => {
});
it('Create Table Column', () => {
// cy.get('.nc-project-tree').find('.v-list-item__title:contains(Tables)', {timeout: 10000})
// .first().click()
//
// cy.get('.nc-project-tree').contains(name, {timeout: 6000}).first().click({force: true});
cy.get(`.project-tab:contains(${name}):visible`).should('exist')
mainPage.addColumn(colName)
cy.get('.v-window-item--active .nc-grid tr > th:last button').click({force: true});
cy.get('.nc-column-name-input input').clear().type(colName)
cy.get('.nc-col-create-or-edit-card').contains('Save').click()
cy
.get(`th:contains(${colName})`)
.should('exist');
});
cy.get(`th:contains(${colName})`).should('exist');
// wait for pop up's to exit
cy.wait(3000)
})
// edit the newly created column
it('Edit table column - rename & uidt update', () => {
it('Edit table column - change datatype', () => {
cy.get(`th:contains(${colName}) .mdi-menu-down`)
.trigger('mouseover', {force: true})
.click({force: true})
cy.get('.nc-column-edit').click()
// change column type and verify
cy.get('.nc-ui-dt-dropdown').click()
cy.contains('LongText').click()
@ -50,20 +44,15 @@ const genTest = (type) => {
cy.get(`th[data-col="${colName}"] .mdi-text-subject`).should('exist')
cy.get(`th:contains(${colName}) .mdi-menu-down`)
.trigger('mouseover', {force: true})
.click({force: true})
cy.get('.nc-column-edit').click()
})
// edit the newly created column
it('Edit table column - rename', () => {
cy.get(`th:contains(${colName}) .mdi-menu-down`)
.trigger('mouseover', {force: true})
.click({force: true})
@ -74,23 +63,15 @@ const genTest = (type) => {
cy.get('.nc-column-name-input input').clear().type(updatedColName)
cy.get('.nc-col-create-or-edit-card').contains('Save').click()
cy.wait(3000)
cy
.get(`th:contains(${updatedColName})`)
.should('exist');
cy
.get(`th:contains(${colName})`)
.should('not.exist');
cy.get(`th:contains(${colName})`).should('not.exist')
cy.get(`th:contains(${updatedColName})`).should('exist')
})
// delete the newly created column
it('Delete table column', () => {
cy
.get(`th:contains(${updatedColName})`)
.should('exist');
cy.get(`th:contains(${updatedColName})`).should('exist');
cy.get(`th:contains(${updatedColName}) .mdi-menu-down`)
.trigger('mouseover')
@ -99,18 +80,34 @@ const genTest = (type) => {
cy.get('.nc-column-delete').click()
cy.get('button:contains(Confirm)').click()
cy
.get(`th:contains(${updatedColName})`)
.should('not.exist');
cy.get(`th:contains(${updatedColName})`).should('not.exist');
})
})
});
}
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/>.
*
*/

60
cypress/integration/common/table_operations_spec.js

@ -1,25 +1,31 @@
import { loginPage, projectsPage } from "../../support/page_objects/navigation";
import { roles, staticProjects } from "../../support/page_objects/projectConstants";
const genTest = (type, meta) => {
describe(`${meta ? 'Meta - ' : ''}${type.toUpperCase()} api - Table`, () => {
before(() => {
cy.waitForSpinners();
if (type === 'rest') {
cy.openOrCreateRestProject({
new: true,
meta
});
} else {
cy.openOrCreateGqlProject({
new: true,
meta
});
loginPage.signIn(roles.owner.credentials)
if(!meta)
{
if(type=='rest')
projectsPage.openProject(staticProjects.externalREST.basic.name)
else
projectsPage.openProject(staticProjects.externalGQL.basic.name)
}
});
else
{
if(type=='rest')
projectsPage.openProject(staticProjects.sampleREST.basic.name)
else
projectsPage.openProject(staticProjects.sampleGQL.basic.name)
}
})
const name = 'Test' + Date.now();
// create a new random table
it('Create Table', () => {
cy.get('.add-btn').click();
@ -31,7 +37,9 @@ const genTest = (type, meta) => {
cy.get('.nc-create-table-card .nc-create-table-submit').first().click()
cy.get(`.project-tab:contains(${name})`).should('exist')
cy.url().should('contain', `?name=${name}&`)
});
cy.wait(3000)
})
// delete newly created table
@ -49,8 +57,6 @@ const genTest = (type, meta) => {
cy.get('button:contains(Submit)').click()
cy.get(`.project-tab:contains(${name}):visible`).first().should('not.exist')
});
})
}
@ -60,3 +66,25 @@ genTest('graphql')
genTest('rest', true)
genTest('graphql', true)
/**
* @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/>.
*
*/

42
cypress/integration/common/table_row_operations_spec.js

@ -1,3 +1,6 @@
import { loginPage } from "../../support/page_objects/navigation"
const genTest = (type) => {
describe(`${type.toUpperCase()} api - Table Row`, () => {
@ -15,16 +18,11 @@ const genTest = (type) => {
cy.deleteTable(name)
});
it('Add new row', () => {
cy.get('.nc-add-new-row-btn').click({force: true});
cy.get('#data-table-form-Title > input').first().type(randVal);
cy.contains('Save Row').filter('button').click({force: true})
cy.get('td').contains(randVal).should('exist');
cy.get('td', {timeout: 10000}).contains(randVal).should('exist');
})
it('Update row', () => {
@ -33,17 +31,14 @@ const genTest = (type) => {
.find('.nc-row-expand-icon')
.click({force: true});
cy.get('#data-table-form-Title > input').first().clear().type(updatedRandVal);
cy.contains('Save Row').filter('button').click({force: true})
cy.get('td').contains(updatedRandVal).should('exist');
cy.wait(3000)
cy.get('td').contains(randVal).should('not.exist');
cy.get('td').contains(updatedRandVal).should('exist');
})
it('Delete row', () => {
cy.get('td').contains(updatedRandVal).rightclick({force: true})
@ -52,11 +47,32 @@ const genTest = (type) => {
cy.wait(1000)
cy.get('td').contains(randVal).should('not.exist');
})
});
}
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/>.
*
*/

59
cypress/integration/user_role_spec.js → cypress/integration/common/user_role_spec.js

@ -1,35 +1,8 @@
import { loginPage, projectsPage } from "../support/page_objects/navigation"
import { mainPage } from "../support/page_objects/mainPage"
import { roles } from "../support/page_objects/projectConstants"
import { loginPage } from "../../support/page_objects/navigation"
import { mainPage } from "../../support/page_objects/mainPage"
import { roles } from "../../support/page_objects/projectConstants"
describe('Test project creation, user creation', () => {
let projectName = ''
it('Create Project', () => {
loginPage.signUp(roles.owner.credentials)
const projectParams = { dbType: 1, apiType: 0, name: 'sakilaDb' }
const databaseParams = {
databaseType: 0,
hostAddress: 'localhost',
portNumber: '3306',
username: 'root',
password: 'password',
databaseName: 'sakila'
}
projectName = projectsPage.createProject(projectParams, databaseParams)
})
userRoleCreation('creator')
userRoleCreation('editor')
userRoleCreation('commenter')
userRoleCreation('viewer')
})
const genTest = (roleType) => {
const genTest = (apiType, roleType) => {
describe(`User role validation`, () => {
@ -188,7 +161,7 @@ const genTest = (roleType) => {
// Owner, Creator will have two navigation drawer (on each side of center panel)
if (validationString == 'exist') {
navDrawListCnt = 4
navDrawListItemCnt = 16
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)
@ -206,9 +179,10 @@ const genTest = (roleType) => {
///////////////////////////////////////////////////////
// Test suite
it(`[${roles[roleType].name}] SignIn, Open project SakilaDb`, () => {
loginPage.signIn(roles[roleType].credentials)
projectsPage.openProject('sakilaDb')
it(`[${roles[roleType].name}] SignIn, Open project`, () => {
//loginPage.signIn(roles[roleType].credentials)
//projectsPage.openProject('sakilaDb')
loginPage.loginAndOpenProject(apiType)
})
it(`[${roles[roleType].name}] Left navigation menu, New User add`, () => {
@ -249,11 +223,16 @@ const genTest = (roleType) => {
})
}
genTest('owner')
genTest('creator')
genTest('editor')
genTest('commenter')
genTest('viewer')
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')
/**

37
cypress/integration/common/users_spec.js

@ -1,37 +0,0 @@
const genTest = (type) => {
describe(`${type.toUpperCase()} api - User Management`, () => {
before( loginPage.loginAndOpenProject(type) )
const email = `noco${Date.now()}@gmail.com`;
it('Add new user', () => {
cy.get('.v-list-item:contains("Team & Auth")').click();
cy.get(`.project-tab:contains("Team & Auth"):visible`).should('exist')
cy.get(`td:contains("pranavc@gmail.com")`).should('exist')
cy.get('button:contains("New User")').first().click()
cy.get('label:contains(Email)').next('input').type(email).trigger('input')
cy.get('.nc-invite-or-save-btn').then($el => {
cy.wrap($el[0]).click()
// cy.contains('.v-alert', /http:\/\/locahost/).should('exist')
cy.contains('.v-alert', '#/user/authentication/signup/').should('exist')
})
})
})
}
genTest('rest')
genTest('graphql')

9
cypress/support/commands.js

@ -174,22 +174,18 @@ Cypress.Commands.add('createTable', (name) => {
cy.get('.add-btn').click();
cy.get('.nc-create-table-card .nc-table-name input[type="text"]').first().click().clear().type(name)
cy.get('.nc-create-table-card .nc-table-name-alias input[type="text"]').first().should('have.value', name.toLowerCase())
cy.wait(5000)
cy.get('.nc-create-table-card .nc-create-table-submit').first().click()
cy.get(`.project-tab:contains(${name})`).should('exist')
cy.url().should('contain', `?name=${name}&`)
cy.wait(3000)
})
Cypress.Commands.add('deleteTable', (name) => {
cy.get('.nc-project-tree').find('.v-list-item__title:contains(Tables)', {timeout: 10000})
.first().click()
cy.get('.nc-project-tree').contains(name, {timeout: 6000}).first().click({force: true});
cy.get(`.project-tab:contains(${name}):visible`).should('exist')
cy.get('.nc-table-delete-btn:visible').click()
cy.get('button:contains(Submit)').click()
cy.get(`.project-tab:contains(${name}):visible`).first().should('not.exist')
})
@ -197,11 +193,8 @@ Cypress.Commands.add('deleteTable', (name) => {
Cypress.Commands.add('createColumn', (table, columnName) => {
cy.get('.nc-project-tree').find('.v-list-item__title:contains(Tables)', {timeout: 10000})
.first().click()
cy.get('.nc-project-tree').contains(table, {timeout: 6000}).first().click({force: true});
cy.get(`.project-tab:contains(${table}):visible`).should('exist')
cy.get('.v-window-item--active .nc-grid tr > th:last button').click({force: true});
cy.get('.nc-column-name-input input').clear().type(columnName)
cy.get('.nc-col-create-or-edit-card').contains('Save').click()

6
cypress/support/page_objects/mainPage.js

@ -115,6 +115,12 @@ export class _mainPage {
getRow = (rowIndex) => {
return cy.get('.xc-row-table').find('tr').eq(rowIndex)
}
addColumn = (colName) => {
cy.get('.v-window-item--active .nc-grid tr > th:last button').click({force: true});
cy.get('.nc-column-name-input input', {timeout: 3000}).clear().type(colName)
cy.get('.nc-col-create-or-edit-card').contains('Save').click()
}
}

Loading…
Cancel
Save