Skip to content
This repository was archived by the owner on Jun 1, 2025. It is now read-only.

Commit 36f958d

Browse files
authored
feat(tests): add more Cypress E2E tests for Tree Data (#525)
1 parent 7084133 commit 36f958d

File tree

3 files changed

+103
-3
lines changed

3 files changed

+103
-3
lines changed

src/app/examples/grid-tree-data-parent-child.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ <h2 [innerHTML]="title"></h2>
88
<span class="icon mdi mdi-plus"></span>
99
<span>Add New Item (in 1st group)</span>
1010
</button>
11-
<button (click)="collapseAll()" class="btn btn-default btn-sm">
11+
<button (click)="collapseAll()" data-test="collapse-all" class="btn btn-default btn-sm">
1212
<span class="icon mdi mdi-arrow-collapse"></span>
1313
<span>Collapse All</span>
1414
</button>
15-
<button (click)="expandAll()" class="btn btn-default btn-sm">
15+
<button (click)="expandAll()" data-test="expand-all" class="btn btn-default btn-sm">
1616
<span class="icon mdi mdi-arrow-expand"></span>
1717
<span>Expand All</span>
1818
</button>
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
/// <reference types="cypress" />
2+
3+
describe('Example 28 - Tree Data (from a Hierarchical Dataset)', () => {
4+
const titles = ['Title', 'Duration', '% Complete', 'Start', 'Finish', 'Effort Driven'];
5+
6+
it('should display Example title', () => {
7+
cy.visit(`${Cypress.config('baseExampleUrl')}/tree-data-parent-child`);
8+
cy.get('h2').should('contain', 'Example 28: Tree Data (from a flat dataset with parentId references)');
9+
});
10+
11+
it('should have exact column titles in grid', () => {
12+
cy.get('#grid28')
13+
.find('.slick-header-columns')
14+
.children()
15+
.each(($child, index) => expect($child.text()).to.eq(titles[index]));
16+
});
17+
18+
it('should have a Grid Preset Filter on 3rd column "% Complete" and expect all rows to be filtered as well', () => {
19+
cy.get('.input-group-text.rangeOutput_percentComplete')
20+
.contains('25');
21+
22+
cy.get('.search-filter.filter-percentComplete')
23+
.find('.input-group-addon.operator select')
24+
.contains('>=');
25+
});
26+
27+
it('should collapsed all rows from "Collapse All" button', () => {
28+
cy.get('[data-test=collapse-all]')
29+
.contains('Collapse All')
30+
.click();
31+
32+
cy.get('#grid28')
33+
.find('.slick-group-toggle.expanded')
34+
.should('have.length', 0);
35+
36+
cy.get('#grid28')
37+
.find('.slick-group-toggle.collapsed')
38+
.should(($rows) => expect($rows).to.have.length.greaterThan(0));
39+
});
40+
41+
it('should expand all rows from "Expand All" button', () => {
42+
cy.get('[data-test=expand-all]')
43+
.contains('Expand All')
44+
.click();
45+
46+
cy.get('#grid28')
47+
.find('.slick-group-toggle.collapsed')
48+
.should('have.length', 0);
49+
50+
cy.get('#grid28')
51+
.find('.slick-group-toggle.expanded')
52+
.should(($rows) => expect($rows).to.have.length.greaterThan(0));
53+
});
54+
55+
it('should collapsed all rows from "Collapse All" context menu', () => {
56+
cy.get('#grid28')
57+
.contains('5 days');
58+
59+
cy.get('#grid28')
60+
.find('.slick-row .slick-cell:nth(1)')
61+
.rightclick({ force: true });
62+
63+
cy.get('.slick-context-menu.dropright .slick-context-menu-command-list')
64+
.find('.slick-context-menu-item')
65+
.find('.slick-context-menu-content')
66+
.contains('Collapse all Groups')
67+
.click();
68+
69+
cy.get('#grid28')
70+
.find('.slick-group-toggle.expanded')
71+
.should('have.length', 0);
72+
73+
cy.get('#grid28')
74+
.find('.slick-group-toggle.collapsed')
75+
.should(($rows) => expect($rows).to.have.length.greaterThan(0));
76+
});
77+
78+
it('should collapsed all rows from "Expand All" context menu', () => {
79+
cy.get('#grid28')
80+
.contains('5 days');
81+
82+
cy.get('#grid28')
83+
.find('.slick-row .slick-cell:nth(1)')
84+
.rightclick({ force: true });
85+
86+
cy.get('.slick-context-menu.dropright .slick-context-menu-command-list')
87+
.find('.slick-context-menu-item')
88+
.find('.slick-context-menu-content')
89+
.contains('Expand all Groups')
90+
.click();
91+
92+
cy.get('#grid28')
93+
.find('.slick-group-toggle.collapsed')
94+
.should('have.length', 0);
95+
96+
cy.get('#grid28')
97+
.find('.slick-group-toggle.expanded')
98+
.should(($rows) => expect($rows).to.have.length.greaterThan(0));
99+
});
100+
});

test/cypress/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"author": "Ghislain B.",
1212
"license": "MIT",
1313
"devDependencies": {
14-
"cypress": "^4.8.0",
14+
"cypress": "^4.10.0",
1515
"mocha": "^5.2.0",
1616
"mochawesome": "^3.1.2",
1717
"mochawesome-merge": "^1.0.7",

0 commit comments

Comments
 (0)