Browse Source

test(cypress): fix inconsistency- inaccessible DOM element due to pagination delay

Signed-off-by: Raju Udava <sivadstala@gmail.com>
pull/805/head
Raju Udava 3 years ago
parent
commit
2bca2be339
  1. 128
      .github/workflows/ci-cd.yml
  2. 1
      scripts/cypress/integration/common/00_pre_configurations.js
  3. 21
      scripts/cypress/integration/common/1b_table_column_operations.js
  4. 81
      scripts/cypress/integration/common/1c_table_row_operations.js
  5. 21
      scripts/cypress/integration/common/3a_filter_sort_fields_operations.js
  6. 4
      scripts/cypress/plugins/index.js

128
.github/workflows/ci-cd.yml

@ -12,38 +12,38 @@ on:
- "scripts/cypress/**" - "scripts/cypress/**"
jobs: jobs:
#cypress-restTableOps-run: cypress-restTableOps-run:
# runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
# steps: steps:
# - name: Checkout - name: Checkout
# uses: actions/checkout@v2 uses: actions/checkout@v2
# with: with:
# fetch-depth: 0 fetch-depth: 0
# - name: Cache node modules - name: Cache node modules
# uses: actions/cache@v2 uses: actions/cache@v2
# env: env:
# cache-name: cache-node-modules cache-name: cache-node-modules
#
# with: with:
# # npm cache files are stored in `~/.npm` on Linux/macOS # npm cache files are stored in `~/.npm` on Linux/macOS
# path: ~/.npm path: ~/.npm
# key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
# restore-keys: | restore-keys: |
# ${{ runner.os }}-build-${{ env.cache-name }}- ${{ runner.os }}-build-${{ env.cache-name }}-
# ${{ runner.os }}-build- ${{ runner.os }}-build-
# ${{ runner.os }}- ${{ runner.os }}-
#
# - name: Cypress run - name: Cypress run
# uses: cypress-io/github-action@v2 uses: cypress-io/github-action@v2
# with: with:
# start: | start: |
# npm run start:api npm run start:api
# npm run start:web npm run start:web
# docker-compose -f ./scripts/docker-compose-cypress.yml up -d docker-compose -f ./scripts/docker-compose-cypress.yml up -d
# spec: "./scripts/cypress/integration/test/restTableOps.js" spec: "./scripts/cypress/integration/test/restTableOps.js"
# wait-on: "http://localhost:8080, http://localhost:3000/_nuxt/runtime.js" wait-on: "http://localhost:8080, http://localhost:3000/_nuxt/runtime.js"
# wait-on-timeout: 1200 wait-on-timeout: 1200
# config-file: scripts/cypress/cypress.json config-file: scripts/cypress/cypress.json
cypress-restViews-run: cypress-restViews-run:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
steps: steps:
@ -140,38 +140,38 @@ jobs:
wait-on: "http://localhost:8080, http://localhost:3000/_nuxt/runtime.js" wait-on: "http://localhost:8080, http://localhost:3000/_nuxt/runtime.js"
wait-on-timeout: 1200 wait-on-timeout: 1200
config-file: scripts/cypress/cypress.json config-file: scripts/cypress/cypress.json
#cypress-gqlTableOps-run: cypress-gqlTableOps-run:
# runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
# steps: steps:
# - name: Checkout - name: Checkout
# uses: actions/checkout@v2 uses: actions/checkout@v2
# with: with:
# fetch-depth: 0 fetch-depth: 0
# - name: Cache node modules - name: Cache node modules
# uses: actions/cache@v2 uses: actions/cache@v2
# env: env:
# cache-name: cache-node-modules cache-name: cache-node-modules
#
# with: with:
# # npm cache files are stored in `~/.npm` on Linux/macOS # npm cache files are stored in `~/.npm` on Linux/macOS
# path: ~/.npm path: ~/.npm
# key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
# restore-keys: | restore-keys: |
# ${{ runner.os }}-build-${{ env.cache-name }}- ${{ runner.os }}-build-${{ env.cache-name }}-
# ${{ runner.os }}-build- ${{ runner.os }}-build-
# ${{ runner.os }}- ${{ runner.os }}-
#
# - name: Cypress run - name: Cypress run
# uses: cypress-io/github-action@v2 uses: cypress-io/github-action@v2
# with: with:
# start: | start: |
# npm run start:api npm run start:api
# npm run start:web npm run start:web
# docker-compose -f ./scripts/docker-compose-cypress.yml up -d docker-compose -f ./scripts/docker-compose-cypress.yml up -d
# spec: "./scripts/cypress/integration/test/gqlTableOps.js" spec: "./scripts/cypress/integration/test/gqlTableOps.js"
# wait-on: "http://localhost:8080, http://localhost:3000/_nuxt/runtime.js" wait-on: "http://localhost:8080, http://localhost:3000/_nuxt/runtime.js"
# wait-on-timeout: 1200 wait-on-timeout: 1200
# config-file: scripts/cypress/cypress.json config-file: scripts/cypress/cypress.json
cypress-gqlViews-run: cypress-gqlViews-run:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
steps: steps:

1
scripts/cypress/integration/common/00_pre_configurations.js

@ -11,6 +11,7 @@ export const genTest = (type, xcdb) => {
describe(`Project pre-configurations`, () => { describe(`Project pre-configurations`, () => {
it('Admin SignUp', () => { it('Admin SignUp', () => {
cy.task('log', 'This will be output to the terminal')
cy.waitForSpinners(); cy.waitForSpinners();
cy.signinOrSignup(roles.owner.credentials) cy.signinOrSignup(roles.owner.credentials)
cy.wait(2000) cy.wait(2000)

21
scripts/cypress/integration/common/1b_table_column_operations.js

@ -10,8 +10,8 @@ export const genTest = (type, xcdb) => {
const name = 'tablex' const name = 'tablex'
const colName = 'column_name_a' const colName = 'column_name_a'
const updatedColName = 'updated_column_name' const updatedColName = 'updated_column_name'
const randVal = 'Test' const randVal = 'Test@1234.com'
const updatedRandVal = 'Updated' const updatedRandVal = 'Updated@1234.com'
before(() => { before(() => {
// loginPage.loginAndOpenProject(type) // loginPage.loginAndOpenProject(type)
@ -91,22 +91,19 @@ export const genTest = (type, xcdb) => {
cy.wait(2000) cy.wait(2000)
cy.get('.nc-add-new-row-btn').click({force: true}); cy.get('.nc-add-new-row-btn').click({force: true});
cy.get('#data-table-form-Title > input').first().type(randVal); cy.get('#data-table-form-Title > input').first().type(randVal);
cy.contains('Save Row').filter('button').click({force: true}) cy.getActiveModal().find('button').contains('Save Row').click({force: true})
cy.get('td', {timeout: 10000}).contains(randVal).should('exist'); mainPage.getCell('Title', 1).contains(randVal).should('exist')
}) })
it('Update row', () => { it('Update row', () => {
cy.get('td').contains(randVal) mainPage.getRow(1).find('.nc-row-expand-icon').click({force: true})
.closest('tr')
.find('.nc-row-expand-icon')
.click({force: true});
cy.get('#data-table-form-Title > input').first().clear().type(updatedRandVal); cy.get('#data-table-form-Title > input').first().clear().type(updatedRandVal);
cy.contains('Save Row').filter('button').click({force: true}) cy.getActiveModal().find('button').contains('Save Row').click({force: true})
cy.wait(3000) cy.wait(3000)
cy.get('td').contains(randVal).should('not.exist');
cy.get('td').contains(updatedRandVal).should('exist'); mainPage.getCell('Title', 1).contains(randVal).should('not.exist')
mainPage.getCell('Title', 1).contains(updatedRandVal).should('exist')
}) })
it('Delete row', () => { it('Delete row', () => {

81
scripts/cypress/integration/common/1c_table_row_operations.js

@ -1,81 +0,0 @@
import { loginPage } from "../../support/page_objects/navigation"
import { isTestSuiteActive } from "../../support/page_objects/projectConstants"
export const genTest = (type, xcdb) => {
if(!isTestSuiteActive(type, xcdb)) return;
describe(`${type.toUpperCase()} api - Table Row`, () => {
const randVal = 'Test' + Date.now();
const updatedRandVal = 'Updated' + Date.now();
const name = 'Tablerow' + Date.now();
before(() => {
//loginPage.loginAndOpenProject(type)
cy.createTable(name)
});
// delete table
after(() => {
cy.deleteTable(name)
});
it('Add new row', () => {
cy.get('.nc-add-new-row-btn').click({force: true});
cy.get('#data-table-form-Title > input').first().type(randVal);
cy.contains('Save Row').filter('button').click({force: true})
cy.get('td', {timeout: 10000}).contains(randVal).should('exist');
})
it('Update row', () => {
cy.get('td').contains(randVal)
.closest('tr')
.find('.nc-row-expand-icon')
.click({force: true});
cy.get('#data-table-form-Title > input').first().clear().type(updatedRandVal);
cy.contains('Save Row').filter('button').click({force: true})
cy.wait(3000).then(() => {
cy.get('td').contains(randVal).should('not.exist');
cy.get('td').contains(updatedRandVal).should('exist');
})
})
it('Delete row', () => {
cy.get('td').contains(updatedRandVal).rightclick({force: true})
// delete row
cy.getActiveMenu().find('.v-list-item:contains("Delete Row")').first().click({force: true})
cy.wait(1000)
cy.get('td').contains(randVal).should('not.exist');
})
});
}
// genTest('rest', false)
// genTest('graphql', false)
/**
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
*
* @author Pranav C Balan <pranavxc@gmail.com>
* @author Raju Udava <sivadstala@gmail.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

21
scripts/cypress/integration/common/3a_filter_sort_fields_operations.js

@ -65,15 +65,18 @@ export const genTest = (type, xcdb) => {
// create new row using right click menu option // create new row using right click menu option
// //
it('Add row using rightclick menu option', () => { it('Add row using rightclick menu option', () => {
mainPage.getPagination(5).click() // mainPage.getPagination(5).click({ force: true })
mainPage.getCell("Country", 9).rightclick() // wait before proceeding further to ensure reload is completed
cy.getActiveMenu().contains('Insert New Row').click() // cy.wait(1000)
mainPage.getCell("Country", 10).dblclick().type('Test Country-1{enter}')
mainPage.getCell("Country", 10).rightclick() mainPage.getCell("Country", 9).rightclick({force: true})
cy.getActiveMenu().contains('Insert New Row').click() cy.getActiveMenu().contains('Insert New Row').click({force: true})
mainPage.getCell("Country", 11).dblclick().type('Test Country-2{enter}') mainPage.getCell("Country", 10).dblclick().find('input').type('Test Country-1{enter}')
mainPage.getCell("Country", 10).rightclick({force: true})
cy.getActiveMenu().contains('Insert New Row').click({force: true})
mainPage.getCell("Country", 11).dblclick().find('input').type('Test Country-2{enter}')
// verify // verify
mainPage.getCell("Country", 10).contains("Test Country-1").should('exist') mainPage.getCell("Country", 10).contains("Test Country-1").should('exist')
@ -86,8 +89,8 @@ export const genTest = (type, xcdb) => {
mainPage.getRow(10).find('.mdi-checkbox-blank-outline').click({force: true}) mainPage.getRow(10).find('.mdi-checkbox-blank-outline').click({force: true})
mainPage.getRow(11).find('.mdi-checkbox-blank-outline').click({force: true}) mainPage.getRow(11).find('.mdi-checkbox-blank-outline').click({force: true})
mainPage.getCell("Country", 10).rightclick() mainPage.getCell("Country", 10).rightclick({force: true})
cy.getActiveMenu().contains('Delete Selected Row').click() cy.getActiveMenu().contains('Delete Selected Row').click({force: true})
// verify // verify
mainPage.getCell("Country", 10).should('not.exist') mainPage.getCell("Country", 10).should('not.exist')

4
scripts/cypress/plugins/index.js

@ -43,6 +43,10 @@ module.exports = (on, config) => {
}, },
'readXlsx': readXlsx.read, 'readXlsx': readXlsx.read,
'readSheetList': readXlsx.sheetList, 'readSheetList': readXlsx.sheetList,
log(message) {
console.log(message)
return null
}
}) })
} }

Loading…
Cancel
Save