feat: add tests for sorting column (#3519)
* feat: add tests for sorting column
This commit is contained in:
parent
f58054b337
commit
0b748bcc37
@ -1,9 +1,11 @@
|
||||
const foodMini = require('./food.mini.js')
|
||||
const foodSmall = require('./food.small.js')
|
||||
const foodSort = require('./food.sort.js')
|
||||
|
||||
const fixtures = {
|
||||
'food.mini': foodMini,
|
||||
'food.small': foodSmall,
|
||||
'food.sort': foodSort,
|
||||
}
|
||||
|
||||
export default fixtures
|
||||
|
3
main/tests/cypress/cypress/fixtures/food.sort.csv
Normal file
3
main/tests/cypress/cypress/fixtures/food.sort.csv
Normal file
@ -0,0 +1,3 @@
|
||||
NDB_No,Shrt_Desc,Water,Energ_Kcal,Date,Fat
|
||||
01001,"BUTTER,WITH SALT",15.87,717,17/12/2020,false
|
||||
01002,"BUTTER,WHIPPED,WITH SALT",15.87,717,17/08/2020,true
|
|
7
main/tests/cypress/cypress/fixtures/food.sort.js
Normal file
7
main/tests/cypress/cypress/fixtures/food.sort.js
Normal file
@ -0,0 +1,7 @@
|
||||
const fixture = [
|
||||
['NDB_No', 'Shrt_Desc', 'Water', 'Energ_Kcal', 'Date', 'Fat'],
|
||||
['01001', 'BUTTER,WITH SALT', '15.87', '717', '17/12/2020', 'false'],
|
||||
['01002', 'BUTTER,WHIPPED,WITH SALT', '15.87', '717', '17/08/2020', 'true'],
|
||||
]
|
||||
|
||||
export default fixture
|
@ -1,6 +1,6 @@
|
||||
describe(__filename, function () {
|
||||
it('Perform a basic sort', function () {
|
||||
cy.loadAndVisitProject('food.mini')
|
||||
it('Perform a text sort + Reverse + Remove', function () {
|
||||
cy.loadAndVisitProject('food.sort')
|
||||
|
||||
// sort and confirm
|
||||
cy.columnActionClick('Shrt_Desc', ['Sort'])
|
||||
@ -13,57 +13,103 @@ describe(__filename, function () {
|
||||
'BUTTER,WHIPPED,WITH SALT'
|
||||
)
|
||||
cy.getCell(1, 'Shrt_Desc').should('to.contain', 'BUTTER,WITH SALT')
|
||||
})
|
||||
|
||||
it('Perform a basic sort + Reverse', function () {
|
||||
cy.loadAndVisitProject('food.mini')
|
||||
|
||||
// sort and confirm
|
||||
cy.columnActionClick('Shrt_Desc', ['Sort'])
|
||||
cy.waitForDialogPanel()
|
||||
cy.confirmDialogPanel()
|
||||
|
||||
// check the sorting
|
||||
cy.getCell(0, 'Shrt_Desc').should(
|
||||
'to.contain',
|
||||
'BUTTER,WHIPPED,WITH SALT'
|
||||
)
|
||||
cy.getCell(1, 'Shrt_Desc').should('to.contain', 'BUTTER,WITH SALT')
|
||||
|
||||
// do a reverse sort
|
||||
|
||||
cy.columnActionClick('Shrt_Desc', ['Sort', 'Reverse'])
|
||||
|
||||
// re-check the sorting
|
||||
|
||||
cy.getCell(0, 'Shrt_Desc').should('to.contain', 'BUTTER,WITH SALT')
|
||||
cy.getCell(1, 'Shrt_Desc').should(
|
||||
'to.contain',
|
||||
'BUTTER,WHIPPED,WITH SALT'
|
||||
)
|
||||
})
|
||||
|
||||
it('Perform a basic sort + Remove Sort', function () {
|
||||
cy.loadAndVisitProject('food.mini')
|
||||
|
||||
// sort and confirm
|
||||
cy.columnActionClick('Shrt_Desc', ['Sort'])
|
||||
cy.waitForDialogPanel()
|
||||
cy.confirmDialogPanel()
|
||||
|
||||
// check the sorting
|
||||
cy.getCell(0, 'Shrt_Desc').should(
|
||||
'to.contain',
|
||||
'BUTTER,WHIPPED,WITH SALT'
|
||||
)
|
||||
cy.getCell(1, 'Shrt_Desc').should('to.contain', 'BUTTER,WITH SALT')
|
||||
|
||||
// remove
|
||||
cy.columnActionClick('Shrt_Desc', ['Sort', 'Remove sort'])
|
||||
|
||||
// re-check the sorting
|
||||
cy.getCell(0, 'Shrt_Desc').should('to.contain', 'BUTTER,WITH SALT')
|
||||
cy.getCell(1, 'Shrt_Desc').should(
|
||||
'to.contain',
|
||||
'BUTTER,WHIPPED,WITH SALT'
|
||||
)
|
||||
})
|
||||
it('Perform a number sort + Reverse + Remove', function () {
|
||||
cy.loadAndVisitProject('food.sort')
|
||||
|
||||
cy.castColumnTo('NDB_No','number')
|
||||
cy.columnActionClick('NDB_No', ['Sort'])
|
||||
|
||||
cy.waitForDialogPanel()
|
||||
cy.get('[type="radio"]').check('number')
|
||||
cy.get('[type="radio"]').check('reverse')
|
||||
cy.confirmDialogPanel()
|
||||
|
||||
// ensure sorting is active
|
||||
cy.getCell(0, 'NDB_No').should('to.contain', 1002)
|
||||
cy.getCell(1, 'NDB_No').should('to.contain', 1001)
|
||||
cy.columnActionClick('NDB_No', ['Sort', 'Reverse'])
|
||||
cy.getCell(0, 'NDB_No').should('to.contain', 1001)
|
||||
cy.getCell(1, 'NDB_No').should('to.contain', 1002)
|
||||
cy.columnActionClick('NDB_No', ['Sort', 'Remove sort'])
|
||||
cy.getCell(0, 'NDB_No').should('to.contain', 1001)
|
||||
cy.getCell(1, 'NDB_No').should('to.contain', 1002)
|
||||
})
|
||||
it('Perform a date sort + Reverse + Remove', function () {
|
||||
cy.loadAndVisitProject('food.sort')
|
||||
|
||||
cy.castColumnTo('Date','date')
|
||||
cy.columnActionClick('Date', ['Sort'])
|
||||
|
||||
cy.waitForDialogPanel()
|
||||
cy.get('[type="radio"]').check('date')
|
||||
cy.get('[type="radio"]').check('reverse')
|
||||
cy.confirmDialogPanel()
|
||||
|
||||
// ensure sorting is active
|
||||
cy.getCell(0, 'Date').should('to.contain', '2020-12-17T00:00:00Z')
|
||||
cy.getCell(1, 'Date').should('to.contain', '2020-08-17T00:00:00Z')
|
||||
|
||||
cy.columnActionClick('Date', ['Sort', 'Reverse'])
|
||||
|
||||
cy.getCell(0, 'Date').should('to.contain', '2020-08-17T00:00:00Z')
|
||||
cy.getCell(1, 'Date').should('to.contain', '2020-12-17T00:00:00Z')
|
||||
|
||||
cy.columnActionClick('Date', ['Sort', 'Remove sort'])
|
||||
cy.getCell(0, 'Date').should('to.contain', '2020-12-17T00:00:00Z')
|
||||
cy.getCell(1, 'Date').should('to.contain', '2020-08-17T00:00:00Z')
|
||||
|
||||
})
|
||||
it('Perform a bool sort + Reverse + Remove', function () {
|
||||
cy.loadAndVisitProject('food.sort')
|
||||
|
||||
cy.getCell(0, 'Fat')
|
||||
.trigger('mouseover')
|
||||
.within(() => {
|
||||
cy.get('a.data-table-cell-edit').click()
|
||||
})
|
||||
cy.get('select').select('boolean')
|
||||
cy.get('button').contains(new RegExp('Apply', 'g')).click()
|
||||
|
||||
cy.getCell(1, 'Fat')
|
||||
.trigger('mouseover')
|
||||
.within(() => {
|
||||
cy.get('a.data-table-cell-edit').click()
|
||||
})
|
||||
cy.get('select').select('boolean')
|
||||
cy.get('button').contains(new RegExp('Apply', 'g')).click()
|
||||
|
||||
cy.columnActionClick('Fat', ['Sort'])
|
||||
|
||||
cy.waitForDialogPanel()
|
||||
cy.get('[type="radio"]').check('boolean')
|
||||
cy.confirmDialogPanel()
|
||||
|
||||
cy.getCell(0, 'Fat').should('to.contain', 'false')
|
||||
cy.getCell(1, 'Fat').should('to.contain', 'true')
|
||||
|
||||
cy.columnActionClick('Fat', ['Sort', 'Reverse'])
|
||||
cy.getCell(0, 'Fat').should('to.contain', 'true')
|
||||
cy.getCell(1, 'Fat').should('to.contain', 'false')
|
||||
|
||||
cy.columnActionClick('Fat', ['Sort', 'Remove sort'])
|
||||
cy.getCell(0, 'Fat').should('to.contain', 'false')
|
||||
cy.getCell(1, 'Fat').should('to.contain', 'true')
|
||||
})
|
||||
})
|
||||
|
@ -0,0 +1,120 @@
|
||||
describe(__filename, function () {
|
||||
it('Ensure it reverses and reorders text sort', function () {
|
||||
cy.loadAndVisitProject('food.sort')
|
||||
|
||||
cy.columnActionClick('Shrt_Desc', ['Sort'])
|
||||
cy.waitForDialogPanel()
|
||||
cy.confirmDialogPanel()
|
||||
|
||||
cy.getCell(0, 'Shrt_Desc').should(
|
||||
'to.contain',
|
||||
'BUTTER,WHIPPED,WITH SALT'
|
||||
)
|
||||
cy.getCell(1, 'Shrt_Desc').should('to.contain', 'BUTTER,WITH SALT')
|
||||
cy.get('.viewpanel-sorting a').contains('Sort').click()
|
||||
cy.get('.menu-container').contains('By Shrt_Desc').trigger('mouseover')
|
||||
cy.get('.menu-item').contains('Reverse').click()
|
||||
cy.getCell(0, 'Shrt_Desc').should('to.contain', 'BUTTER,WITH SALT')
|
||||
cy.getCell(1, 'Shrt_Desc').should(
|
||||
'to.contain',
|
||||
'BUTTER,WHIPPED,WITH SALT'
|
||||
)
|
||||
cy.get('.viewpanel-sorting a').contains('Sort').click()
|
||||
cy.get('.menu-container').contains('Reorder rows permanently').click()
|
||||
cy.reload()
|
||||
cy.getCell(0, 'Shrt_Desc').should('to.contain', 'BUTTER,WITH SALT')
|
||||
cy.getCell(1, 'Shrt_Desc').should(
|
||||
'to.contain',
|
||||
'BUTTER,WHIPPED,WITH SALT'
|
||||
)
|
||||
})
|
||||
it('Ensure it reverses and reorders number sort', function () {
|
||||
cy.loadAndVisitProject('food.sort')
|
||||
|
||||
cy.castColumnTo('NDB_No','number')
|
||||
cy.columnActionClick('NDB_No', ['Sort'])
|
||||
|
||||
cy.waitForDialogPanel()
|
||||
cy.get('[type="radio"]').check('number')
|
||||
cy.get('[type="radio"]').check('reverse')
|
||||
cy.confirmDialogPanel()
|
||||
|
||||
cy.getCell(0, 'NDB_No').should('to.contain', 1002)
|
||||
cy.getCell(1, 'NDB_No').should('to.contain', 1001)
|
||||
|
||||
cy.get('.viewpanel-sorting a').contains('Sort').click()
|
||||
cy.get('.menu-container').contains('By NDB_No').trigger('mouseover')
|
||||
cy.get('.menu-item').contains('Reverse').click()
|
||||
cy.getCell(0, 'NDB_No').should('to.contain', 1001)
|
||||
cy.getCell(1, 'NDB_No').should('to.contain', 1002)
|
||||
cy.get('.viewpanel-sorting a').contains('Sort').click()
|
||||
cy.get('.menu-container').contains('Reorder rows permanently').click()
|
||||
cy.reload()
|
||||
cy.getCell(0, 'NDB_No').should('to.contain', 1001)
|
||||
cy.getCell(1, 'NDB_No').should('to.contain', 1002)
|
||||
})
|
||||
it('Ensure it reverses and reorders date sort', function () {
|
||||
cy.loadAndVisitProject('food.sort')
|
||||
|
||||
cy.castColumnTo('Date','date')
|
||||
cy.columnActionClick('Date', ['Sort'])
|
||||
|
||||
cy.waitForDialogPanel()
|
||||
cy.get('[type="radio"]').check('date')
|
||||
cy.get('[type="radio"]').check('reverse')
|
||||
cy.confirmDialogPanel()
|
||||
|
||||
cy.getCell(0, 'Date').should('to.contain', '2020-12-17T00:00:00Z')
|
||||
cy.getCell(1, 'Date').should('to.contain', '2020-08-17T00:00:00Z')
|
||||
|
||||
cy.get('.viewpanel-sorting a').contains('Sort').click()
|
||||
cy.get('.menu-container').contains('By Date').trigger('mouseover')
|
||||
cy.get('.menu-item').contains('Reverse').click()
|
||||
cy.getCell(0, 'Date').should('to.contain', '2020-08-17T00:00:00Z')
|
||||
cy.getCell(1, 'Date').should('to.contain', '2020-12-17T00:00:00Z')
|
||||
|
||||
cy.get('.viewpanel-sorting a').contains('Sort').click()
|
||||
cy.get('.menu-container').contains('Reorder rows permanently').click()
|
||||
cy.reload()
|
||||
cy.getCell(0, 'Date').should('to.contain', '2020-08-17T00:00:00Z')
|
||||
cy.getCell(1, 'Date').should('to.contain', '2020-12-17T00:00:00Z')
|
||||
})
|
||||
it('Ensure it reverses and reorders bool sort', function () {
|
||||
cy.loadAndVisitProject('food.sort')
|
||||
|
||||
cy.getCell(0, 'Fat')
|
||||
.trigger('mouseover')
|
||||
.within(() => {
|
||||
cy.get('a.data-table-cell-edit').click()
|
||||
})
|
||||
cy.get('select').select('boolean')
|
||||
cy.get('button').contains(new RegExp('Apply', 'g')).click()
|
||||
|
||||
cy.getCell(1, 'Fat')
|
||||
.trigger('mouseover')
|
||||
.within(() => {
|
||||
cy.get('a.data-table-cell-edit').click()
|
||||
})
|
||||
cy.get('select').select('boolean')
|
||||
cy.get('button').contains(new RegExp('Apply', 'g')).click()
|
||||
|
||||
cy.columnActionClick('Fat', ['Sort'])
|
||||
|
||||
cy.waitForDialogPanel()
|
||||
cy.get('[type="radio"]').check('boolean')
|
||||
cy.confirmDialogPanel()
|
||||
|
||||
cy.getCell(0, 'Fat').should('to.contain', 'false')
|
||||
cy.getCell(1, 'Fat').should('to.contain', 'true')
|
||||
cy.get('.viewpanel-sorting a').contains('Sort').click()
|
||||
cy.get('.menu-container').contains('By Fat').trigger('mouseover')
|
||||
cy.get('.menu-item').contains('Reverse').click()
|
||||
cy.getCell(0, 'Fat').should('to.contain', 'true')
|
||||
cy.getCell(1, 'Fat').should('to.contain', 'false')
|
||||
cy.get('.viewpanel-sorting a').contains('Sort').click()
|
||||
cy.get('.menu-container').contains('Reorder rows permanently').click()
|
||||
cy.reload()
|
||||
cy.getCell(0, 'Fat').should('to.contain', 'true')
|
||||
cy.getCell(1, 'Fat').should('to.contain', 'false')
|
||||
})
|
||||
})
|
@ -57,6 +57,18 @@ Cypress.Commands.add('doCreateProjectThroughUserInterface', () => {
|
||||
})
|
||||
})
|
||||
|
||||
Cypress.Commands.add('castColumnTo', (selector, target) => {
|
||||
cy.get(
|
||||
'.data-table th:contains("' + selector + '") .column-header-menu'
|
||||
).click()
|
||||
|
||||
const targetAction = 'To ' + target
|
||||
|
||||
cy.get('body > .menu-container').eq(0).contains('Edit cells').click()
|
||||
cy.get('body > .menu-container').eq(1).contains('Common transforms').click()
|
||||
cy.get('body > .menu-container').eq(2).contains(targetAction).click()
|
||||
})
|
||||
|
||||
Cypress.Commands.add('getCell', (rowIndex, columnName) => {
|
||||
const cssRowIndex = rowIndex + 1
|
||||
// first get the header, to know the cell index
|
||||
|
Loading…
Reference in New Issue
Block a user