From f246c7f87cdcbc7aa5aa11d3dafd26f7d8e6f7e6 Mon Sep 17 00:00:00 2001 From: Raju Udava Date: Tue, 21 Sep 2021 12:59:15 +0530 Subject: [PATCH] test: [cypress] stability & error scenario handling Signed-off-by: Raju Udava --- .../integration/common/1a_table_operations.js | 39 +++++++------------ .../3a_filter_sort_fields_operations.js | 25 +++++++++--- .../integration/common/3d_rollup_column.js | 2 + .../common/4a_table_view_grid_gallery.js | 4 +- .../integration/common/4b_table_view_share.js | 2 +- cypress/integration/common/5a_user_role.js | 21 +++++----- cypress/integration/common/5b_preview_role.js | 2 +- cypress/support/page_objects/navigation.js | 10 ++++- 8 files changed, 60 insertions(+), 45 deletions(-) diff --git a/cypress/integration/common/1a_table_operations.js b/cypress/integration/common/1a_table_operations.js index 472a38b1ee..04fbb8a2e2 100644 --- a/cypress/integration/common/1a_table_operations.js +++ b/cypress/integration/common/1a_table_operations.js @@ -1,27 +1,12 @@ -import { loginPage, projectsPage } from "../../support/page_objects/navigation"; -import { roles, staticProjects } from "../../support/page_objects/projectConstants"; +import { loginPage } from "../../support/page_objects/navigation"; -const genTest = (type, meta) => { +const genTest = (type, xcdb) => { - describe(`${meta ? 'Meta - ' : ''}${type.toUpperCase()} api - Table`, () => { + describe(`${xcdb ? 'Meta - ' : ''}${type.toUpperCase()} api - Table`, () => { before(() => { - 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) - } + loginPage.loginAndOpenProject(type, xcdb) }) const name = 'Test' + Date.now(); @@ -29,16 +14,20 @@ const genTest = (type, meta) => { // create a new random table it('Create Table', () => { cy.get('.add-btn').click(); - cy.get('.nc-create-table-card .nc-table-name input[type="text"]').first().click().clear().type(name) - if (!meta) { - cy.get('.nc-create-table-card .nc-table-name-alias input[type="text"]').first().should('have.value', name.toLowerCase()) + cy.get('.nc-create-table-card .nc-table-name input[type="text"]') + .first().click().clear().type(name) + + if (!xcdb) { + 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) + cy.wait(5000) }) @@ -58,8 +47,8 @@ const genTest = (type, meta) => { } -genTest('rest') -genTest('graphql') +genTest('rest', false) +genTest('graphql', false) genTest('rest', true) genTest('graphql', true) diff --git a/cypress/integration/common/3a_filter_sort_fields_operations.js b/cypress/integration/common/3a_filter_sort_fields_operations.js index 20bcea1a35..b42aa94f6c 100644 --- a/cypress/integration/common/3a_filter_sort_fields_operations.js +++ b/cypress/integration/common/3a_filter_sort_fields_operations.js @@ -86,6 +86,9 @@ const genTest = (type) => { // verify mainPage.getCell("Country", 10).should('not.exist') mainPage.getCell("Country", 11).should('not.exist') + + cy.wait(1000) + mainPage.getPagination(1).click() }) }) @@ -114,20 +117,24 @@ const genTest = (type) => { describe('Field Operation', () => { - before(() => { - cy.get('.nc-fields-menu-btn').click() - }) + // before(() => { + // cy.get('.nc-fields-menu-btn').click() + // }) - if ('Hide field', () => { + it('Hide field', () => { cy.get('th:contains(LastUpdate)').should('be.visible') // toggle and confirm it's hidden + cy.get('.nc-fields-menu-btn').click() cy.get('.menuable__content__active .v-list-item label:contains(LastUpdate)').click() + cy.get('.nc-fields-menu-btn').click() cy.get('th:contains(LastUpdate)').should('not.be.visible') }) it('Show field', () => { + cy.get('.nc-fields-menu-btn').click() cy.get('.menuable__content__active .v-list-item label:contains(LastUpdate)').click() + cy.get('.nc-fields-menu-btn').click() cy.get('th:contains(LastUpdate)').should('be.visible') }) }) @@ -139,17 +146,23 @@ const genTest = (type) => { cy.contains('Add Filter').click(); cy.get('.nc-filter-field-select').last().click(); - cy.get('.menuable__content__active .v-list-item:contains(Country)').click() + cy.getActiveMenu().find('.v-list-item:contains(Country)').click() cy.get('.nc-filter-operation-select').last().click(); - cy.get('.menuable__content__active .v-list-item:contains("is equal")').click() + cy.getActiveMenu().find('.v-list-item:contains("is equal")').click() cy.get('.nc-filter-value-select input:text').last().type('India'); + // cy.getActiveMenu().find('button:contains("Apply changes")').click() + cy.get('.nc-filter-menu-btn').click() + cy.wait(1000) cy.get('td:contains(India)').should('exist') }) it('Delete Filter', () => { // remove sort and check + cy.get('.nc-filter-menu-btn').click() cy.get('.nc-filter-item-remove-btn').click() + // cy.getActiveMenu().find('button:contains("Apply changes")').click() + cy.get('.nc-filter-menu-btn').click() cy.contains('td:contains(India)').should('not.exist') }) }) diff --git a/cypress/integration/common/3d_rollup_column.js b/cypress/integration/common/3d_rollup_column.js index 323decc62f..a6d1d7d3ca 100644 --- a/cypress/integration/common/3d_rollup_column.js +++ b/cypress/integration/common/3d_rollup_column.js @@ -1,3 +1,5 @@ +import { loginPage } from "../../support/page_objects/navigation" + const genTest = (type) => { describe(`${type.toUpperCase()} api - RollUp column`, () => { diff --git a/cypress/integration/common/4a_table_view_grid_gallery.js b/cypress/integration/common/4a_table_view_grid_gallery.js index d3d87e7c77..524cc74fbc 100644 --- a/cypress/integration/common/4a_table_view_grid_gallery.js +++ b/cypress/integration/common/4a_table_view_grid_gallery.js @@ -1,3 +1,5 @@ +import { loginPage } from "../../support/page_objects/navigation" + const genTest = (dbType) => { describe(`${dbType.toUpperCase()} api - Table views`, () => { @@ -7,7 +9,7 @@ const genTest = (dbType) => { // Run once before test- create project (rest/graphql) // before(() => { - loginPage.loginAndOpenProject(type) + loginPage.loginAndOpenProject(dbType) // open a table to work on views // diff --git a/cypress/integration/common/4b_table_view_share.js b/cypress/integration/common/4b_table_view_share.js index 0e34fdb304..506a98e4f0 100644 --- a/cypress/integration/common/4b_table_view_share.js +++ b/cypress/integration/common/4b_table_view_share.js @@ -12,7 +12,7 @@ const shareViewWithPwd = (pwdCorrect, pwd) => { // copy link text, visit URL cy.getActiveModal().find('.share-link-box') - .contains('http', {timeout: 2000}) + .contains('http', {timeout: 10000}) .then(($obj) => { let linkText = $obj.text() diff --git a/cypress/integration/common/5a_user_role.js b/cypress/integration/common/5a_user_role.js index 02d3ee6182..ba36230d60 100644 --- a/cypress/integration/common/5a_user_role.js +++ b/cypress/integration/common/5a_user_role.js @@ -1,6 +1,6 @@ -import { loginPage } from "../../support/page_objects/navigation" +import { loginPage, projectsPage } from "../../support/page_objects/navigation" import { mainPage } from "../../support/page_objects/mainPage" -import { roles } from "../../support/page_objects/projectConstants" +import { roles, staticProjects } from "../../support/page_objects/projectConstants" const genTest = (apiType, roleType) => { @@ -20,7 +20,7 @@ const genTest = (apiType, roleType) => { mainPage.navigationDraw(mainPage.TEAM_N_AUTH).should(validationString) mainPage.navigationDraw(mainPage.PROJ_METADATA).should(validationString) - mainPage.navigationDraw(mainPage.ROLE_VIEW).should(validationString) + // mainPage.navigationDraw(mainPage.ROLE_VIEW).should(validationString) if ('exist' == validationString) { mainPage.navigationDraw(mainPage.ROLE_VIEW).contains('editor') mainPage.navigationDraw(mainPage.ROLE_VIEW).contains('commenter') @@ -28,7 +28,6 @@ const genTest = (apiType, roleType) => { } cy.get('button:contains("New User")').should(validationString) - } @@ -81,7 +80,7 @@ const genTest = (apiType, roleType) => { // update row option (right click) // - cy.get(`tbody > :nth-child(4) > [data-col="City"]`).rightclick() + cy.get(`tbody > :nth-child(8) > [data-col="City"]`).rightclick() cy.get('.menuable__content__active').should(validationString) @@ -113,7 +112,7 @@ const genTest = (apiType, roleType) => { // double click cell entries to edit // - cy.get(`tbody > :nth-child(4) > [data-col="City"]`).dblclick().find('input').should(validationString) + cy.get(`tbody > :nth-child(8) > [data-col="City"]`).dblclick().find('input').should(validationString) } @@ -131,7 +130,7 @@ const genTest = (apiType, roleType) => { // click on comment icon & type comment // - cy.get('.v-input.row-checkbox').eq(4).next().next().click({ force: true }) + cy.get('.v-input.row-checkbox').eq(8).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}') @@ -180,9 +179,11 @@ const genTest = (apiType, roleType) => { // Test suite it(`[${roles[roleType].name}] SignIn, Open project`, () => { - //loginPage.signIn(roles[roleType].credentials) - //projectsPage.openProject('sakilaDb') - loginPage.loginAndOpenProject(apiType) + loginPage.signIn(roles[roleType].credentials) + if('rest' == apiType) + projectsPage.openProject(staticProjects.externalREST.basic.name) + else + projectsPage.openProject(staticProjects.externalGQL.basic.name) }) it(`[${roles[roleType].name}] Left navigation menu, New User add`, () => { diff --git a/cypress/integration/common/5b_preview_role.js b/cypress/integration/common/5b_preview_role.js index 76cf5334a2..2f15771870 100644 --- a/cypress/integration/common/5b_preview_role.js +++ b/cypress/integration/common/5b_preview_role.js @@ -237,7 +237,7 @@ describe('Role preview validations', () => { // Sign in/ open project before(() => { loginPage.signIn(roles.owner.credentials) - projectsPage.openProject('sakilaDb') + projectsPage.openProject('externalREST') }) const genTest = (roleType) => { diff --git a/cypress/support/page_objects/navigation.js b/cypress/support/page_objects/navigation.js index 3a5df48624..0bc6ad1dda 100644 --- a/cypress/support/page_objects/navigation.js +++ b/cypress/support/page_objects/navigation.js @@ -54,13 +54,21 @@ export class _loginPage { // standard pre-project activity // - loginAndOpenProject(apiType) { + loginAndOpenProject(apiType, xcdb) { loginPage.signIn(roles.owner.credentials) + if(!xcdb) { if ('rest' == apiType) projectsPage.openProject(staticProjects.externalREST.basic.name) else projectsPage.openProject(staticProjects.externalGQL.basic.name) + } + else { + if ('rest' == apiType) + projectsPage.openProject(staticProjects.sampleREST.basic.name) + else + projectsPage.openProject(staticProjects.sampleGQL.basic.name) + } } }