Browse Source

test: [cypress] use existing project instead of creating new for every test

Signed-off-by: dstala <sivadstala@gmail.com>
Signed-off-by: Raju Udava <sivadstala@gmail.com>
pull/559/head
dstala 3 years ago committed by Raju Udava
parent
commit
eb8b653c8d
  1. 23
      cypress/integration/common/filter_sort_fields_operations_spec.js
  2. 14
      cypress/integration/common/formula_column.js
  3. 12
      cypress/integration/common/lookup_column.js
  4. 17
      cypress/integration/common/open_existing_table_spec.js
  5. 17
      cypress/integration/common/open_existing_table_with_m2m_spec.js
  6. 10
      cypress/integration/common/rollup_column.js
  7. 30
      cypress/integration/common/share_view.js
  8. 12
      cypress/integration/common/table_column_operations_spec.js
  9. 11
      cypress/integration/common/table_row_operations_spec.js
  10. 14
      cypress/integration/common/table_view_spec.js
  11. 13
      cypress/integration/common/users_spec.js
  12. 90
      cypress/integration/ncTest.spec.js
  13. 35
      cypress/integration/preview_role_spec.js
  14. 38
      cypress/integration/user_role_spec.js
  15. 1
      cypress/plugins/index.js
  16. 13
      cypress/support/page_objects/navigation.js

23
cypress/integration/common/filter_sort_fields_operations_spec.js

@ -1,29 +1,16 @@
import { loginPage } from "../../support/page_objects/navigation"
const genTest = (type) => {
describe(`${type.toUpperCase()} api - Filter, Fields, Sort`, () => {
before(() => {
cy.waitForSpinners();
if (type === 'rest') {
cy.openOrCreateRestProject({
new: true
});
} else {
cy.openOrCreateGqlProject({
new: true
});
}
loginPage.loginAndOpenProject(type)
// open country table
cy.openTableTab('Country');
// cy.intercept({
// method: "GET",
// url: "/nc/**/api/v1/Country**",
// hostname: 'localhost',
// port: 8080
// }).as("dataGetFirst");
// cy.wait("@dataGetFirst");
// todo: wait until api call completes
cy.wait(2000)
})

14
cypress/integration/common/formula_column.js

@ -1,4 +1,6 @@
import { loginPage } from "../../support/page_objects/navigation"
const genTest = (type) => {
describe(`${type.toUpperCase()} api - FORMULA`, () => {
@ -6,15 +8,7 @@ const genTest = (type) => {
// Run once before test- create project (rest/graphql)
//
before(() => {
cy.waitForSpinners();
// create project
//
if (type === 'rest') {
cy.openOrCreateRestProject({ new: true })
} else {
cy.openOrCreateGqlProject({ new: true })
}
loginPage.loginAndOpenProject(type)
// open a table to work on views
//
@ -143,7 +137,7 @@ const genTest = (type) => {
// ADD, AVG, LEN
RESULT_MATH_0[i] = ((cityId[i] + countryId[i]) +
((cityId[i] + countryId[i]) / 2) +
(city[i].length)).toFixed(4)
(city[i].length))
// CEILING, FLOOR, ROUND, MOD, MIN, MAX
RESULT_MATH_1[i] = (Math.ceil(1.4) +

12
cypress/integration/common/lookup_column.js

@ -1,4 +1,6 @@
import { loginPage } from "../../support/page_objects/navigation"
const genTest = (type) => {
describe(`${type.toUpperCase()} api - LookUp column`, () => {
@ -15,15 +17,7 @@ const genTest = (type) => {
// Run once before test- create project (rest/graphql)
//
before(() => {
cy.waitForSpinners();
// create project
//
if (type === 'rest') {
cy.openOrCreateRestProject({ new: true })
} else {
cy.openOrCreateGqlProject({ new: true })
}
loginPage.loginAndOpenProject(type)
// open a table to work on views
//

17
cypress/integration/common/open_existing_table_spec.js

@ -1,20 +1,11 @@
import { loginPage } from "../../support/page_objects/navigation"
const genTest = (type) => {
describe(`${type.toUpperCase()} api - Existing table`, () => {
before(() => {
cy.waitForSpinners();
if (type === 'rest') {
cy.openOrCreateRestProject({
new: true
});
} else {
cy.openOrCreateGqlProject({
new: true
});
}
});
before(loginPage.loginAndOpenProject(type))
it('Open Country table', () => {

17
cypress/integration/common/open_existing_table_with_m2m_spec.js

@ -1,20 +1,11 @@
import { loginPage } from "../../support/page_objects/navigation"
const genTest = (type) => {
describe(`${type.toUpperCase()} api - Existing table with M2M'`, () => {
before(() => {
cy.waitForSpinners();
if (type === 'rest') {
cy.openOrCreateRestProject({
new: true
});
} else {
cy.openOrCreateGqlProject({
new: true
});
}
})
before(loginPage.loginAndOpenProject(type))
it('Open Actor table', () => {

10
cypress/integration/common/rollup_column.js

@ -15,15 +15,7 @@ const genTest = (type) => {
// Run once before test- create project (rest/graphql)
//
before(() => {
cy.waitForSpinners();
// create project
//
if (type === 'rest') {
cy.openOrCreateRestProject({ new: true })
} else {
cy.openOrCreateGqlProject({ new: true })
}
loginPage.loginAndOpenProject(type)
// open a table to work on views
//

30
cypress/integration/common/share_view.js

@ -1,4 +1,4 @@
import { loginPage, projectsPage } from "../../support/page_objects/navigation"
import { loginPage } from "../../support/page_objects/navigation"
const shareViewWithPwd = (pwdCorrect, pwd) => {
@ -85,26 +85,10 @@ 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)
loginPage.loginAndOpenProject(type)
cy.openTableTab('City');
})
@ -122,11 +106,11 @@ const genTest = (type) => {
it('Delete view', deleteCreatedViews )
// clean up
after( () => {
loginPage.signIn({ username: 'user@nocodb.com', password: 'Password123.' })
projectsPage.deleteProject(projectName)
})
// // clean up
// after( () => {
// loginPage.signIn({ username: 'user@nocodb.com', password: 'Password123.' })
// projectsPage.deleteProject(projectName)
// })
})
}

12
cypress/integration/common/table_column_operations_spec.js

@ -6,17 +6,7 @@ const genTest = (type) => {
const updatedColName = 'updated_column_name' + Date.now();
before(() => {
cy.waitForSpinners();
if (type === 'rest') {
cy.openOrCreateRestProject({
new: true
});
} else {
cy.openOrCreateGqlProject({
new: true
});
}
loginPage.loginAndOpenProject(type)
cy.createTable(name)
});

11
cypress/integration/common/table_row_operations_spec.js

@ -6,16 +6,7 @@ const genTest = (type) => {
const name = 'Tablerow' + Date.now();
before(() => {
cy.waitForSpinners();
if (type === 'rest') {
cy.openOrCreateRestProject({
new: true
});
} else {
cy.openOrCreateGqlProject({
new: true
});
}
loginPage.loginAndOpenProject(type)
cy.createTable(name)
});

14
cypress/integration/common/table_view_spec.js

@ -7,19 +7,7 @@ const genTest = (dbType) => {
// Run once before test- create project (rest/graphql)
//
before(() => {
cy.waitForSpinners();
// create project
//
if (dbType === 'rest') {
cy.openOrCreateRestProject({
new: true
});
} else {
cy.openOrCreateGqlProject({
new: true
});
}
loginPage.loginAndOpenProject(type)
// open a table to work on views
//

13
cypress/integration/common/users_spec.js

@ -2,18 +2,7 @@ const genTest = (type) => {
describe(`${type.toUpperCase()} api - User Management`, () => {
before(() => {
cy.waitForSpinners();
if (type === 'rest') {
cy.openOrCreateRestProject({
new: true
});
} else {
cy.openOrCreateGqlProject({
new: true
});
}
});
before( loginPage.loginAndOpenProject(type) )
const email = `noco${Date.now()}@gmail.com`;

90
cypress/integration/ncTest.spec.js

@ -1,90 +0,0 @@
import { loginPage, projectsPage } from "../support/page_objects/navigation"
const activeCredentials = 0
const userCredentials = [
{ username: 'user@nocodb.com', password: 'Password123.' }]
describe('Login & project page', () => {
beforeEach(() => {
loginPage.signIn(userCredentials[activeCredentials])
})
let projectName = ''
it('1. Create project: NC_DB_NONE, NC_REST', () => {
const projectParams = { dbType: 0, apiType: 0, name: 'sampleREST' }
projectName = projectsPage.createProject(projectParams)
})
it('1a. Open existing project & refresh project list', () => {
projectsPage.refreshProject()
projectsPage.searchProject('sample')
projectsPage.openProject(projectName)
})
it('1b. Delete project: NC_DB_NONE, NC_REST', () => {
projectsPage.deleteProject(projectName)
})
it('2. Create project: NC_DB_NONE, NC_GQL', () => {
const projectParams = { dbType: 0, apiType: 1, name: 'sampleGQL' }
projectName = projectsPage.createProject(projectParams)
})
it('2a. Delete project: NC_DB_NONE, NC_GQL', () => {
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/>.
*
*/

35
cypress/integration/preview_role_spec.js

@ -5,6 +5,7 @@
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
@ -12,40 +13,6 @@ const reVerificationAfterReset = false
// should we verify permissions in owner mode before preview?
const baseVerificationBeforePreview = false
// database
// validation details
// advSettings: left navigation bar (audit, metadata, auth, transient view modes)
// editSchema: create table, add/update/delete column
// editData: add/ update/ delete row, cell contents
// editComment: add comment
// shareView: right navigation bar (share options)
const roles = {
owner: {
name: 'owner',
credentials: { username: 'user@nocodb.com', password: 'Password123.' },
validations: { advSettings: true, editSchema: true, editData: true, editComment: true, shareView: true }
},
creator: {
name: 'creator',
credentials: { username: 'creator@nocodb.com', password: 'Password123.' },
validations: { advSettings: true, editSchema: true, editData: true, editComment: true, shareView: true }
},
editor: {
name: 'editor',
credentials: { username: 'editor@nocodb.com', password: 'Password123.' },
validations: { advSettings: false, editSchema: false, editData: true, editComment: true, shareView: false }
},
commenter: {
name: 'commenter',
credentials: { username: 'commenter@nocodb.com', password: 'Password123.' },
validations: { advSettings: false, editSchema: false, editData: false, editComment: true, shareView: false }
},
viewer: {
name: 'viewer',
credentials: { username: 'viewer@nocodb.com', password: 'Password123.' },
validations: { advSettings: false, editSchema: false, editData: false, editComment: false, shareView: false }
}
}
// project configuration settings
//

38
cypress/integration/user_role_spec.js

@ -1,42 +1,6 @@
import { loginPage, projectsPage } from "../support/page_objects/navigation"
import { mainPage } from "../support/page_objects/mainPage"
// database
// validation details
// advSettings: left navigation bar (audit, metadata, auth, transient view modes)
// editSchema: create table, add/update/delete column
// editData: add/ update/ delete row, cell contents
// editComment: add comment
// shareView: right navigation bar (share options)
const roles = {
owner: {
name: 'owner',
credentials: { username: 'user@nocodb.com', password: 'Password123.' },
validations: { advSettings: true, editSchema: true, editData: true, editComment: true, shareView: true }
},
creator: {
name: 'creator',
credentials: { username: 'creator@nocodb.com', password: 'Password123.' },
validations: { advSettings: true, editSchema: true, editData: true, editComment: true, shareView: true }
},
editor: {
name: 'editor',
credentials: { username: 'editor@nocodb.com', password: 'Password123.' },
validations: { advSettings: false, editSchema: false, editData: true, editComment: true, shareView: false }
},
commenter: {
name: 'commenter',
credentials: { username: 'commenter@nocodb.com', password: 'Password123.' },
validations: { advSettings: false, editSchema: false, editData: false, editComment: true, shareView: false }
},
viewer: {
name: 'viewer',
credentials: { username: 'viewer@nocodb.com', password: 'Password123.' },
validations: { advSettings: false, editSchema: false, editData: false, editComment: false, shareView: false }
}
}
import { roles } from "../support/page_objects/projectConstants"
describe('Test project creation, user creation', () => {

1
cypress/plugins/index.js

@ -20,3 +20,4 @@ module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
}

13
cypress/support/page_objects/navigation.js

@ -1,5 +1,5 @@
import { defaultDbParams } from "./projectConstants"
import { roles, staticProjects, defaultDbParams } from "./projectConstants"
///////////////////////////////////////////////////////////
// Sign in/ Sign up page
@ -51,6 +51,17 @@ export class _loginPage {
cy.url({ timeout: 6000 }).should('contain', '#/project')
cy.wait(1000)
}
// standard pre-project activity
//
loginAndOpenProject(apiType) {
loginPage.signIn(roles.owner.credentials)
if ('rest' == apiType)
projectsPage.openProject(staticProjects.externalREST.basic.name)
else
projectsPage.openProject(staticProjects.externalGQL.basic.name)
}
}

Loading…
Cancel
Save