From af3c70e6298a2a9b49c58914d372f4ac279e5667 Mon Sep 17 00:00:00 2001 From: Raju Udava Date: Fri, 24 Sep 2021 14:58:15 +0530 Subject: [PATCH] test: [cypress] Environment variable for test suite selection Signed-off-by: Raju Udava --- cypress.json | 4 +- .../common/00_pre_configurations.js | 21 +- .../common/0a_project_operations.js | 8 +- .../integration/common/1a_table_operations.js | 2 + .../common/1b_table_column_operations.js | 8 +- .../common/1c_table_row_operations.js | 8 +- .../2a_table_with_belongs_to_colulmn.js | 4 +- .../common/2b_table_with_m2m_column.js | 8 +- .../3a_filter_sort_fields_operations.js | 8 +- .../integration/common/3b_formula_column.js | 8 +- .../integration/common/3c_lookup_column.js | 8 +- .../integration/common/3d_rollup_column.js | 8 +- .../common/4a_table_view_grid_gallery.js | 12 +- .../integration/common/4b_table_view_share.js | 8 +- cypress/integration/common/5a_user_role.js | 6 +- cypress/integration/common/5b_preview_role.js | 527 +++++++++--------- cypress/integration/common/6a_audit.js | 10 +- cypress/integration/common/6c_swagger_api.js | 287 +++++----- .../support/page_objects/projectConstants.js | 42 ++ 19 files changed, 537 insertions(+), 450 deletions(-) diff --git a/cypress.json b/cypress.json index 245acfe53c..a87e87614b 100644 --- a/cypress.json +++ b/cypress.json @@ -7,5 +7,7 @@ "video": false, "retries": 2, "screenshotOnRunFailure": false, - "numTestsKeptInMemory": 5 + "numTestsKeptInMemory": 0, + "env": { + "testMode": "extREST" } } diff --git a/cypress/integration/common/00_pre_configurations.js b/cypress/integration/common/00_pre_configurations.js index aee4de2e60..57f1aee168 100644 --- a/cypress/integration/common/00_pre_configurations.js +++ b/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) => { @@ -62,10 +62,11 @@ describe('Static users- add to other static projects', () => { mainPage.addExistingUserToProject(roles.viewer.credentials.username, roles.viewer.name) }) } - - 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) }) diff --git a/cypress/integration/common/0a_project_operations.js b/cypress/integration/common/0a_project_operations.js index 9ed45ffc95..a159822989 100644 --- a/cypress/integration/common/0a_project_operations.js +++ b/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 diff --git a/cypress/integration/common/1a_table_operations.js b/cypress/integration/common/1a_table_operations.js index 04fbb8a2e2..a22d1e5518 100644 --- a/cypress/integration/common/1a_table_operations.js +++ b/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`, () => { diff --git a/cypress/integration/common/1b_table_column_operations.js b/cypress/integration/common/1b_table_column_operations.js index 434ead571b..94a12b9934 100644 --- a/cypress/integration/common/1b_table_column_operations.js +++ b/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 diff --git a/cypress/integration/common/1c_table_row_operations.js b/cypress/integration/common/1c_table_row_operations.js index 9ad8174cc0..85b91dfb20 100644 --- a/cypress/integration/common/1c_table_row_operations.js +++ b/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 diff --git a/cypress/integration/common/2a_table_with_belongs_to_colulmn.js b/cypress/integration/common/2a_table_with_belongs_to_colulmn.js index ffcc178cd4..18130d9c3a 100644 --- a/cypress/integration/common/2a_table_with_belongs_to_colulmn.js +++ b/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)) diff --git a/cypress/integration/common/2b_table_with_m2m_column.js b/cypress/integration/common/2b_table_with_m2m_column.js index 1d14043f83..b34c8ebf72 100644 --- a/cypress/integration/common/2b_table_with_m2m_column.js +++ b/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) /** diff --git a/cypress/integration/common/3a_filter_sort_fields_operations.js b/cypress/integration/common/3a_filter_sort_fields_operations.js index b42aa94f6c..d46325e746 100644 --- a/cypress/integration/common/3a_filter_sort_fields_operations.js +++ b/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 diff --git a/cypress/integration/common/3b_formula_column.js b/cypress/integration/common/3b_formula_column.js index ea03996e70..f5b4e62af5 100644 --- a/cypress/integration/common/3b_formula_column.js +++ b/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) /** diff --git a/cypress/integration/common/3c_lookup_column.js b/cypress/integration/common/3c_lookup_column.js index ed0df2f5b5..ddd3ed9238 100644 --- a/cypress/integration/common/3c_lookup_column.js +++ b/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 diff --git a/cypress/integration/common/3d_rollup_column.js b/cypress/integration/common/3d_rollup_column.js index a6d1d7d3ca..8e288030a1 100644 --- a/cypress/integration/common/3d_rollup_column.js +++ b/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) /** diff --git a/cypress/integration/common/4a_table_view_grid_gallery.js b/cypress/integration/common/4a_table_view_grid_gallery.js index 524cc74fbc..0060139bbb 100644 --- a/cypress/integration/common/4a_table_view_grid_gallery.js +++ b/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) /** diff --git a/cypress/integration/common/4b_table_view_share.js b/cypress/integration/common/4b_table_view_share.js index 506a98e4f0..7bc920cc5d 100644 --- a/cypress/integration/common/4b_table_view_share.js +++ b/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 diff --git a/cypress/integration/common/5a_user_role.js b/cypress/integration/common/5a_user_role.js index ba36230d60..e7986b465e 100644 --- a/cypress/integration/common/5a_user_role.js +++ b/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) diff --git a/cypress/integration/common/5b_preview_role.js b/cypress/integration/common/5b_preview_role.js index 13b8c2f33e..1fcdde389d 100644 --- a/cypress/integration/common/5b_preview_role.js +++ b/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,355 +14,361 @@ 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) => { - - cy.log(`##### advancedSettings: ${roleType}`) - - let validationString = (true == roles[roleType].validations.advSettings) ? 'exist' : 'not.exist' - - // restricted mode has only 3 lists & 3 items - let vListLength = (true == roles[roleType].validations.advSettings) ? 4 : 3 - let vListItemLength = (true == roles[roleType].validations.advSettings) ? 6 : 3 - - cy.get('.nc-nav-drawer').find('.v-list').should('has.length', vListLength) - cy.get('.nc-nav-drawer').find('.v-list > .v-list-item').should('has.length', vListItemLength) - - cy.get('.nc-nav-drawer').find('.v-list > .v-list-item').contains('Audit').should('exist') - cy.get('.nc-nav-drawer').find('.v-list > .v-list-item').contains('App Store').should(validationString) - cy.get('.nc-nav-drawer').find('.v-list > .v-list-item').contains('Team & Auth').should(validationString) - cy.get('.nc-nav-drawer').find('.v-list > .v-list-item').contains('Project Metadata').should(validationString) - - // preview mode- common across all - cy.get('.nc-nav-drawer').find('.v-list').last().contains('editor').should('exist') - cy.get('.nc-nav-drawer').find('.v-list').last().contains('commenter').should('exist') - cy.get('.nc-nav-drawer').find('.v-list').last().contains('viewer').should('exist') - - // Reset preview option available only in 'preview mode' - // Open team & auth after reset-preview to ensure 'New User' button is visible again + // project configuration settings // - if (true == roles[roleType].validations.advSettings) { - cy.get('.nc-nav-drawer').find('.v-list').last().contains('Reset Preview').should('not.exist') - cy.get('.nc-nav-drawer').find('.v-list > .v-list-item').contains('Team & Auth').click() - } - else { - cy.get('.nc-nav-drawer').find('.v-list').last().contains('Reset Preview').should('exist') - } + const advancedSettings = (roleType) => { - cy.get('button:contains("New User")').should(validationString) -} + cy.log(`##### advancedSettings: ${roleType}`) + let validationString = (true == roles[roleType].validations.advSettings) ? 'exist' : 'not.exist' -// Table data related validations -// - Add/delete/modify row -// -const editData = (roleType) => { + // restricted mode has only 3 lists & 3 items + let vListLength = (true == roles[roleType].validations.advSettings) ? 4 : 3 + let vListItemLength = (true == roles[roleType].validations.advSettings) ? 6 : 3 - cy.log(`##### editData: ${roleType}`) + cy.get('.nc-nav-drawer').find('.v-list').should('has.length', vListLength) + cy.get('.nc-nav-drawer').find('.v-list > .v-list-item').should('has.length', vListItemLength) - // TODO: to be fixed for roleType = 'editor' - // Some of the expected buttons are invisible - if (roleType == 'editor') - return false + cy.get('.nc-nav-drawer').find('.v-list > .v-list-item').contains('Audit').should('exist') + cy.get('.nc-nav-drawer').find('.v-list > .v-list-item').contains('App Store').should(validationString) + cy.get('.nc-nav-drawer').find('.v-list > .v-list-item').contains('Team & Auth').should(validationString) + cy.get('.nc-nav-drawer').find('.v-list > .v-list-item').contains('Project Metadata').should(validationString) - // TODO: to be fixed for roleType = 'editor' - // Unhandled exception - if (roleType == 'viewer') - return false + // preview mode- common across all + cy.get('.nc-nav-drawer').find('.v-list').last().contains('editor').should('exist') + cy.get('.nc-nav-drawer').find('.v-list').last().contains('commenter').should('exist') + cy.get('.nc-nav-drawer').find('.v-list').last().contains('viewer').should('exist') - let columnName = 'City' - let validationString = (true == roles[roleType].validations.editData) ? 'exist' : 'not.exist' + // Reset preview option available only in 'preview mode' + // Open team & auth after reset-preview to ensure 'New User' button is visible again + // + if (true == roles[roleType].validations.advSettings) { + cy.get('.nc-nav-drawer').find('.v-list').last().contains('Reset Preview').should('not.exist') + cy.get('.nc-nav-drawer').find('.v-list > .v-list-item').contains('Team & Auth').click() + } + else { + cy.get('.nc-nav-drawer').find('.v-list').last().contains('Reset Preview').should('exist') + } + + cy.get('button:contains("New User")').should(validationString) + } - cy.openTableTab(columnName) - // add new row option (from menu header) + // Table data related validations + // - Add/delete/modify row // - cy.get('.nc-add-new-row-btn').should(validationString) + const editData = (roleType) => { - // update row option (right click) - // + cy.log(`##### editData: ${roleType}`) - // TODO: roleType = viewer has an unhandled exception for rightClick - if (roleType != 'viewer') { - cy.get(`tbody > :nth-child(4) > [data-col="City"]`).rightclick() - cy.get('.menuable__content__active').should(validationString) - } + // TODO: to be fixed for roleType = 'editor' + // Some of the expected buttons are invisible + if (roleType == 'editor') + return false - if (validationString == 'exist') { + // TODO: to be fixed for roleType = 'editor' + // Unhandled exception + if (roleType == 'viewer') + return false - // right click options will exist (only for 'exist' case) - // - cy.getActiveMenu().contains('Insert New Row').should(validationString) - cy.getActiveMenu().contains('Delete Row').should(validationString) - cy.getActiveMenu().contains('Delete Selected Rows').should(validationString) - cy.get('body').type('{esc}') + let columnName = 'City' + let validationString = (true == roles[roleType].validations.editData) ? 'exist' : 'not.exist' - // update cell contents option using row expander should be enabled - // - //cy.get('.nc-row-expand-icon').eq(4).click({ force: true }) - cy.get('.v-input.row-checkbox').eq(4).next().next().click({ force: true }) - cy.getActiveModal().find('button').contains('Save Row').should('exist') - cy.get('body').type('{esc}') + cy.openTableTab(columnName) - } - else { - // update cell contents option using row expander should be disabled + // add new row option (from menu header) // - //cy.get('.nc-row-expand-icon').eq(4).click({ force: true }) - cy.get('.v-input.row-checkbox').eq(4).next().next().click({ force: true }) - cy.getActiveModal().find('button:disabled').contains('Save Row').should('exist') - cy.getActiveModal().find('button').contains('Cancel').click() - cy.get('body').type('{esc}') - } - - // double click cell entries to edit - // - cy.get(`tbody > :nth-child(4) > [data-col="City"]`).dblclick().find('input').should(validationString) -} - + cy.get('.nc-add-new-row-btn').should(validationString) -// Schema related validations -// - Add/delete table -// - Add/Update/delete column -// -const editSchema = (roleType) => { + // update row option (right click) + // - cy.log(`##### editSchema: ${roleType}`) + // TODO: roleType = viewer has an unhandled exception for rightClick + if (roleType != 'viewer') { + cy.get(`tbody > :nth-child(4) > [data-col="City"]`).rightclick() + cy.get('.menuable__content__active').should(validationString) + } - let columnName = 'City' - let validationString = (true == roles[roleType].validations.editSchema) ? 'exist' : 'not.exist' + if (validationString == 'exist') { - // create table options - // - cy.get('.add-btn').should(validationString) - cy.get('.v-tabs-bar').eq(0).find('button.mdi-plus-box').should(validationString) + // right click options will exist (only for 'exist' case) + // + cy.getActiveMenu().contains('Insert New Row').should(validationString) + cy.getActiveMenu().contains('Delete Row').should(validationString) + cy.getActiveMenu().contains('Delete Selected Rows').should(validationString) + cy.get('body').type('{esc}') - // delete table option - // - cy.get('.nc-table-delete-btn').should(validationString) + // update cell contents option using row expander should be enabled + // + //cy.get('.nc-row-expand-icon').eq(4).click({ force: true }) + cy.get('.v-input.row-checkbox').eq(4).next().next().click({ force: true }) + cy.getActiveModal().find('button').contains('Save Row').should('exist') + cy.get('body').type('{esc}') + + } + else { + // update cell contents option using row expander should be disabled + // + //cy.get('.nc-row-expand-icon').eq(4).click({ force: true }) + cy.get('.v-input.row-checkbox').eq(4).next().next().click({ force: true }) + cy.getActiveModal().find('button:disabled').contains('Save Row').should('exist') + cy.getActiveModal().find('button').contains('Cancel').click() + cy.get('body').type('{esc}') + } + + // double click cell entries to edit + // + cy.get(`tbody > :nth-child(4) > [data-col="City"]`).dblclick().find('input').should(validationString) + } - // add new column option - // - cy.get('.new-column-header').should(validationString) - // update column (edit/ delete menu) + // Schema related validations + // - Add/delete table + // - Add/Update/delete column // - cy.get(`th:contains(${columnName}) .mdi-menu-down`).should(validationString) + const editSchema = (roleType) => { -} + cy.log(`##### editSchema: ${roleType}`) + let columnName = 'City' + let validationString = (true == roles[roleType].validations.editSchema) ? 'exist' : 'not.exist' -// read &/ update comment -// Viewer: only allowed to read -// Everyone else: read &/ update -// -const editComment = (roleType) => { + // create table options + // + cy.get('.add-btn').should(validationString) + cy.get('.v-tabs-bar').eq(0).find('button.mdi-plus-box').should(validationString) - cy.log(`##### editComment: ${roleType}`) + // delete table option + // + cy.get('.nc-table-delete-btn').should(validationString) - // TODO: to be fixed for roleType = 'editor' - // Unhandled exception - if (roleType == 'viewer') - return false + // add new column option + // + cy.get('.new-column-header').should(validationString) + // update column (edit/ delete menu) + // + cy.get(`th:contains(${columnName}) .mdi-menu-down`).should(validationString) - let columnName = 'City' - let validationString = (true == roles[roleType].validations.editComment) ? 'Comment added successfully' : 'Not allowed' + } - cy.openTableTab(columnName) - // click on comment icon & type comment + // read &/ update comment + // Viewer: only allowed to read + // Everyone else: read &/ update // + const editComment = (roleType) => { - cy.get('.v-input.row-checkbox').eq(4).next().next().click({ force: true }) - //cy.get('.nc-row-expand-icon').eq(4).click({ force: true }) - cy.getActiveModal().find('.mdi-comment-multiple-outline').should('exist').click() - cy.getActiveModal().find('.comment-box').type('Comment-1{enter}') - cy.getActiveModal().find('.mdi-door-open').click() + cy.log(`##### editComment: ${roleType}`) - // Expected response: - // Viewer: Not allowed - // Everyone else: Comment added successfully - // - cy.get('body').contains(validationString, { timeout: 2000 }).should('exist') - cy.wait(1000) - cy.getActiveModal().find('button').contains('Cancel').click() - cy.get('body').type('{esc}') -} + // TODO: to be fixed for roleType = 'editor' + // Unhandled exception + if (roleType == 'viewer') + return false -// right navigation menu bar -// Editor/Viewer/Commenter : can only view 'existing' views -// Rest: can create/edit -const viewMenu = (roleType) => { - cy.log(`##### viewMenu: ${roleType}`) + let columnName = 'City' + let validationString = (true == roles[roleType].validations.editComment) ? 'Comment added successfully' : 'Not allowed' - // TODO: to be fixed for roleType = 'editor' - // Unhandled exception - if (roleType == 'viewer') - return false + cy.openTableTab(columnName) - let columnName = 'City' - let navDrawListCnt = 2 - let navDrawListItemCnt = 5 - cy.openTableTab(columnName) - let validationString = (true == roles[roleType].validations.shareView) ? 'exist' : 'not.exist' + // click on comment icon & type comment + // - // validate if Share button is visible at header tool bar - cy.get('header.v-toolbar').eq(0).find('button:contains("Share")').should(validationString) + cy.get('.v-input.row-checkbox').eq(4).next().next().click({ force: true }) + //cy.get('.nc-row-expand-icon').eq(4).click({ force: true }) + cy.getActiveModal().find('.mdi-comment-multiple-outline').should('exist').click() + cy.getActiveModal().find('.comment-box').type('Comment-1{enter}') + cy.getActiveModal().find('.mdi-door-open').click() - // Owner, Creator will have two navigation drawer (on each side of center panel) - if (validationString == 'exist') { - navDrawListCnt = 4 - navDrawListItemCnt = 16 + // Expected response: + // Viewer: Not allowed + // Everyone else: Comment added successfully + // + cy.get('body').contains(validationString, { timeout: 2000 }).should('exist') + cy.wait(1000) + cy.getActiveModal().find('button').contains('Cancel').click() + cy.get('body').type('{esc}') } - 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) - - // redundant - // cy.get('.v-navigation-drawer__content').eq(1).find('.v-list-item').eq(0).contains('Views').should('exist') - // cy.get('.v-navigation-drawer__content').eq(1).find('.v-list-item').eq(1).contains('City').should('exist') - - // cy.get(`.nc-create-grid-view`).should(validationString) - // cy.get(`.nc-create-gallery-view`).should(validationString) -} + // right navigation menu bar + // Editor/Viewer/Commenter : can only view 'existing' views + // Rest: can create/edit + const viewMenu = (roleType) => { + + cy.log(`##### viewMenu: ${roleType}`) + + // TODO: to be fixed for roleType = 'editor' + // Unhandled exception + if (roleType == 'viewer') + return false + + let columnName = 'City' + let navDrawListCnt = 2 + let navDrawListItemCnt = 5 + cy.openTableTab(columnName) + let validationString = (true == roles[roleType].validations.shareView) ? 'exist' : 'not.exist' + + // validate if Share button is visible at header tool bar + cy.get('header.v-toolbar').eq(0).find('button:contains("Share")').should(validationString) + + // Owner, Creator will have two navigation drawer (on each side of center panel) + if (validationString == 'exist') { + navDrawListCnt = 4 + navDrawListItemCnt = 16 + } + 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) + + // redundant + // cy.get('.v-navigation-drawer__content').eq(1).find('.v-list-item').eq(0).contains('Views').should('exist') + // cy.get('.v-navigation-drawer__content').eq(1).find('.v-list-item').eq(1).contains('City').should('exist') + + // cy.get(`.nc-create-grid-view`).should(validationString) + // cy.get(`.nc-create-gallery-view`).should(validationString) + } -/////////////////////////////////////////////////////////// -//// Test Suite -describe('Role preview validations', () => { + /////////////////////////////////////////////////////////// + //// Test Suite - // Sign in/ open project - before(() => { - loginPage.signIn(roles.owner.credentials) - projectsPage.openProject('externalREST') - }) + describe('Role preview validations', () => { - const genTest = (roleType) => { + // Sign in/ open project + before(() => { + loginPage.signIn(roles.owner.credentials) + projectsPage.openProject('externalREST') + }) - it(`Role type: ${roleType} > Advanced settings validation`, () => { + const genTestSub = (roleType) => { - if (true == baseVerificationBeforePreview) - advancedSettings('owner') + it(`Role type: ${roleType} > Advanced settings validation`, () => { - // click on preview & wait for page to switch over - mainPage.navigationDraw(mainPage.ROLE_VIEW).contains(roleType).click() - cy.wait(3000) + if (true == baseVerificationBeforePreview) + advancedSettings('owner') - advancedSettings(roleType) + // click on preview & wait for page to switch over + mainPage.navigationDraw(mainPage.ROLE_VIEW).contains(roleType).click() + cy.wait(3000) - // reset preview to rollback to owner/creator mode - mainPage.navigationDraw(mainPage.ROLE_VIEW).contains('Reset Preview').click() - cy.wait(3000) + advancedSettings(roleType) - if (reVerificationAfterReset == true) - advancedSettings('owner') + // reset preview to rollback to owner/creator mode + mainPage.navigationDraw(mainPage.ROLE_VIEW).contains('Reset Preview').click() + cy.wait(3000) - }) + if (reVerificationAfterReset == true) + advancedSettings('owner') - it(`Role type: ${roleType} > Edit schema validation`, (done) => { - // known issue: to be fixed - // right click raising alarm 'not allowed' for viewer - // - cy.on('uncaught:exception', (err, runnable) => { - expect(err.message).to.include('Not allowed') - done() - return false }) - // open existing table-column - // - cy.openTableTab('City') + it(`Role type: ${roleType} > Edit schema validation`, (done) => { + // known issue: to be fixed + // right click raising alarm 'not allowed' for viewer + // + cy.on('uncaught:exception', (err, runnable) => { + expect(err.message).to.include('Not allowed') + done() + return false + }) - if (true == baseVerificationBeforePreview) - editSchema('owner') + // open existing table-column + // + cy.openTableTab('City') - // click on preview & wait for page to switch over - mainPage.navigationDraw(mainPage.ROLE_VIEW).contains(roleType).click() - cy.wait(10000) + if (true == baseVerificationBeforePreview) + editSchema('owner') - editSchema(roleType) + // click on preview & wait for page to switch over + mainPage.navigationDraw(mainPage.ROLE_VIEW).contains(roleType).click() + cy.wait(10000) - // reset preview to rollback to owner/creator mode - mainPage.navigationDraw(mainPage.ROLE_VIEW).contains('Reset Preview').click() - cy.wait(10000) + editSchema(roleType) - if (reVerificationAfterReset == true) - editSchema('owner') + // reset preview to rollback to owner/creator mode + mainPage.navigationDraw(mainPage.ROLE_VIEW).contains('Reset Preview').click() + cy.wait(10000) - cy.wait(100).then(() => { - done() + if (reVerificationAfterReset == true) + editSchema('owner') + + cy.wait(100).then(() => { + done() + }) }) - }) - it(`Role type: ${roleType} > Edit data validations`, () => { + it(`Role type: ${roleType} > Edit data validations`, () => { - if (true == baseVerificationBeforePreview) - editData('owner') + if (true == baseVerificationBeforePreview) + editData('owner') - // click on preview & wait for page to switch over - mainPage.navigationDraw(mainPage.ROLE_VIEW).contains(roleType).click() - cy.wait(3000) + // click on preview & wait for page to switch over + mainPage.navigationDraw(mainPage.ROLE_VIEW).contains(roleType).click() + cy.wait(3000) - editData(roleType) + editData(roleType) - // reset preview to rollback to owner/creator mode - mainPage.navigationDraw(mainPage.ROLE_VIEW).contains('Reset Preview').click() - cy.wait(3000) + // reset preview to rollback to owner/creator mode + mainPage.navigationDraw(mainPage.ROLE_VIEW).contains('Reset Preview').click() + cy.wait(3000) - if (reVerificationAfterReset == true) - editData('owner') - }) + if (reVerificationAfterReset == true) + editData('owner') + }) - it(`Role type: ${roleType} > Edit comment validations`, () => { + it(`Role type: ${roleType} > Edit comment validations`, () => { - if (true == baseVerificationBeforePreview) - editComment('owner') + if (true == baseVerificationBeforePreview) + editComment('owner') - // click on preview & wait for page to switch over - mainPage.navigationDraw(mainPage.ROLE_VIEW).contains(roleType).click() - cy.wait(3000) + // click on preview & wait for page to switch over + mainPage.navigationDraw(mainPage.ROLE_VIEW).contains(roleType).click() + cy.wait(3000) - editComment(roleType) + editComment(roleType) - // reset preview to rollback to owner/creator mode - mainPage.navigationDraw(mainPage.ROLE_VIEW).contains('Reset Preview').click() - cy.wait(3000) + // reset preview to rollback to owner/creator mode + mainPage.navigationDraw(mainPage.ROLE_VIEW).contains('Reset Preview').click() + cy.wait(3000) - if (reVerificationAfterReset == true) - editComment('owner') - }) + if (reVerificationAfterReset == true) + editComment('owner') + }) - it(`Role type: ${roleType} > View menu validations`, () => { + it(`Role type: ${roleType} > View menu validations`, () => { - if (true == baseVerificationBeforePreview) - viewMenu('owner') + if (true == baseVerificationBeforePreview) + viewMenu('owner') - // click on preview & wait for page to switch over - mainPage.navigationDraw(mainPage.ROLE_VIEW).contains(roleType).click() - cy.wait(3000) + // click on preview & wait for page to switch over + mainPage.navigationDraw(mainPage.ROLE_VIEW).contains(roleType).click() + cy.wait(3000) - viewMenu(roleType) + viewMenu(roleType) - // reset preview to rollback to owner/creator mode - mainPage.navigationDraw(mainPage.ROLE_VIEW).contains('Reset Preview').click() - cy.wait(3000) + // reset preview to rollback to owner/creator mode + mainPage.navigationDraw(mainPage.ROLE_VIEW).contains('Reset Preview').click() + cy.wait(3000) - if (reVerificationAfterReset == true) - viewMenu('owner') - }) - } + if (reVerificationAfterReset == true) + viewMenu('owner') + }) + } - genTest('editor') - genTest('commenter') + genTestSub('editor') + genTestSub('commenter') + + // enable post xcAuditModeCommentsCount fix + // genTestSub('viewer') + }) + +} - // enable post xcAuditModeCommentsCount fix - // genTest('viewer') -}) +genTest('rest', false) diff --git a/cypress/integration/common/6a_audit.js b/cypress/integration/common/6a_audit.js index 3ed1d40142..52a8751560 100644 --- a/cypress/integration/common/6a_audit.js +++ b/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 diff --git a/cypress/integration/common/6c_swagger_api.js b/cypress/integration/common/6c_swagger_api.js index 3c38329347..a4804148c6 100644 --- a/cypress/integration/common/6c_swagger_api.js +++ b/cypress/integration/common/6c_swagger_api.js @@ -2,164 +2,171 @@ 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`, () => { - before(()=> { - loginPage.loginAndOpenProject('rest', false) - }) +const genTest = (type, xcdb) => { + if(!isTestSuiteActive(type, xcdb)) return; - it("[REST] open project & record swagger URL, AuthToken", () => { - let authToken = mainPage.getAuthToken() - cy.url().then( (url) => { - // retrieve project name from URL & use it to construct Swagger URL - // URL on homepage: http://localhost:3000/#/nc/externalrest_weUO?type=roles&dbalias=&name=Team%20%26%20Auth%20 - // Swagger URL: http://localhost:8080/nc/externalrest_weUO/db/swagger - // - const projectName = url.split("/")[5].split("?")[0]; - let swaggerURL = `http://localhost:8080/nc/${projectName}/db/swagger` - - // exchange information between two tests using a file - // https://stackoverflow.com/questions/52050657/what-is-the-best-practice-of-pass-states-between-tests-in-cypress - // - cy.writeFile("shared.json", {SWAGGER_URL: swaggerURL, AUTH_TOKEN: authToken}) - }) + describe(`Swagger API - Test preparation`, () => { + before(()=> { + loginPage.loginAndOpenProject('rest', false) + }) + + it("[REST] open project & record swagger URL, AuthToken", () => { + let authToken = mainPage.getAuthToken() + cy.url().then( (url) => { + // retrieve project name from URL & use it to construct Swagger URL + // URL on homepage: http://localhost:3000/#/nc/externalrest_weUO?type=roles&dbalias=&name=Team%20%26%20Auth%20 + // Swagger URL: http://localhost:8080/nc/externalrest_weUO/db/swagger + // + const projectName = url.split("/")[5].split("?")[0]; + let swaggerURL = `http://localhost:8080/nc/${projectName}/db/swagger` + + // exchange information between two tests using a file + // https://stackoverflow.com/questions/52050657/what-is-the-best-practice-of-pass-states-between-tests-in-cypress + // + 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 - // - const getSwaggerButton = (tag, idx, desc) => { - return cy.get(`#operations-tag-${tag}`).next().find('.opblock').eq(idx).find(`button:contains(${desc})`) - } + // returns swagger button intended for + // + const getSwaggerButton = (tag, idx, desc) => { + return cy.get(`#operations-tag-${tag}`).next().find('.opblock').eq(idx).find(`button:contains(${desc})`) + } - let Token + let Token - // basic authentication tag verification - // - it("Swagger URL access & basic validation", () => { - // retrieve information stored in previous IT block + // basic authentication tag verification // - cy.readFile("shared.json").then((jsonPayload) => { - let URL = jsonPayload.SWAGGER_URL - Token = jsonPayload.AUTH_TOKEN - - cy.visit(URL) - cy.log(Token) - - // validate; API order assumed - cy.get('#operations-tag-Authentication').next().find('.opblock').should('has.length', 9) - getSwaggerButton("Authentication", 0, "User login").should('exist') - getSwaggerButton("Authentication", 1, "User signup").should('exist') - getSwaggerButton("Authentication", 2, "Password Forgot").should('exist') - getSwaggerButton("Authentication", 3, "Email validate link").should('exist') - getSwaggerButton("Authentication", 4, "Validate password reset token").should('exist') - getSwaggerButton("Authentication", 5, "Password reset").should('exist') - getSwaggerButton("Authentication", 6, "User details").should('exist') - getSwaggerButton("Authentication", 7, "Update user details").should('exist') - getSwaggerButton("Authentication", 8, "Update user details").should('exist') + it("Swagger URL access & basic validation", () => { + // retrieve information stored in previous IT block + // + cy.readFile("shared.json").then((jsonPayload) => { + let URL = jsonPayload.SWAGGER_URL + Token = jsonPayload.AUTH_TOKEN + + cy.visit(URL) + cy.log(Token) + + // validate; API order assumed + cy.get('#operations-tag-Authentication').next().find('.opblock').should('has.length', 9) + getSwaggerButton("Authentication", 0, "User login").should('exist') + getSwaggerButton("Authentication", 1, "User signup").should('exist') + getSwaggerButton("Authentication", 2, "Password Forgot").should('exist') + getSwaggerButton("Authentication", 3, "Email validate link").should('exist') + getSwaggerButton("Authentication", 4, "Validate password reset token").should('exist') + getSwaggerButton("Authentication", 5, "Password reset").should('exist') + getSwaggerButton("Authentication", 6, "User details").should('exist') + getSwaggerButton("Authentication", 7, "Update user details").should('exist') + getSwaggerButton("Authentication", 8, "Update user details").should('exist') + }) }) - }) - it("Authorize success: Valid token", ()=> { - // authorize button, feed token, click authorize - cy.get('[class="btn authorize unlocked"]').click() - cy.get('input').type(Token) - cy.get('.auth-btn-wrapper > .authorize').click() + it("Authorize success: Valid token", ()=> { + // authorize button, feed token, click authorize + cy.get('[class="btn authorize unlocked"]').click() + cy.get('input').type(Token) + cy.get('.auth-btn-wrapper > .authorize').click() - // Response: "Authorized" should exist on DOM - cy.get('.auth-container').contains('Authorized').should('exist') - cy.get('.btn-done').click() + // Response: "Authorized" should exist on DOM + cy.get('.auth-container').contains('Authorized').should('exist') + cy.get('.btn-done').click() - // Authorize button is LOCKED now - cy.get('[class="btn authorize locked"]').should('exist') - }) + // Authorize button is LOCKED now + cy.get('[class="btn authorize locked"]').should('exist') + }) - it("Execute Authentication (valid token case) > GET: User details API", ()=> { - // Auth> User details API - getSwaggerButton("Authentication", 6, "User details").click() + it("Execute Authentication (valid token case) > GET: User details API", ()=> { + // Auth> User details API + getSwaggerButton("Authentication", 6, "User details").click() - // "Try it out" button, followed by "Execute" - cy.get('.try-out > .btn').click() - cy.get('.execute-wrapper > .btn').click() + // "Try it out" button, followed by "Execute" + cy.get('.try-out > .btn').click() + cy.get('.execute-wrapper > .btn').click() - // check response: validate email credentials - cy.get('.highlight-code > .microlight').contains('email').should('exist') - cy.get('.highlight-code > .microlight').contains(roles.owner.credentials.username).should('exist') + // check response: validate email credentials + cy.get('.highlight-code > .microlight').contains('email').should('exist') + cy.get('.highlight-code > .microlight').contains(roles.owner.credentials.username).should('exist') - // reset operations (clear, cancel, windback User details tab) - cy.get('.btn-clear').click() - cy.get('.try-out > .btn').click() - getSwaggerButton("Authentication", 6, "User details").click() - }) + // reset operations (clear, cancel, windback User details tab) + cy.get('.btn-clear').click() + cy.get('.try-out > .btn').click() + getSwaggerButton("Authentication", 6, "User details").click() + }) - it("Logout post authorization", ()=> { - // authorize button, logout - cy.get('[class="btn authorize locked"]').click() - cy.get('.auth-btn-wrapper > button:contains("Logout")').click() - cy.get('.btn-done').click() - - // Authorize button is UNLOCKED now - cy.get('[class="btn authorize unlocked"]').should('exist') - }) - - it("Execute Authentication (logout case) > GET: User details API", ()=> { - // Auth> User details API - getSwaggerButton("Authentication", 6, "User details").click() - - // "Try it out" button, followed by "Execute" - cy.get('.try-out > .btn').click() - cy.get('.execute-wrapper > .btn').click() - - // check response: email credentials shouldnt exist. should display 'guest:true' - cy.get('.highlight-code > .microlight').contains('guest').should('exist') - cy.get('.highlight-code > .microlight').contains('email').should('not.exist') - cy.get('.highlight-code > .microlight').contains(roles.owner.credentials.username).should('not.exist') - - // reset operations (clear, cancel, windback User details tab) - cy.get('.btn-clear').click() - cy.get('.try-out > .btn').click() - getSwaggerButton("Authentication", 6, "User details").click() - }) + it("Logout post authorization", ()=> { + // authorize button, logout + cy.get('[class="btn authorize locked"]').click() + cy.get('.auth-btn-wrapper > button:contains("Logout")').click() + cy.get('.btn-done').click() + + // Authorize button is UNLOCKED now + cy.get('[class="btn authorize unlocked"]').should('exist') + }) + + it("Execute Authentication (logout case) > GET: User details API", ()=> { + // Auth> User details API + getSwaggerButton("Authentication", 6, "User details").click() + + // "Try it out" button, followed by "Execute" + cy.get('.try-out > .btn').click() + cy.get('.execute-wrapper > .btn').click() + + // check response: email credentials shouldnt exist. should display 'guest:true' + cy.get('.highlight-code > .microlight').contains('guest').should('exist') + cy.get('.highlight-code > .microlight').contains('email').should('not.exist') + cy.get('.highlight-code > .microlight').contains(roles.owner.credentials.username).should('not.exist') + + // reset operations (clear, cancel, windback User details tab) + cy.get('.btn-clear').click() + cy.get('.try-out > .btn').click() + getSwaggerButton("Authentication", 6, "User details").click() + }) - it("Authorize failure: invalid token", ()=> { - // authorize button, feed *invalid* token, click authorize - cy.get('[class="btn authorize unlocked"]').click() - cy.get('input').type('xyz') - cy.get('.auth-btn-wrapper > .authorize').click() - - // Response: "Authorized" should *not* exist on DOM - // TBD: cy.get('.auth-container').contains('Authorized').should('not.exist') - cy.get('.btn-done').click() - - // Authorize button should be UNLOCKED now - // TBD: cy.get('[class="btn authorize unlocked"]').should('exist') - }) - - it("Execute Authentication (invalid token case) > GET: User details API", ()=> { - // Auth> User details API - getSwaggerButton("Authentication", 6, "User details").click() - - // "Try it out" button, followed by "Execute" - cy.get('.try-out > .btn').click() - cy.get('.execute-wrapper > .btn').click() - - // check response: email credentials shouldnt exist. should display 'guest:true' - cy.get('.highlight-code > .microlight').contains('guest').should('exist') - cy.get('.highlight-code > .microlight').contains('email').should('not.exist') - cy.get('.highlight-code > .microlight').contains(roles.owner.credentials.username).should('not.exist') - - // reset operations (clear, cancel, windback User details tab) - cy.get('.btn-clear').click() - cy.get('.try-out > .btn').click() - getSwaggerButton("Authentication", 6, "User details").click() - }) + it("Authorize failure: invalid token", ()=> { + // authorize button, feed *invalid* token, click authorize + cy.get('[class="btn authorize unlocked"]').click() + cy.get('input').type('xyz') + cy.get('.auth-btn-wrapper > .authorize').click() + + // Response: "Authorized" should *not* exist on DOM + // TBD: cy.get('.auth-container').contains('Authorized').should('not.exist') + cy.get('.btn-done').click() + + // Authorize button should be UNLOCKED now + // TBD: cy.get('[class="btn authorize unlocked"]').should('exist') + }) + + it("Execute Authentication (invalid token case) > GET: User details API", ()=> { + // Auth> User details API + getSwaggerButton("Authentication", 6, "User details").click() + + // "Try it out" button, followed by "Execute" + cy.get('.try-out > .btn').click() + cy.get('.execute-wrapper > .btn').click() + + // check response: email credentials shouldnt exist. should display 'guest:true' + cy.get('.highlight-code > .microlight').contains('guest').should('exist') + cy.get('.highlight-code > .microlight').contains('email').should('not.exist') + cy.get('.highlight-code > .microlight').contains(roles.owner.credentials.username).should('not.exist') + + // reset operations (clear, cancel, windback User details tab) + cy.get('.btn-clear').click() + cy.get('.try-out > .btn').click() + getSwaggerButton("Authentication", 6, "User details").click() + }) - // clean-up created file (shared.json) - after(() => { - cy.exec("del shared.json").then(()=> { - cy.log("file cleaned up!") + // clean-up created file (shared.json) + after(() => { + cy.exec("del shared.json").then(()=> { + cy.log("file cleaned up!") + }) }) }) -}) +} + +genTest('rest', false) diff --git a/cypress/support/page_objects/projectConstants.js b/cypress/support/page_objects/projectConstants.js index 0827ebaf87..68bbebd5a5 100644 --- a/cypress/support/page_objects/projectConstants.js +++ b/cypress/support/page_objects/projectConstants.js @@ -62,4 +62,46 @@ export const staticProjects = { basic: { dbType: 'external', apiType: 'GQL', name: 'externalGQL' }, 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; + } } \ No newline at end of file