-
Notifications
You must be signed in to change notification settings - Fork 420
/
exampleGridMenu.spec.js
190 lines (155 loc) · 5.29 KB
/
exampleGridMenu.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
/// <reference types="Cypress" />
describe('Example - Grid Menu', () => {
const fullTitles = ['#', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J'];
it('should display Example Grid Menu', () => {
cy.visit(`${Cypress.config('baseExampleUrl')}/example-grid-menu.html`);
cy.get('h2').should('contain', 'Demonstrates:');
cy.contains('This example demonstrates using the Slick.Controls.GridMenu ');
});
it('should have exact Column Titles in the grid', () => {
cy.get('#myGrid')
.find('.slick-header-columns')
.children()
.each(($child, index) => expect($child.text()).to.eq(fullTitles[index]));
});
it('should click on the Grid Menu to hide the column "A"', () => {
const expectedTitleList = ['#', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J']; // without "A"
cy.get('#myGrid')
.find('button.slick-gridmenu-button')
.trigger('click')
.click();
cy.get('#myGrid')
.get('.slick-gridmenu:visible')
.find('.slick-gridmenu-list')
.children('li:visible:nth(0)')
.children('label')
.should('contain', 'A')
.click();
cy.get('#myGrid')
.get('.slick-gridmenu:visible')
.find('span.close')
.trigger('click')
.click();
cy.get('#myGrid')
.find('.slick-header-columns')
.children()
.each(($child, index) => expect($child.text()).to.eq(expectedTitleList[index]));
});
it('should click on the External Grid Menu to show the column "A" as 1st column again', () => {
cy.get('button')
.contains('Grid Menu')
.trigger('click')
.click();
cy.get('#myGrid')
.get('.slick-gridmenu:visible')
.find('.slick-gridmenu-list')
.children('li:visible:nth(0)')
.children('label')
.should('contain', 'A')
.click();
cy.get('[data-dismiss=slick-gridmenu]')
.click({ force: true });
cy.get('#myGrid')
.find('.slick-header-columns')
.children()
.each(($child, index) => expect($child.text()).to.eq(fullTitles[index]));
});
it('should click on "Help" and expect an Alert to show the Help text', () => {
cy.on('window:alert', (str) => {
expect(str).to.equal(`Command: help`);
});
cy.get('.slick-gridmenu-item')
.contains('Help')
.click();
});
it('should toggle Filter Row and expect the row to be hidden', () => {
cy.get('.slick-gridmenu-item')
.contains('Toggle Filter Row')
.click();
cy.get('#myGrid')
.find('.slick-pane-left')
.find('.slick-headerrow')
.should('be.hidden');
});
it('should toggle Filter Row and expect the row to be shown again', () => {
cy.get('.slick-gridmenu-item')
.contains('Toggle Filter Row')
.click();
cy.get('#myGrid')
.find('.slick-pane-left')
.find('.slick-headerrow')
.should('be.visible');
});
it('should toggle Top Panel and expect the row to show up', () => {
cy.get('.slick-gridmenu-item')
.contains('Toggle Top Panel')
.click();
cy.get('#myGrid')
.find('.slick-pane-left')
.find('.slick-top-panel-scroller')
.should('be.visible');
});
it('should toggle Top Panel and expect the row to be hide', () => {
cy.get('.slick-gridmenu-item')
.contains('Toggle Top Panel')
.click();
cy.get('#myGrid')
.find('.slick-pane-left')
.find('.slick-top-panel-scroller')
.should('be.hidden');
});
it('should filter column "#" with value 9 and expect only 1 row in the grid with value 9', () => {
cy.get('.grid-canvas')
.find('.slick-row')
.should('be.visible');
cy.get('#myGrid')
.find('.slick-headerrow-column.l0.r0')
.find('input')
.type('9');
cy.get('#myGrid')
.find('.slick-row')
.should('have.length', 1);
});
it('should open the Grid Menu and click on Clear Filter and expect multiple rows now showing in the grid', () => {
cy.get('#myGrid')
.find('button.slick-gridmenu-button')
.trigger('click')
.click();
cy.get('.slick-gridmenu-item')
.contains('Clear Filters')
.click();
cy.get('.grid-canvas')
.find('.slick-row')
.should('be.visible');
cy.get('#myGrid')
.find('.slick-row')
.its('length')
.should('be.gt', 1)
cy.get('#myGrid')
.get('.slick-gridmenu:visible')
.find('span.close')
.trigger('click')
.click();
});
it('should drag column "A" to be after column "C" and expect this to be reflected in the Grid Menu', () => {
const expectedGridMenuList = ['B', 'C', 'A', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'Force fit columns', 'Synchronous resize']; // without "A"
cy.get('.slick-header-columns')
.children('.slick-header-column:nth(1)')
.should('contain', 'A')
.trigger('mousedown', 'bottom', { which: 1 });
cy.get('.slick-header-columns')
.children('.slick-header-column:nth(3)')
.should('contain', 'C')
.trigger('mousemove', 'bottomRight')
.trigger('mouseup', 'bottomRight', { force: true });
cy.get('button')
.contains('Grid Menu')
.trigger('click')
.click();
cy.get('#myGrid')
.get('.slick-gridmenu:visible')
.find('.slick-gridmenu-list')
.children('li:visible')
.each(($child, index) => expect($child.text()).to.eq(expectedGridMenuList[index]));
});
});