From 182f70729d588baa30400557c264246cead127ca Mon Sep 17 00:00:00 2001 From: Kush Trivedi <44091822+kushthedude@users.noreply.github.com> Date: Mon, 12 Apr 2021 01:11:05 +0530 Subject: [PATCH] feat: add tests for special column All (#3769) * feat: add tests for special column All --- .../project/grid/all-column/.gitkeep | 0 .../grid/all-column/edit-columns.spec.js | 72 +++++++++++++++ .../project/grid/all-column/edit-rows.spec.js | 87 +++++++++++++++++++ .../project/grid/all-column/star.spec.js | 2 +- .../project/grid/all-column/view.spec.js | 31 +++++++ .../project/grid/column/edit-cells/.gitkeep | 0 .../column/edit-column/join_columns.spec.js | 4 +- .../tests/cypress/cypress/support/commands.js | 4 +- 8 files changed, 196 insertions(+), 4 deletions(-) delete mode 100644 main/tests/cypress/cypress/integration/project/grid/all-column/.gitkeep create mode 100644 main/tests/cypress/cypress/integration/project/grid/all-column/edit-columns.spec.js create mode 100644 main/tests/cypress/cypress/integration/project/grid/all-column/edit-rows.spec.js create mode 100644 main/tests/cypress/cypress/integration/project/grid/all-column/view.spec.js delete mode 100644 main/tests/cypress/cypress/integration/project/grid/column/edit-cells/.gitkeep diff --git a/main/tests/cypress/cypress/integration/project/grid/all-column/.gitkeep b/main/tests/cypress/cypress/integration/project/grid/all-column/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/main/tests/cypress/cypress/integration/project/grid/all-column/edit-columns.spec.js b/main/tests/cypress/cypress/integration/project/grid/all-column/edit-columns.spec.js new file mode 100644 index 000000000..41a313014 --- /dev/null +++ b/main/tests/cypress/cypress/integration/project/grid/all-column/edit-columns.spec.js @@ -0,0 +1,72 @@ +describe(__filename, function () { + it('Ensure columns are reordered as per order', function () { + cy.loadAndVisitProject('food.mini'); + cy.columnActionClick('All', [ + 'Edit columns', + 'Re-order / remove columns...', + ]); + cy.waitForDialogPanel(); + + cy.dragAndDrop('div[column="Shrt_Desc"]', 'div[column="NDB_No"]'); + cy.dragAndDrop('div[column="Energ_Kcal"]', 'div[column="Water"]'); + + cy.confirmDialogPanel(); + + cy.assertNotificationContainingText('Reorder columns'); + + cy.assertGridEquals([ + ['Shrt_Desc', 'NDB_No', 'Energ_Kcal', 'Water'], + ['BUTTER,WITH SALT', '01001', '717', '15.87'], + ['BUTTER,WHIPPED,WITH SALT', '01002', '717', '15.87'], + ]); + }); + it('Ensure columns are removed using remove column', function () { + cy.loadAndVisitProject('food.mini'); + cy.columnActionClick('All', [ + 'Edit columns', + 'Re-order / remove columns...', + ]); + cy.waitForDialogPanel(); + + cy.dragAndDrop('div[column="Shrt_Desc"]', 'div[bind="trashContainer"]'); + cy.dragAndDrop('div[column="Water"]', 'div[bind="trashContainer"]'); + + cy.confirmDialogPanel(); + + cy.assertNotificationContainingText('Reorder columns'); + + cy.assertGridEquals([ + ['NDB_No', 'Energ_Kcal'], + ['01001', '717'], + ['01002', '717'], + ]); + }); + it('Ensure columns are blanked down', function () { + cy.loadAndVisitProject('food.mini'); + cy.columnActionClick('All', ['Edit columns', 'Blank down']); + + cy.assertGridEquals([ + ['NDB_No', 'Shrt_Desc', 'Water', 'Energ_Kcal'], + ['01001', 'BUTTER,WITH SALT', '15.87', '717'], + ['01002', 'BUTTER,WHIPPED,WITH SALT', '', ''], + ]); + }); + it('Ensure columns are filled down', function () { + cy.loadAndVisitProject('food.mini'); + cy.columnActionClick('All', ['Edit columns', 'Blank down']); + + cy.assertGridEquals([ + ['NDB_No', 'Shrt_Desc', 'Water', 'Energ_Kcal'], + ['01001', 'BUTTER,WITH SALT', '15.87', '717'], + ['01002', 'BUTTER,WHIPPED,WITH SALT', '', ''], + ]); + + cy.columnActionClick('All', ['Edit columns', 'Fill down']); + + cy.assertGridEquals([ + ['NDB_No', 'Shrt_Desc', 'Water', 'Energ_Kcal'], + ['01001', 'BUTTER,WITH SALT', '15.87', '717'], + ['01002', 'BUTTER,WHIPPED,WITH SALT', '15.87', '717'], + ]); + }); +}); diff --git a/main/tests/cypress/cypress/integration/project/grid/all-column/edit-rows.spec.js b/main/tests/cypress/cypress/integration/project/grid/all-column/edit-rows.spec.js new file mode 100644 index 000000000..49f3414ba --- /dev/null +++ b/main/tests/cypress/cypress/integration/project/grid/all-column/edit-rows.spec.js @@ -0,0 +1,87 @@ +describe(__filename, function () { + it('Ensure all rows are starred', function () { + cy.loadAndVisitProject('food.mini'); + cy.columnActionClick('All', ['Edit rows', 'Star rows']); + cy.assertNotificationContainingText('Star 2 rows'); + + cy.get('.data-table tr:nth-child(1) td:nth-child(1) a').should( + 'have.class', + 'data-table-star-on' + ); + cy.get('.data-table tr:nth-child(2) td:nth-child(1) a').should( + 'have.class', + 'data-table-star-on' + ); + }); + it('Ensure all rows are unstarred', function () { + cy.loadAndVisitProject('food.mini'); + cy.columnActionClick('All', ['Edit rows', 'Star rows']); + cy.assertNotificationContainingText('Star 2 rows'); + + cy.get('.data-table tr:nth-child(1) td:nth-child(1) a').should( + 'have.class', + 'data-table-star-on' + ); + cy.get('.data-table tr:nth-child(2) td:nth-child(1) a').should( + 'have.class', + 'data-table-star-on' + ); + cy.columnActionClick('All', ['Edit rows', 'Unstar rows']); + cy.assertNotificationContainingText('Unstar 2 rows'); + + cy.get('.data-table tr:nth-child(1) td:nth-child(1) a').should( + 'have.class', + 'data-table-star-off' + ); + cy.get('.data-table tr:nth-child(2) td:nth-child(1) a').should( + 'have.class', + 'data-table-star-off' + ); + }); + it('Ensure all rows are flagged', function () { + cy.loadAndVisitProject('food.mini'); + cy.columnActionClick('All', ['Edit rows', 'Flag rows']); + cy.assertNotificationContainingText('Flag 2 rows'); + + cy.get('.data-table tr:nth-child(1) td:nth-child(2) a').should( + 'have.class', + 'data-table-flag-on' + ); + cy.get('.data-table tr:nth-child(2) td:nth-child(2) a').should( + 'have.class', + 'data-table-flag-on' + ); + }); + it('Ensure all rows are unflagged', function () { + cy.loadAndVisitProject('food.mini'); + cy.columnActionClick('All', ['Edit rows', 'Flag rows']); + cy.assertNotificationContainingText('Flag 2 rows'); + + cy.get('.data-table tr:nth-child(1) td:nth-child(2) a').should( + 'have.class', + 'data-table-flag-on' + ); + cy.get('.data-table tr:nth-child(2) td:nth-child(2) a').should( + 'have.class', + 'data-table-flag-on' + ); + cy.columnActionClick('All', ['Edit rows', 'Unflag rows']); + cy.assertNotificationContainingText('Unflag 2 rows'); + + cy.get('.data-table tr:nth-child(1) td:nth-child(2) a').should( + 'have.class', + 'data-table-flag-off' + ); + cy.get('.data-table tr:nth-child(2) td:nth-child(2) a').should( + 'have.class', + 'data-table-flag-off' + ); + }); + it('Ensure it removes matching rows', function () { + cy.loadAndVisitProject('food.mini'); + cy.columnActionClick('All', ['Edit rows', 'Remove matching rows']); + cy.assertNotificationContainingText('Remove 2 rows'); + + cy.assertGridEquals([['NDB_No', 'Shrt_Desc', 'Water', 'Energ_Kcal']]); + }); +}); diff --git a/main/tests/cypress/cypress/integration/project/grid/all-column/star.spec.js b/main/tests/cypress/cypress/integration/project/grid/all-column/star.spec.js index 99a9bdf09..aa5e2068b 100644 --- a/main/tests/cypress/cypress/integration/project/grid/all-column/star.spec.js +++ b/main/tests/cypress/cypress/integration/project/grid/all-column/star.spec.js @@ -1,5 +1,5 @@ describe(__filename, function () { - it('Ensure flag is visible and toggle on/off', function () { + it('Ensure star is visible and toggle on/off', function () { cy.loadAndVisitProject('food.mini'); cy.get('.data-table tr:nth-child(1) td:nth-child(1) a') .should('have.class', 'data-table-star-off') diff --git a/main/tests/cypress/cypress/integration/project/grid/all-column/view.spec.js b/main/tests/cypress/cypress/integration/project/grid/all-column/view.spec.js new file mode 100644 index 000000000..0ca62d5b5 --- /dev/null +++ b/main/tests/cypress/cypress/integration/project/grid/all-column/view.spec.js @@ -0,0 +1,31 @@ +describe(__filename, function () { + it('it collapses all columns', function () { + cy.loadAndVisitProject('food.mini'); + cy.columnActionClick('All', ['View', 'Collapse all columns']); + + cy.get('.odd td:nth-child(4)').should('to.contain', ''); + cy.get('.odd td:nth-child(5)').should('to.contain', ''); + cy.get('.odd td:nth-child(6)').should('to.contain', ''); + cy.get('.odd td:nth-child(7)').should('to.contain', ''); + + cy.get('.even td:nth-child(4)').should('to.contain', ''); + cy.get('.even td:nth-child(5)').should('to.contain', ''); + cy.get('.even td:nth-child(6)').should('to.contain', ''); + cy.get('.even td:nth-child(7)').should('to.contain', ''); + }); + it('it expands all columns', function () { + cy.loadAndVisitProject('food.mini'); + cy.columnActionClick('All', ['View', 'Collapse all columns']); + + cy.get('.odd td:nth-child(4)').should('to.contain', ''); + cy.get('.even td:nth-child(7)').should('to.contain', ''); + + cy.columnActionClick('All', ['View', 'Expand all columns']); + + cy.assertGridEquals([ + ['NDB_No', 'Shrt_Desc', 'Water', 'Energ_Kcal'], + ['01001', 'BUTTER,WITH SALT', '15.87', '717'], + ['01002', 'BUTTER,WHIPPED,WITH SALT', '15.87', '717'], + ]); + }); +}); diff --git a/main/tests/cypress/cypress/integration/project/grid/column/edit-cells/.gitkeep b/main/tests/cypress/cypress/integration/project/grid/column/edit-cells/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/main/tests/cypress/cypress/integration/project/grid/column/edit-column/join_columns.spec.js b/main/tests/cypress/cypress/integration/project/grid/column/edit-column/join_columns.spec.js index fd69b820b..994e3a996 100644 --- a/main/tests/cypress/cypress/integration/project/grid/column/edit-column/join_columns.spec.js +++ b/main/tests/cypress/cypress/integration/project/grid/column/edit-column/join_columns.spec.js @@ -19,7 +19,7 @@ describe(__filename, function () { cy.waitForDialogPanel(); cy.get('input[column="NDB_No"]').check(); - cy.dragAndDrop('div[column="NDB_No', 'div[column="Shrt_Desc"]'); + cy.dragAndDrop('div[column="NDB_No"]', 'div[column="Shrt_Desc"]'); cy.confirmDialogPanel(); @@ -46,7 +46,7 @@ describe(__filename, function () { cy.columnActionClick('Shrt_Desc', ['Edit column', 'Join columns...']); cy.waitForDialogPanel(); - cy.dragAndDrop('div[column="NDB_No', 'div[column="Shrt_Desc"]'); + cy.dragAndDrop('div[column="NDB_No"]', 'div[column="Shrt_Desc"]'); cy.get('input[column="NDB_No"]').check(); cy.get('input[bind="field_separatorInput"]').type(':-:'); diff --git a/main/tests/cypress/cypress/support/commands.js b/main/tests/cypress/cypress/support/commands.js index 1fc084b73..1c66736fa 100644 --- a/main/tests/cypress/cypress/support/commands.js +++ b/main/tests/cypress/cypress/support/commands.js @@ -322,7 +322,9 @@ Cypress.Commands.add( Cypress.Commands.add('dragAndDrop', (sourceSelector, targetSelector) => { cy.get(sourceSelector).trigger('mousedown', { which: 1 }); - cy.get(targetSelector).trigger('mousemove').trigger('mouseup'); + cy.get(targetSelector) + .trigger('mousemove') + .trigger('mouseup', { force: true }); }); Cypress.Commands.add(