Browse Source

[test] cypress: test suite for grid view verification

Signed-off-by: Raju Udava <sivadstala@gmail.com>
pull/671/head
Raju Udava 3 years ago
parent
commit
194d95da6c
  1. 266
      cypress/integration/common/4f_grid_view_share.js
  2. 4
      cypress/integration/test/masterSuite.js
  3. 61
      cypress/support/page_objects/mainPage.js

266
cypress/integration/common/4f_grid_view_share.js

@ -0,0 +1,266 @@
import { loginPage } from "../../support/page_objects/navigation"
import { isTestSuiteActive } from "../../support/page_objects/projectConstants"
import { mainPage } from "../../support/page_objects/mainPage"
let baseURL = ''
let viewURL = []
export const genTest = (type, xcdb) => {
if(!isTestSuiteActive(type, xcdb)) return;
describe(`${type.toUpperCase()} api - Table views`, () => {
const name = 'Test' + Date.now();
// Run once before test- create project (rest/graphql)
//
before(() => {
// loginPage.loginAndOpenProject(type)
// open a table to work on views
//
cy.openTableTab('Country');
})
beforeEach(() => {
cy.restoreLocalStorage();
})
afterEach(() => {
cy.saveLocalStorage();
})
after(() => {
// close table
cy.get('[href="#table||db||Country"]').find('button.mdi-close').click()
})
const generateViewLink = () => {
// click on share view
cy.get('.v-navigation-drawer__content > .container')
.find('.v-list > .v-list-item')
.contains('Share View')
.click()
// wait, as URL initially will be /undefined
cy.wait(500)
// copy link text, visit URL
cy.getActiveModal().find('.share-link-box')
.contains('/nc/view/', {timeout: 10000})
.then(($obj) => {
cy.get('body').type('{esc}')
viewURL.push($obj.text())
})
}
// Common routine to create/edit/delete GRID & GALLERY view
// Input: viewType - 'grid'/'gallery'
//
const viewTest = (viewType) => {
it(`Create ${viewType} view`, () => {
// create a normal public view
cy.get(`.nc-create-${viewType}-view`).click();
cy.getActiveModal().find('button:contains(Submit)').click()
cy.wait(1000)
// create view for fields verification
cy.get(`.nc-create-${viewType}-view`).click();
cy.getActiveModal().find('button:contains(Submit)').click()
cy.wait(1000)
// create view for Sort verification
cy.get(`.nc-create-${viewType}-view`).click();
cy.getActiveModal().find('button:contains(Submit)').click()
cy.wait(1000)
// create view for Filter verification
cy.get(`.nc-create-${viewType}-view`).click();
cy.getActiveModal().find('button:contains(Submit)').click()
cy.wait(1000)
// store base URL- to re-visit and delete form view later
cy.url().then((url) => {
baseURL = url
})
})
it(`Share ${viewType} view generate URL with all fields enabled`, () => {
cy.get(`.nc-view-item.nc-${viewType}-view-item`).contains('Country1').click()
generateViewLink()
cy.log(viewURL)
})
it(`Share ${viewType} view generate URL with a field hidden`, () => {
cy.get(`.nc-view-item.nc-${viewType}-view-item`).contains('Country2').click()
mainPage.hideUnhideField('LastUpdate')
generateViewLink()
})
it(`Share ${viewType} view generate URL with a field sorted`, () => {
cy.get(`.nc-view-item.nc-${viewType}-view-item`).contains('Country3').click()
mainPage.sortField('Country', 'Z -> A')
generateViewLink()
})
it(`Share ${viewType} view generate URL with a field filtered`, () => {
cy.get(`.nc-view-item.nc-${viewType}-view-item`).contains('Country4').click()
mainPage.filterField('Country', 'is equal', 'India')
generateViewLink()
})
it(`Share ${viewType} view : Access URL with a field hidden`, () => {
// visit public view
cy.visit(viewURL[1])
// wait for public view page to load!
cy.wait(5000)
// verify column headers
cy.get('[data-col="Country"]').should('exist')
cy.get('[data-col="LastUpdate"]').should('not.exist')
cy.get('[data-col="Country => City"]').should('exist')
// country column content verification before sort
mainPage.getCell("Country", 1).contains("Afghanistan").should('exist')
mainPage.getCell("Country", 2).contains("Algeria").should('exist')
mainPage.getCell("Country", 3).contains("American Samoa").should('exist')
})
it(`Share ${viewType} view : Access URL with a field sorted`, () => {
// visit public view
cy.visit(viewURL[2])
// wait for public view page to load!
cy.wait(5000)
// verify column headers
cy.get('[data-col="Country"]').should('exist')
cy.get('[data-col="LastUpdate"]').should('exist')
cy.get('[data-col="Country => City"]').should('exist')
// country column content verification before sort
mainPage.getCell("Country", 1).contains("Zambia").should('exist')
})
it(`Share ${viewType} view : Access URL with a field filtered`, () => {
// visit public view
cy.visit(viewURL[3])
// wait for public view page to load!
cy.wait(5000)
// verify column headers
cy.get('[data-col="Country"]').should('exist')
cy.get('[data-col="LastUpdate"]').should('exist')
cy.get('[data-col="Country => City"]').should('exist')
// country column content verification before sort
mainPage.getCell("Country", 1).contains("India").should('exist')
})
it(`Share ${viewType} view : Access URL with all fields enabled`, () => {
// visit public view
cy.visit(viewURL[0])
// wait for public view page to load!
cy.wait(5000)
// verify column headers
cy.get('[data-col="Country"]').should('exist')
cy.get('[data-col="LastUpdate"]').should('exist')
cy.get('[data-col="Country => City"]').should('exist')
// country column content verification before sort
mainPage.getCell("Country", 1).contains("Afghanistan").should('exist')
mainPage.getCell("Country", 2).contains("Algeria").should('exist')
mainPage.getCell("Country", 3).contains("American Samoa").should('exist')
})
it(`Share ${viewType} view : Enable sort`, () => {
// Sort menu operations (Country Column, Z->A)
mainPage.sortField('Country', 'Z -> A')
mainPage.getCell("Country", 1).contains("Zambia").should('exist')
})
it(`Share ${viewType} view : Disable sort`, () => {
// remove sort and validate
mainPage.clearSort()
mainPage.getCell("Country", 1).contains("Afghanistan").should('exist')
})
it(`Share ${viewType} view : Create Filter`, () => {
// add filter & validate
mainPage.filterField('Country', 'is equal', 'India')
cy.wait(1000)
mainPage.getCell("Country", 1).contains("India").should('exist')
})
it(`Share ${viewType} view : Delete Filter`, () => {
// Remove sort and Validate
mainPage.filterReset()
mainPage.getCell("Country", 1).contains("Afghanistan").should('exist')
})
it(`Delete ${viewType} view`, () => {
// go back to base page
cy.visit(baseURL)
// number of view entries should be 2 before we delete
cy.get('.nc-view-item').its('length').should('eq', 5)
// click on delete icon (becomes visible on hovering mouse)
cy.get('.nc-view-delete-icon').eq(3).click({ force: true })
cy.wait(1000)
cy.get('.nc-view-delete-icon').eq(2).click({ force: true })
cy.wait(1000)
cy.get('.nc-view-delete-icon').eq(1).click({ force: true })
cy.wait(1000)
cy.get('.nc-view-delete-icon').eq(0).click({ force: true })
cy.wait(1000)
// confirm if the number of veiw entries is reduced by 1
cy.get('.nc-view-item').its('length').should('eq', 1)
})
}
// below scenario's will be invoked twice, once for rest & then for graphql
viewTest('grid')
})
}
// invoke for different API types supported
//
// 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/>.
*
*/

4
cypress/integration/test/masterSuite.js

@ -1,4 +1,4 @@
// For single file tests-
// // For single file tests-
// let t0 = require('./explicitLogin')
// t0.genTest('rest', false)
@ -19,6 +19,7 @@ let t4a = require('../common/4a_table_view_grid_gallery_form')
let t4c = require('../common/4c_form_view_detailed')
let t4d = require('../common/4d_table_view_grid_locked')
let t4e = require('../common/4e_form_view_share')
let t4f = require('../common/4f_grid_view_share')
let t5a = require('../common/5a_user_role')
let t5b = require('../common/5b_preview_role')
let t6a = require('../common/6a_audit')
@ -42,6 +43,7 @@ const nocoTestSuite = (type, xcdb) => {
t4c.genTest(type, xcdb)
t4d.genTest(type, xcdb)
t4e.genTest(type, xcdb)
t4f.genTest(type, xcdb)
t5a.genTest(type, 'owner')
t5a.genTest(type, 'creator')

61
cypress/support/page_objects/mainPage.js

@ -76,15 +76,15 @@ export class _mainPage {
cy.get('button:contains("SIGN UP")').click()
cy.url({ timeout: 6000 }).should('contain', '#/project')
cy.wait(1000)
cy.wait(1000)
})
}
addExistingUserToProject = (emailId, role) => {
cy.get('.v-list-item:contains("Team & Auth")').click()
cy.get(`tr:contains(${emailId})`).find('.mdi-plus', {timeout: 2000}).click()
cy.get(`tr:contains(${emailId})`).find('.mdi-pencil-outline', {timeout: 2000}).click()
cy.get(`tr:contains(${emailId})`).find('.mdi-plus', { timeout: 2000 }).click()
cy.get(`tr:contains(${emailId})`).find('.mdi-pencil-outline', { timeout: 2000 }).click()
cy.get('label:contains(Select User roles)').click()
@ -94,8 +94,8 @@ export class _mainPage {
cy.getActiveMenu().contains(role).click()
cy.getActiveMenu().contains('editor').click()
cy.get('.mdi-menu-down').click()
cy.get('.nc-invite-or-save-btn').click()
cy.wait(1000)
cy.get('.nc-invite-or-save-btn').click()
cy.wait(1000)
}
getCell = (columnHeader, cellNumber) => {
@ -103,9 +103,9 @@ export class _mainPage {
}
getPagination = (pageNumber) => {
if(pageNumber == '<')
if (pageNumber == '<')
return cy.get('.nc-pagination .v-pagination > li:first-child')
if(pageNumber == '>')
if (pageNumber == '>')
return cy.get('.nc-pagination .v-pagination > li:last-child')
return cy.get(`.nc-pagination .v-pagination > li:contains(${pageNumber}) button`)
@ -116,9 +116,9 @@ export class _mainPage {
}
addColumn = (colName) => {
cy.get('.v-window-item--active .nc-grid tr > th:last button').click({force: true});
cy.get('.nc-column-name-input input', {timeout: 3000}).clear().type(colName)
cy.get('.nc-col-create-or-edit-card').contains('Save').click()
cy.get('.v-window-item--active .nc-grid tr > th:last button').click({ force: true });
cy.get('.nc-column-name-input input', { timeout: 3000 }).clear().type(colName)
cy.get('.nc-col-create-or-edit-card').contains('Save').click()
}
getAuthToken = () => {
@ -137,7 +137,7 @@ export class _mainPage {
cy.getActiveModal().find('[placeholder="eg: smtp.example.com"]').click().type(host)
cy.getActiveModal().find('[placeholder="Port"]').click().type(port)
cy.getActiveModal().find('[placeholder="Secure"]').click().type(secure)
cy.getActiveModal().find('button').contains('Save').click()
cy.getActiveModal().find('button').contains('Save').click()
}
resetSMTP = () => {
@ -147,7 +147,44 @@ export class _mainPage {
.find('button')
.contains(" Reset ")
.click({ force: true })
cy.getActiveModal().find('button').contains('Submit').click()
cy.getActiveModal().find('button').contains('Submit').click()
}
hideUnhideField = (field) => {
cy.get('.nc-fields-menu-btn').click()
cy.get(`.menuable__content__active .v-list-item label:contains(${field})`).click()
cy.get('.nc-fields-menu-btn').click()
}
sortField = (field, criteria) => {
cy.get('.nc-sort-menu-btn').click()
cy.contains('Add Sort Option').click();
cy.get('.nc-sort-field-select div').first().click()
cy.get(`.menuable__content__active .v-list-item:contains(${field})`).click()
cy.get('.nc-sort-dir-select div').first().click()
cy.get(`.menuable__content__active .v-list-item:contains(${criteria})`).click()
}
clearSort = () => {
cy.get('.nc-sort-item-remove-btn').click()
}
filterField = (field, operation, value) => {
cy.get('.nc-filter-menu-btn').click()
cy.contains('Add Filter').click();
cy.get('.nc-filter-field-select').last().click();
cy.getActiveMenu().find(`.v-list-item:contains(${field})`).click()
cy.get('.nc-filter-operation-select').last().click();
cy.getActiveMenu().find(`.v-list-item:contains(${operation})`).click()
cy.get('.nc-filter-value-select input:text').last().type(`${value}`);
cy.get('.nc-filter-menu-btn').click()
}
filterReset = () => {
cy.get('.nc-filter-menu-btn').click()
cy.get('.nc-filter-item-remove-btn').click()
cy.get('.nc-filter-menu-btn').click()
}
}

Loading…
Cancel
Save