-
-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tests): add more Cypress E2E tests for grouping (#584)
* feat(tests): add more Cypress E2E tests for grouping
- Loading branch information
1 parent
18289d3
commit 90d47e6
Showing
7 changed files
with
204 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/// <reference types="cypress" /> | ||
|
||
describe('Example 14 - Grouping & Aggregators', () => { | ||
const fullTitles = ['#', 'Title', 'Duration', '% Complete', 'Start', 'Finish', 'Cost', 'Effort Driven']; | ||
const GRID_ROW_HEIGHT = 35; | ||
|
||
it('should display Example title', () => { | ||
cy.visit(`${Cypress.config('baseExampleUrl')}/grouping`); | ||
cy.get('h2').should('contain', 'Example 14: Grouping & Aggregators'); | ||
}); | ||
|
||
it('should have exact column titles on 1st grid', () => { | ||
cy.get('#grid14') | ||
.find('.slick-header-columns') | ||
.children() | ||
.each(($child, index) => expect($child.text()).to.eq(fullTitles[index])); | ||
}); | ||
|
||
describe('Grouping Tests', () => { | ||
it('should "Group by Duration & sort groups by value" then Collapse All and expect only group titles', () => { | ||
cy.get('[data-test="add-50k-rows-btn"]').click(); | ||
cy.get('[data-test="group-duration-sort-value-btn"]').click(); | ||
cy.get('[data-test="collapse-all-btn"]').click(); | ||
|
||
cy.get(`[style="top:${GRID_ROW_HEIGHT * 0}px"] > .slick-cell:nth(0) .slick-group-toggle.collapsed`).should('have.length', 1); | ||
cy.get(`[style="top:${GRID_ROW_HEIGHT * 0}px"] > .slick-cell:nth(0) .slick-group-title`).should('contain', 'Duration: 0'); | ||
|
||
cy.get(`[style="top:${GRID_ROW_HEIGHT * 1}px"] > .slick-cell:nth(0) .slick-group-title`).should('contain', 'Duration: 1'); | ||
cy.get(`[style="top:${GRID_ROW_HEIGHT * 2}px"] > .slick-cell:nth(0) .slick-group-title`).should('contain', 'Duration: 2'); | ||
cy.get(`[style="top:${GRID_ROW_HEIGHT * 3}px"] > .slick-cell:nth(0) .slick-group-title`).should('contain', 'Duration: 3'); | ||
cy.get(`[style="top:${GRID_ROW_HEIGHT * 4}px"] > .slick-cell:nth(0) .slick-group-title`).should('contain', 'Duration: 4'); | ||
}); | ||
|
||
it('should click on Expand All columns and expect 1st row as grouping title and 2nd row as a regular row', () => { | ||
cy.get('[data-test="add-50k-rows-btn"]').click(); | ||
cy.get('[data-test="group-duration-sort-value-btn"]').click(); | ||
cy.get('[data-test="expand-all-btn"]').click(); | ||
|
||
cy.get(`[style="top:${GRID_ROW_HEIGHT * 0}px"] > .slick-cell:nth(0) .slick-group-toggle.expanded`).should('have.length', 1); | ||
cy.get(`[style="top:${GRID_ROW_HEIGHT * 0}px"] > .slick-cell:nth(0) .slick-group-title`).should('contain', 'Duration: 0'); | ||
|
||
cy.get(`[style="top:${GRID_ROW_HEIGHT * 1}px"] > .slick-cell:nth(1)`).should('contain', 'Task'); | ||
cy.get(`[style="top:${GRID_ROW_HEIGHT * 1}px"] > .slick-cell:nth(2)`).should('contain', '0'); | ||
}); | ||
|
||
it('should "Group by Duration then Effort-Driven" and expect 1st row to be expanded, 2nd row to be collapsed and 3rd row to have group totals', () => { | ||
cy.get('[data-test="group-duration-effort-btn"]').click(); | ||
|
||
cy.get(`[style="top:${GRID_ROW_HEIGHT * 0}px"].slick-group-level-0 > .slick-cell:nth(0) .slick-group-toggle.expanded`).should('have.length', 1); | ||
cy.get(`[style="top:${GRID_ROW_HEIGHT * 0}px"].slick-group-level-0 > .slick-cell:nth(0) .slick-group-title`).should('contain', 'Duration: 0'); | ||
|
||
cy.get(`[style="top:${GRID_ROW_HEIGHT * 1}px"].slick-group-level-1 .slick-group-toggle.collapsed`).should('have.length', 1); | ||
cy.get(`[style="top:${GRID_ROW_HEIGHT * 1}px"].slick-group-level-1 .slick-group-title`).should('contain', 'Effort-Driven: False'); | ||
|
||
cy.get(`[style="top:${GRID_ROW_HEIGHT * 2}px"].slick-group-level-1 .slick-group-toggle.collapsed`).should('have.length', 1); | ||
cy.get(`[style="top:${GRID_ROW_HEIGHT * 2}px"].slick-group-level-1 .slick-group-title`).should('contain', 'Effort-Driven: True'); | ||
|
||
cy.get(`[style="top:${GRID_ROW_HEIGHT * 3}px"].slick-group-totals.slick-group-level-0 .slick-cell:nth(2)`).should('contain', 'Total: 0'); | ||
}); | ||
|
||
it('should "Group by Duration then Effort-Driven then Percent" and expect fist 2 rows to be expanded, 3rd row to be collapsed then 4th row to have group total', () => { | ||
cy.get('[data-test="group-duration-effort-percent-btn"]').click(); | ||
|
||
cy.get(`[style="top:${GRID_ROW_HEIGHT * 0}px"].slick-group-level-0 > .slick-cell:nth(0) .slick-group-toggle.expanded`).should('have.length', 1); | ||
cy.get(`[style="top:${GRID_ROW_HEIGHT * 0}px"].slick-group-level-0 > .slick-cell:nth(0) .slick-group-title`).should('contain', 'Duration: 0'); | ||
|
||
cy.get(`[style="top:${GRID_ROW_HEIGHT * 1}px"].slick-group-level-1 .slick-group-toggle.expanded`).should('have.length', 1); | ||
cy.get(`[style="top:${GRID_ROW_HEIGHT * 1}px"].slick-group-level-1 .slick-group-title`).should('contain', 'Effort-Driven: False'); | ||
|
||
cy.get(`[style="top:${GRID_ROW_HEIGHT * 2}px"].slick-group-level-2 .slick-group-toggle.collapsed`).should('have.length', 1); | ||
cy.get(`[style="top:${GRID_ROW_HEIGHT * 2}px"].slick-group-level-2 .slick-group-title`).contains(/^% Complete: [0-9]/); | ||
|
||
cy.get(`[style="top:${GRID_ROW_HEIGHT * 3}px"].slick-group-totals.slick-group-level-2 .slick-cell:nth(3)`).contains(/^Avg: [0-9]\%$/); | ||
cy.get(`[style="top:${GRID_ROW_HEIGHT * 3}px"].slick-group-totals.slick-group-level-2`) | ||
.find('.slick-cell:nth(3)').contains('Avg: '); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/// <reference types="cypress" /> | ||
|
||
describe('Example 19 - Draggable Grouping & Aggregators', () => { | ||
const fullTitles = ['Title', 'Duration', '% Complete', 'Start', 'Finish', 'Cost', 'Effort Driven']; | ||
const GRID_ROW_HEIGHT = 35; | ||
|
||
it('should display Example title', () => { | ||
cy.visit(`${Cypress.config('baseExampleUrl')}/draggrouping`); | ||
cy.get('h2').should('contain', 'Example 19: Draggable Grouping & Aggregators'); | ||
}); | ||
|
||
it('should have exact column titles on 1st grid', () => { | ||
cy.get('#grid19') | ||
.find('.slick-header-columns') | ||
.children() | ||
.each(($child, index) => expect($child.text()).to.eq(fullTitles[index])); | ||
}); | ||
|
||
describe('Grouping Tests', () => { | ||
it('should "Group by Duration & sort groups by value" then Collapse All and expect only group titles', () => { | ||
cy.get('[data-test="add-50k-rows-btn"]').click(); | ||
cy.get('[data-test="group-duration-sort-value-btn"]').click(); | ||
cy.get('[data-test="collapse-all-btn"]').click(); | ||
|
||
cy.get(`[style="top:${GRID_ROW_HEIGHT * 0}px"] > .slick-cell:nth(0) .slick-group-toggle.collapsed`).should('have.length', 1); | ||
cy.get(`[style="top:${GRID_ROW_HEIGHT * 0}px"] > .slick-cell:nth(0) .slick-group-title`).should('contain', 'Duration: 0'); | ||
|
||
cy.get(`[style="top:${GRID_ROW_HEIGHT * 1}px"] > .slick-cell:nth(0) .slick-group-title`).should('contain', 'Duration: 1'); | ||
cy.get(`[style="top:${GRID_ROW_HEIGHT * 2}px"] > .slick-cell:nth(0) .slick-group-title`).should('contain', 'Duration: 2'); | ||
cy.get(`[style="top:${GRID_ROW_HEIGHT * 3}px"] > .slick-cell:nth(0) .slick-group-title`).should('contain', 'Duration: 3'); | ||
cy.get(`[style="top:${GRID_ROW_HEIGHT * 4}px"] > .slick-cell:nth(0) .slick-group-title`).should('contain', 'Duration: 4'); | ||
}); | ||
|
||
it('should click on Expand All columns and expect 1st row as grouping title and 2nd row as a regular row', () => { | ||
cy.get('[data-test="add-50k-rows-btn"]').click(); | ||
cy.get('[data-test="group-duration-sort-value-btn"]').click(); | ||
cy.get('[data-test="expand-all-btn"]').click(); | ||
|
||
cy.get(`[style="top:${GRID_ROW_HEIGHT * 0}px"] > .slick-cell:nth(0) .slick-group-toggle.expanded`).should('have.length', 1); | ||
cy.get(`[style="top:${GRID_ROW_HEIGHT * 0}px"] > .slick-cell:nth(0) .slick-group-title`).should('contain', 'Duration: 0'); | ||
|
||
cy.get(`[style="top:${GRID_ROW_HEIGHT * 1}px"] > .slick-cell:nth(0)`).should('contain', 'Task'); | ||
cy.get(`[style="top:${GRID_ROW_HEIGHT * 1}px"] > .slick-cell:nth(1)`).should('contain', '0'); | ||
}); | ||
|
||
it('should show 1 column title (Duration) shown in the pre-header section', () => { | ||
cy.get('.slick-dropped-grouping:nth(0) div').contains('Duration'); | ||
}); | ||
|
||
it('should "Group by Duration then Effort-Driven" and expect 1st row to be expanded, 2nd row to be expanded and 3rd row to be a regular row', () => { | ||
cy.get('[data-test="group-duration-effort-btn"]').click(); | ||
|
||
cy.get(`[style="top:${GRID_ROW_HEIGHT * 0}px"].slick-group-level-0 > .slick-cell:nth(0) .slick-group-toggle.expanded`).should('have.length', 1); | ||
cy.get(`[style="top:${GRID_ROW_HEIGHT * 0}px"].slick-group-level-0 > .slick-cell:nth(0) .slick-group-title`).should('contain', 'Duration: 0'); | ||
|
||
cy.get(`[style="top:${GRID_ROW_HEIGHT * 1}px"].slick-group-level-1 .slick-group-toggle.expanded`).should('have.length', 1); | ||
cy.get(`[style="top:${GRID_ROW_HEIGHT * 1}px"].slick-group-level-1 .slick-group-title`).should('contain', 'Effort-Driven: False'); | ||
|
||
cy.get(`[style="top:${GRID_ROW_HEIGHT * 2}px"] > .slick-cell:nth(0)`).should('contain', 'Task'); | ||
cy.get(`[style="top:${GRID_ROW_HEIGHT * 2}px"] > .slick-cell:nth(1)`).should('contain', '0'); | ||
}); | ||
|
||
it('should show 2 column titles (Duration, Effort Driven) shown in the pre-header section', () => { | ||
cy.get('.slick-dropped-grouping:nth(0) div').contains('Duration'); | ||
cy.get('.slick-dropped-grouping:nth(1) div').contains('Effort Driven'); | ||
}); | ||
|
||
it('should be able to drag and swap grouped column titles inside the pre-header', () => { | ||
cy.get('.slick-dropped-grouping:nth(0) div') | ||
.contains('Duration') | ||
.trigger('mousedown', 'bottom', { which: 1 }); | ||
|
||
cy.get('.slick-dropped-grouping:nth(1) div') | ||
.contains('Effort Driven') | ||
.trigger('mousemove', 'bottomRight') | ||
.trigger('mouseup', 'bottomRight', { force: true }); | ||
}); | ||
|
||
it('should expect the grouping to be swapped as well in the grid', () => { | ||
cy.get(`[style="top:${GRID_ROW_HEIGHT * 0}px"].slick-group-level-0 > .slick-cell:nth(0) .slick-group-toggle.expanded`).should('have.length', 1); | ||
cy.get(`[style="top:${GRID_ROW_HEIGHT * 0}px"].slick-group-level-0 > .slick-cell:nth(0) .slick-group-title`).should('contain', 'Effort-Driven: False'); | ||
|
||
cy.get(`[style="top:${GRID_ROW_HEIGHT * 1}px"].slick-group-level-1 .slick-group-toggle.expanded`).should('have.length', 1); | ||
cy.get(`[style="top:${GRID_ROW_HEIGHT * 1}px"].slick-group-level-1 .slick-group-title`).should('contain', 'Duration: 0'); | ||
|
||
cy.get(`[style="top:${GRID_ROW_HEIGHT * 2}px"] > .slick-cell:nth(0)`).should('contain', 'Task'); | ||
cy.get(`[style="top:${GRID_ROW_HEIGHT * 2}px"] > .slick-cell:nth(1)`).should('contain', '0'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters