Browse Source

test: [cypress] Environment variable for test suite selection

Signed-off-by: Raju Udava <sivadstala@gmail.com>
pull/569/head
Raju Udava 3 years ago
parent
commit
af3c70e629
  1. 4
      cypress.json
  2. 19
      cypress/integration/common/00_pre_configurations.js
  3. 8
      cypress/integration/common/0a_project_operations.js
  4. 2
      cypress/integration/common/1a_table_operations.js
  5. 8
      cypress/integration/common/1b_table_column_operations.js
  6. 8
      cypress/integration/common/1c_table_row_operations.js
  7. 4
      cypress/integration/common/2a_table_with_belongs_to_colulmn.js
  8. 8
      cypress/integration/common/2b_table_with_m2m_column.js
  9. 8
      cypress/integration/common/3a_filter_sort_fields_operations.js
  10. 8
      cypress/integration/common/3b_formula_column.js
  11. 8
      cypress/integration/common/3c_lookup_column.js
  12. 8
      cypress/integration/common/3d_rollup_column.js
  13. 12
      cypress/integration/common/4a_table_view_grid_gallery.js
  14. 8
      cypress/integration/common/4b_table_view_share.js
  15. 6
      cypress/integration/common/5a_user_role.js
  16. 75
      cypress/integration/common/5b_preview_role.js
  17. 10
      cypress/integration/common/6a_audit.js
  18. 15
      cypress/integration/common/6c_swagger_api.js
  19. 42
      cypress/support/page_objects/projectConstants.js

4
cypress.json

@ -7,5 +7,7 @@
"video": false,
"retries": 2,
"screenshotOnRunFailure": false,
"numTestsKeptInMemory": 5
"numTestsKeptInMemory": 0,
"env": {
"testMode": "extREST" }
}

19
cypress/integration/common/00_pre_configurations.js

@ -4,7 +4,7 @@
import { loginPage, projectsPage } from "../../support/page_objects/navigation"
import { mainPage } from "../../support/page_objects/mainPage"
import { staticProjects, roles } from "../../support/page_objects/projectConstants"
import { staticProjects, roles, isTestSuiteActive, getPrimarySuite, isSecondarySuite } from "../../support/page_objects/projectConstants"
describe(`Project pre-configurations`, () => {
@ -24,17 +24,17 @@ describe(`Project pre-configurations`, () => {
})
}
createProject(staticProjects.sampleREST)
createProject(staticProjects.sampleGQL)
createProject(staticProjects.externalREST)
createProject(staticProjects.externalGQL)
if( isTestSuiteActive('rest', true) ) createProject(staticProjects.sampleREST)
if( isTestSuiteActive('graphql', true) ) createProject(staticProjects.sampleGQL)
if( isTestSuiteActive('rest', false) ) createProject(staticProjects.externalREST)
if( isTestSuiteActive('graphql', false) ) createProject(staticProjects.externalGQL)
})
describe('Static user creations (different roles)', () => {
beforeEach(()=> {
loginPage.signIn(roles.owner.credentials)
projectsPage.openProject(staticProjects.sampleREST.basic.name)
projectsPage.openProject(getPrimarySuite().basic.name)
})
const addUser = (user) => {
@ -63,9 +63,10 @@ describe('Static users- add to other static projects', () => {
})
}
addUserToProject(staticProjects.sampleGQL)
addUserToProject(staticProjects.externalREST)
addUserToProject(staticProjects.externalGQL)
if( isSecondarySuite('rest', true) ) addUserToProject(staticProjects.sampleREST)
if( isSecondarySuite('graphql', true) ) addUserToProject(staticProjects.sampleGQL)
if( isSecondarySuite('rest', false) ) addUserToProject(staticProjects.externalREST)
if( isSecondarySuite('graphql', false) ) addUserToProject(staticProjects.externalGQL)
})

8
cypress/integration/common/0a_project_operations.js

@ -1,9 +1,11 @@
import { loginPage } from "../../support/page_objects/navigation"
import { roles } from "../../support/page_objects/projectConstants"
import { isTestSuiteActive } from "../../support/page_objects/projectConstants"
const genTest = (type) => {
const genTest = (type, xcdb) => {
describe(`${type.toUpperCase()} Project operations`, () => {
if(!isTestSuiteActive(type, xcdb)) return;
before(() => {
loginPage.signIn(roles.owner.credentials)
@ -57,8 +59,8 @@ const genTest = (type) => {
})
}
genTest('rest')
genTest('graphql')
genTest('rest', false)
genTest('graphql', false)
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd

2
cypress/integration/common/1a_table_operations.js

@ -1,7 +1,9 @@
import { loginPage } from "../../support/page_objects/navigation";
import { isTestSuiteActive } from "../../support/page_objects/projectConstants"
const genTest = (type, xcdb) => {
if(!isTestSuiteActive(type, xcdb)) return;
describe(`${xcdb ? 'Meta - ' : ''}${type.toUpperCase()} api - Table`, () => {

8
cypress/integration/common/1b_table_column_operations.js

@ -1,8 +1,10 @@
import { loginPage } from "../../support/page_objects/navigation"
import { mainPage } from "../../support/page_objects/mainPage"
import { isTestSuiteActive } from "../../support/page_objects/projectConstants"
const genTest = (type) => {
const genTest = (type, xcdb) => {
if(!isTestSuiteActive(type, xcdb)) return;
describe(`${type.toUpperCase()} api - Table Column`, () => {
const name = 'Table' + Date.now();
@ -85,8 +87,8 @@ const genTest = (type) => {
})
}
genTest('rest')
genTest('graphql')
genTest('rest', false)
genTest('graphql', false)
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd

8
cypress/integration/common/1c_table_row_operations.js

@ -1,7 +1,9 @@
import { loginPage } from "../../support/page_objects/navigation"
import { isTestSuiteActive } from "../../support/page_objects/projectConstants"
const genTest = (type) => {
const genTest = (type, xcdb) => {
if(!isTestSuiteActive(type, xcdb)) return;
describe(`${type.toUpperCase()} api - Table Row`, () => {
const randVal = 'Test' + Date.now();
@ -50,8 +52,8 @@ const genTest = (type) => {
});
}
genTest('rest')
genTest('graphql')
genTest('rest', false)
genTest('graphql', false)
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd

4
cypress/integration/common/2a_table_with_belongs_to_colulmn.js

@ -1,7 +1,9 @@
import { loginPage } from "../../support/page_objects/navigation"
import { isTestSuiteActive } from "../../support/page_objects/projectConstants"
const genTest = (type) => {
const genTest = (type, xcdb) => {
if(!isTestSuiteActive(type, xcdb)) return;
describe(`${type.toUpperCase()} api - Existing table`, () => {
before(() => loginPage.loginAndOpenProject(type))

8
cypress/integration/common/2b_table_with_m2m_column.js

@ -1,7 +1,9 @@
import { loginPage } from "../../support/page_objects/navigation"
import { isTestSuiteActive } from "../../support/page_objects/projectConstants"
const genTest = (type) => {
const genTest = (type, xcdb) => {
if(!isTestSuiteActive(type, xcdb)) return;
describe(`${type.toUpperCase()} api - M2M Column validation`, () => {
before(() => {
@ -54,8 +56,8 @@ const genTest = (type) => {
})
}
genTest('rest')
genTest('graphql')
genTest('rest', false)
genTest('graphql', false)
/**

8
cypress/integration/common/3a_filter_sort_fields_operations.js

@ -1,8 +1,10 @@
import { mainPage } from "../../support/page_objects/mainPage"
import { loginPage } from "../../support/page_objects/navigation"
import { isTestSuiteActive } from "../../support/page_objects/projectConstants"
const genTest = (type) => {
const genTest = (type, xcdb) => {
if(!isTestSuiteActive(type, xcdb)) return;
describe(`${type.toUpperCase()} api - Filter, Fields, Sort`, () => {
before(() => {
@ -169,8 +171,8 @@ const genTest = (type) => {
})
}
genTest('rest')
genTest('graphql')
genTest('rest', false)
genTest('graphql', false)
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd

8
cypress/integration/common/3b_formula_column.js

@ -1,7 +1,9 @@
import { loginPage } from "../../support/page_objects/navigation"
import { isTestSuiteActive } from "../../support/page_objects/projectConstants"
const genTest = (type) => {
const genTest = (type, xcdb) => {
if(!isTestSuiteActive(type, xcdb)) return;
describe(`${type.toUpperCase()} api - FORMULA`, () => {
@ -182,8 +184,8 @@ const genTest = (type) => {
})
}
genTest('rest')
genTest('graphql')
genTest('rest', false)
genTest('graphql', false)
/**

8
cypress/integration/common/3c_lookup_column.js

@ -1,7 +1,9 @@
import { loginPage } from "../../support/page_objects/navigation"
import { isTestSuiteActive } from "../../support/page_objects/projectConstants"
const genTest = (type) => {
const genTest = (type, xcdb) => {
if(!isTestSuiteActive(type, xcdb)) return;
describe(`${type.toUpperCase()} api - LookUp column`, () => {
@ -115,8 +117,8 @@ const genTest = (type) => {
}
genTest('rest')
genTest('graphql')
genTest('rest', false)
genTest('graphql', false)
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd

8
cypress/integration/common/3d_rollup_column.js

@ -1,6 +1,8 @@
import { loginPage } from "../../support/page_objects/navigation"
import { isTestSuiteActive } from "../../support/page_objects/projectConstants"
const genTest = (type) => {
const genTest = (type, xcdb) => {
if(!isTestSuiteActive(type, xcdb)) return;
describe(`${type.toUpperCase()} api - RollUp column`, () => {
@ -150,8 +152,8 @@ const genTest = (type) => {
});
}
genTest('rest')
genTest('graphql')
genTest('rest', false)
genTest('graphql', false)
/**

12
cypress/integration/common/4a_table_view_grid_gallery.js

@ -1,15 +1,17 @@
import { loginPage } from "../../support/page_objects/navigation"
import { isTestSuiteActive } from "../../support/page_objects/projectConstants"
const genTest = (dbType) => {
const genTest = (type, xcdb) => {
if(!isTestSuiteActive(type, xcdb)) return;
describe(`${dbType.toUpperCase()} api - Table views`, () => {
describe(`${type.toUpperCase()} api - Table views`, () => {
const name = 'Test' + Date.now();
// Run once before test- create project (rest/graphql)
//
before(() => {
loginPage.loginAndOpenProject(dbType)
loginPage.loginAndOpenProject(type)
// open a table to work on views
//
@ -73,8 +75,8 @@ const genTest = (dbType) => {
// invoke for different API types supported
//
genTest('rest')
genTest('graphql')
genTest('rest', false)
genTest('graphql', false)
/**

8
cypress/integration/common/4b_table_view_share.js

@ -1,4 +1,5 @@
import { loginPage } from "../../support/page_objects/navigation"
import { isTestSuiteActive } from "../../support/page_objects/projectConstants"
const shareViewWithPwd = (pwdCorrect, pwd) => {
@ -81,7 +82,8 @@ const deleteCreatedViews = () => {
})
}
const genTest = (type) => {
const genTest = (type, xcdb) => {
if(!isTestSuiteActive(type, xcdb)) return;
describe(`${type.toUpperCase()} api - Clipboard access`, () => {
@ -114,8 +116,8 @@ const genTest = (type) => {
})
}
genTest('rest')
genTest('graphql')
genTest('rest', false)
genTest('graphql', false)
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd

6
cypress/integration/common/5a_user_role.js

@ -1,8 +1,10 @@
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"
const genTest = (apiType, roleType) => {
const genTest = (type, roleType) => {
if(!isTestSuiteActive(type, false)) return;
describe(`User role validation`, () => {
@ -180,7 +182,7 @@ const genTest = (apiType, roleType) => {
it(`[${roles[roleType].name}] SignIn, Open project`, () => {
loginPage.signIn(roles[roleType].credentials)
if('rest' == apiType)
if('rest' == type)
projectsPage.openProject(staticProjects.externalREST.basic.name)
else
projectsPage.openProject(staticProjects.externalGQL.basic.name)

75
cypress/integration/common/5b_preview_role.js

@ -6,6 +6,7 @@
import { loginPage, projectsPage } from "../../support/page_objects/navigation"
import { mainPage } from "../../support/page_objects/mainPage"
import { roles } from "../../support/page_objects/projectConstants"
import { isTestSuiteActive } from "../../support/page_objects/projectConstants"
// should we reverify permissions after preview reset?
const reVerificationAfterReset = false
@ -13,10 +14,12 @@ const reVerificationAfterReset = false
// should we verify permissions in owner mode before preview?
const baseVerificationBeforePreview = false
const genTest = (type, xcdb) => {
if(!isTestSuiteActive(type, xcdb)) return;
// project configuration settings
//
const advancedSettings = (roleType) => {
// project configuration settings
//
const advancedSettings = (roleType) => {
cy.log(`##### advancedSettings: ${roleType}`)
@ -51,13 +54,13 @@ const advancedSettings = (roleType) => {
}
cy.get('button:contains("New User")').should(validationString)
}
}
// Table data related validations
// - Add/delete/modify row
//
const editData = (roleType) => {
// Table data related validations
// - Add/delete/modify row
//
const editData = (roleType) => {
cy.log(`##### editData: ${roleType}`)
@ -119,14 +122,14 @@ const editData = (roleType) => {
// double click cell entries to edit
//
cy.get(`tbody > :nth-child(4) > [data-col="City"]`).dblclick().find('input').should(validationString)
}
}
// Schema related validations
// - Add/delete table
// - Add/Update/delete column
//
const editSchema = (roleType) => {
// Schema related validations
// - Add/delete table
// - Add/Update/delete column
//
const editSchema = (roleType) => {
cy.log(`##### editSchema: ${roleType}`)
@ -150,14 +153,14 @@ const editSchema = (roleType) => {
//
cy.get(`th:contains(${columnName}) .mdi-menu-down`).should(validationString)
}
}
// read &/ update comment
// Viewer: only allowed to read
// Everyone else: read &/ update
//
const editComment = (roleType) => {
// read &/ update comment
// Viewer: only allowed to read
// Everyone else: read &/ update
//
const editComment = (roleType) => {
cy.log(`##### editComment: ${roleType}`)
@ -189,12 +192,12 @@ const editComment = (roleType) => {
cy.wait(1000)
cy.getActiveModal().find('button').contains('Cancel').click()
cy.get('body').type('{esc}')
}
}
// right navigation menu bar
// Editor/Viewer/Commenter : can only view 'existing' views
// Rest: can create/edit
const viewMenu = (roleType) => {
// right navigation menu bar
// Editor/Viewer/Commenter : can only view 'existing' views
// Rest: can create/edit
const viewMenu = (roleType) => {
cy.log(`##### viewMenu: ${roleType}`)
@ -226,13 +229,13 @@ const viewMenu = (roleType) => {
// cy.get(`.nc-create-grid-view`).should(validationString)
// cy.get(`.nc-create-gallery-view`).should(validationString)
}
}
///////////////////////////////////////////////////////////
//// Test Suite
///////////////////////////////////////////////////////////
//// Test Suite
describe('Role preview validations', () => {
describe('Role preview validations', () => {
// Sign in/ open project
before(() => {
@ -240,7 +243,7 @@ describe('Role preview validations', () => {
projectsPage.openProject('externalREST')
})
const genTest = (roleType) => {
const genTestSub = (roleType) => {
it(`Role type: ${roleType} > Advanced settings validation`, () => {
@ -356,12 +359,16 @@ describe('Role preview validations', () => {
})
}
genTest('editor')
genTest('commenter')
genTestSub('editor')
genTestSub('commenter')
// enable post xcAuditModeCommentsCount fix
// genTest('viewer')
})
// genTestSub('viewer')
})
}
genTest('rest', false)

10
cypress/integration/common/6a_audit.js

@ -1,10 +1,12 @@
import { mainPage } from "../../support/page_objects/mainPage"
import { loginPage } from "../../support/page_objects/navigation"
import { isTestSuiteActive } from "../../support/page_objects/projectConstants"
const genTest = (type) => {
const genTest = (type, xcdb) => {
if(!isTestSuiteActive(type, xcdb)) return;
describe(`${type.toUpperCase()} api - Filter, Fields, Sort`, () => {
describe(`${type.toUpperCase()} Audit`, () => {
before(() => {
loginPage.loginAndOpenProject(type)
cy.get('.mdi-close').click({ multiple: true })
@ -38,8 +40,8 @@ const genTest = (type) => {
})
}
genTest('rest')
genTest('graphql')
genTest('rest', false)
genTest('graphql', false)
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd

15
cypress/integration/common/6c_swagger_api.js

@ -2,8 +2,12 @@
import { loginPage } from "../../support/page_objects/navigation"
import { mainPage } from "../../support/page_objects/mainPage"
import { roles } from "../../support/page_objects/projectConstants"
import { isTestSuiteActive } from "../../support/page_objects/projectConstants"
describe(`Swagger API - Test preparation`, () => {
const genTest = (type, xcdb) => {
if(!isTestSuiteActive(type, xcdb)) return;
describe(`Swagger API - Test preparation`, () => {
before(()=> {
loginPage.loginAndOpenProject('rest', false)
})
@ -24,9 +28,9 @@ describe(`Swagger API - Test preparation`, () => {
cy.writeFile("shared.json", {SWAGGER_URL: swaggerURL, AUTH_TOKEN: authToken})
})
})
})
})
describe(`Swagger page, base verification`, () => {
describe(`Swagger page, base verification`, () => {
// returns swagger button intended for
//
@ -162,4 +166,7 @@ describe(`Swagger page, base verification`, () => {
cy.log("file cleaned up!")
})
})
})
})
}
genTest('rest', false)

42
cypress/support/page_objects/projectConstants.js

@ -63,3 +63,45 @@ export const staticProjects = {
config: defaultDbParams
}
}
// return TRUE if test suite specified is activated from env-variables
//
export const isTestSuiteActive = (type, xcdb) => {
const env = Cypress.env('testMode')
if( !xcdb ) {
switch( type ) {
case 'rest': return env.includes('extREST')?true:false;
case 'graphql': return env.includes('extGQL')?true:false;
}
} else {
switch( type ) {
case 'rest': return env.includes('xcdbREST')?true:false;
case 'graphql': return env.includes('xcdbGQL')?true:false;
}
}
}
// expecting different modes to be seperated by a .
export const getPrimarySuite = () => {
const env = Cypress.env('testMode').split('.')
switch(env[0]) {
case 'extREST': return staticProjects.externalREST;
case 'extGQL': return staticProjects.externalGQL;
case 'xcdbREST': return staticProjects.sampleREST;
case 'xcdbGQL': return staticProjects.sampleGQL;
}
}
export const isSecondarySuite = (proj, xcdb) => {
if(!isTestSuiteActive(proj, xcdb))
return false;
const env = Cypress.env('testMode').split('.')
switch(env[0]) {
case 'extREST': return (proj=='rest' && !xcdb)?false:true;
case 'extGQL': return (proj=='graphql' && !xcdb)?false:true;
case 'xcdbREST': return (proj=='rest' && xcdb)?false:true;
case 'xcdbGQL': return (proj=='graphql' && xcdb)?false:true;
}
}
Loading…
Cancel
Save