cypress-ag-grid 1.2.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.circleci/config.yml +14 -0
- package/README.md +311 -276
- package/ag-grid-example-filter-text-floating-multi-condition.png +0 -0
- package/app/grid.js +70 -70
- package/app/index.html +12 -12
- package/cypress/{integration/ag-grid-spec.js → e2e/ag-grid.cy.js} +487 -449
- package/cypress/fixtures/cardata.json +21 -21
- package/cypress/plugins/index.js +22 -22
- package/cypress/support/commands.js +25 -25
- package/cypress/support/{index.js → e2e.js} +21 -21
- package/cypress.config.js +11 -0
- package/package.json +29 -29
- package/src/agGrid/agGridInteractions.js +465 -448
- package/src/agGrid/agGridValidations.js +37 -37
- package/src/agGrid/filterOperator.enum.js +13 -13
- package/src/agGrid/menuTab.enum.js +6 -6
- package/src/agGrid/sort.enum.js +5 -5
- package/src/index.js +17 -17
- package/cypress.json +0 -1
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Use the latest 2.1 version of CircleCI pipeline process engine.
|
|
2
|
+
# See: https://circleci.com/docs/2.0/configuration-reference
|
|
3
|
+
version: 2.1
|
|
4
|
+
|
|
5
|
+
orbs:
|
|
6
|
+
# "cypress-io/cypress@1" installs the latest published
|
|
7
|
+
# version "1.x.y" of the orb. We recommend you then use
|
|
8
|
+
# the strict explicit version "cypress-io/cypress@1.x.y"
|
|
9
|
+
# to lock the version and prevent unexpected CI changes
|
|
10
|
+
cypress: cypress-io/cypress@2.0.0
|
|
11
|
+
workflows:
|
|
12
|
+
run_cypress_tests:
|
|
13
|
+
jobs:
|
|
14
|
+
- cypress/run # "run" job comes from "cypress" orb
|
package/README.md
CHANGED
|
@@ -1,276 +1,311 @@
|
|
|
1
|
-
# cypress-ag-grid
|
|
2
|
-
Cypress plugin for interacting with and validating against ag grid.
|
|
3
|
-
|
|
4
|
-
## Table of Contents
|
|
5
|
-
* [Installation](#installation)
|
|
6
|
-
* [Usage](#usage)
|
|
7
|
-
+ [Grid Interaction](#)
|
|
8
|
-
- [Getting Data From the Grid](#getting-data-from-the-grid
|
|
9
|
-
- [Getting Select Row Data](#getting-select-row-data)
|
|
10
|
-
- [Sorting Columns](#sorting-columns)
|
|
11
|
-
- [Filter by Text - Column Menu](#filter-by-text---column-menu)
|
|
12
|
-
- [Filterby Text - Floating Filter](#filterby-text---floating-filter)
|
|
13
|
-
- [Filter by Checkbox - Column Menu](#filter-by-checkbox---column-menu)
|
|
14
|
-
- [Add or Remove Columns](#add-or-remove-columns)
|
|
15
|
-
+ [Grid Validation](#)
|
|
16
|
-
- [Validate Paginated Table](#validate-paginated-table)
|
|
17
|
-
- [Validate Table in the Exact Order](#validate-table-in-the-exact-order)
|
|
18
|
-
- [Validate Subset of Table Data](#validate-subset-of-table-data)
|
|
19
|
-
- [Validate Empty Grid](#validate-empty-grid)
|
|
20
|
-
* [Limitations](#limitations)
|
|
21
|
-
* [Credit](#credit)
|
|
22
|
-
<br/>
|
|
23
|
-
<br/>
|
|
24
|
-
|
|
25
|
-
## Installation
|
|
26
|
-
|
|
27
|
-
```bash
|
|
28
|
-
npm install cypress-ag-grid --save-dev
|
|
29
|
-
```
|
|
30
|
-
Then include the following in your support/index.js file:
|
|
31
|
-
|
|
32
|
-
```javascript
|
|
33
|
-
import "cypress-ag-grid";
|
|
34
|
-
```
|
|
35
|
-
## Usage
|
|
36
|
-
Consider the ag grid example below:
|
|
37
|
-

|
|
38
|
-
|
|
39
|
-
With the following DOM structure:
|
|
40
|
-

|
|
41
|
-
<br/>
|
|
42
|
-
<br/>
|
|
43
|
-
### Getting Data From the Grid:
|
|
44
|
-
To get the Ag Grid data, you must chain `.getAgGridData()` after the `cy.get()` command for the topmost level of the grid, including controls and headers (see selected DOM element in above image).
|
|
45
|
-
|
|
46
|
-
Correct Usage:
|
|
47
|
-
```javascript
|
|
48
|
-
cy.get("#myGrid").getAgGridData()
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
Incorrect Usage:
|
|
52
|
-
```javascript
|
|
53
|
-
cy.getAgGridData();
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
The correct command will return the following:
|
|
57
|
-
```json
|
|
58
|
-
[
|
|
59
|
-
{ "Year": "2020", "Make": "Toyota", "Model": "Celica" },
|
|
60
|
-
{ "Year": "2020", "Make": "Ford", "Model": "Mondeo" },
|
|
61
|
-
{ "Year": "2020", "Make": "Porsche", "Model": "Boxter" },
|
|
62
|
-
{ "Year": "2020", "Make": "BMW", "Model": "3-series" },
|
|
63
|
-
{ "Year": "2020", "Make": "Mercedes", "Model": "GLC300" },
|
|
64
|
-
]
|
|
65
|
-
```
|
|
66
|
-
</br>
|
|
67
|
-
</br>
|
|
68
|
-
|
|
69
|
-
### Getting Select Row Data
|
|
70
|
-
To only get certain rows of data, pass the header values into the `getAgGridData()` command, like so:
|
|
71
|
-
|
|
72
|
-
```javascript
|
|
73
|
-
cy.get("#myGrid).getAgGridData({ onlyColumns: ["Year", "Make"] })
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
The above command will return the follwoing:
|
|
77
|
-
```json
|
|
78
|
-
[
|
|
79
|
-
{ "Year": "2020", "Make": "Toyota"},
|
|
80
|
-
{ "Year": "2020", "Make": "Ford"},
|
|
81
|
-
{ "Year": "2020", "Make": "Porsche"},
|
|
82
|
-
{ "Year": "2020", "Make": "BMW"},
|
|
83
|
-
{ "Year": "2020", "Make": "Mercedes"},
|
|
84
|
-
]
|
|
85
|
-
```
|
|
86
|
-
</br>
|
|
87
|
-
</br>
|
|
88
|
-
|
|
89
|
-
### Sorting Columns
|
|
90
|
-
This command will sort the specified column by the sort direction specified.
|
|
91
|
-
|
|
92
|
-
<b>Defintion</b>:
|
|
93
|
-
`.agGridSortColumn(columnName:String, sortDirection:String)`
|
|
94
|
-
|
|
95
|
-
Example:
|
|
96
|
-
|
|
97
|
-
```javascript
|
|
98
|
-
cy.get("#myGrid").agGridSortColumn("Model", "descending");
|
|
99
|
-
```
|
|
100
|
-
</br>
|
|
101
|
-
</br>
|
|
102
|
-
|
|
103
|
-
### Filter by Text - Column Menu
|
|
104
|
-
This command will filter a column by a text value from its menu. In the options, you must specify a `searchCriteria` objects containing one or more objects with `columnName`, `filterValue`, and optionally `operator` (i.e. Contains, Not contains, Equals, etc.).
|
|
105
|
-
|
|
106
|
-

|
|
107
|
-
|
|
108
|
-
<b>Definition:</b> `.agGridColumnFilterTextMenu(options: {})`
|
|
109
|
-
|
|
110
|
-
Example:
|
|
111
|
-
```javascript
|
|
112
|
-
cy.get("#myGrid").agGridColumnFilterTextMenu({
|
|
113
|
-
searchCriteria:[{
|
|
114
|
-
columnName: "Model",
|
|
115
|
-
filterValue: "GLC300",
|
|
116
|
-
operator:"Equals"
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
columnName: "Make",
|
|
120
|
-
filterValue: "Mercedes",
|
|
121
|
-
operator:"Equals"
|
|
122
|
-
}
|
|
123
|
-
],
|
|
124
|
-
hasApplyButton: false
|
|
125
|
-
})
|
|
126
|
-
````
|
|
127
|
-
The above command will filter the Model column for the value 'GLC300' and set the filter operator to 'Equals'. It will then apply a secondary filter on the Make column for 'Mercedes'.
|
|
128
|
-
</br>
|
|
129
|
-
</br>
|
|
130
|
-
### Filterby Text - Floating Filter
|
|
131
|
-
This command will filter a column by a text value from its floating filter (if applicable).
|
|
132
|
-
|
|
133
|
-

|
|
134
|
-
|
|
135
|
-
<b>Definition:</b> .
|
|
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
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
{
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
<
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
1
|
+
# cypress-ag-grid
|
|
2
|
+
Cypress plugin for interacting with and validating against ag grid.
|
|
3
|
+
|
|
4
|
+
## Table of Contents
|
|
5
|
+
* [Installation](#installation)
|
|
6
|
+
* [Usage](#usage)
|
|
7
|
+
+ [Grid Interaction](#)
|
|
8
|
+
- [Getting Data From the Grid](#getting-data-from-the-grid)
|
|
9
|
+
- [Getting Select Row Data](#getting-select-row-data)
|
|
10
|
+
- [Sorting Columns](#sorting-columns)
|
|
11
|
+
- [Filter by Text - Column Menu](#filter-by-text---column-menu)
|
|
12
|
+
- [Filterby Text - Floating Filter](#filterby-text---floating-filter)
|
|
13
|
+
- [Filter by Checkbox - Column Menu](#filter-by-checkbox---column-menu)
|
|
14
|
+
- [Add or Remove Columns](#add-or-remove-columns)
|
|
15
|
+
+ [Grid Validation](#)
|
|
16
|
+
- [Validate Paginated Table](#validate-paginated-table)
|
|
17
|
+
- [Validate Table in the Exact Order](#validate-table-in-the-exact-order)
|
|
18
|
+
- [Validate Subset of Table Data](#validate-subset-of-table-data)
|
|
19
|
+
- [Validate Empty Grid](#validate-empty-grid)
|
|
20
|
+
* [Limitations](#limitations)
|
|
21
|
+
* [Credit](#credit)
|
|
22
|
+
<br/>
|
|
23
|
+
<br/>
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm install cypress-ag-grid --save-dev
|
|
29
|
+
```
|
|
30
|
+
Then include the following in your support/index.js file:
|
|
31
|
+
|
|
32
|
+
```javascript
|
|
33
|
+
import "cypress-ag-grid";
|
|
34
|
+
```
|
|
35
|
+
## Usage
|
|
36
|
+
Consider the ag grid example below:
|
|
37
|
+

|
|
38
|
+
|
|
39
|
+
With the following DOM structure:
|
|
40
|
+

|
|
41
|
+
<br/>
|
|
42
|
+
<br/>
|
|
43
|
+
### Getting Data From the Grid:
|
|
44
|
+
To get the Ag Grid data, you must chain `.getAgGridData()` after the `cy.get()` command for the topmost level of the grid, including controls and headers (see selected DOM element in above image).
|
|
45
|
+
|
|
46
|
+
Correct Usage:
|
|
47
|
+
```javascript
|
|
48
|
+
cy.get("#myGrid").getAgGridData()
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Incorrect Usage:
|
|
52
|
+
```javascript
|
|
53
|
+
cy.getAgGridData();
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
The correct command will return the following:
|
|
57
|
+
```json
|
|
58
|
+
[
|
|
59
|
+
{ "Year": "2020", "Make": "Toyota", "Model": "Celica" },
|
|
60
|
+
{ "Year": "2020", "Make": "Ford", "Model": "Mondeo" },
|
|
61
|
+
{ "Year": "2020", "Make": "Porsche", "Model": "Boxter" },
|
|
62
|
+
{ "Year": "2020", "Make": "BMW", "Model": "3-series" },
|
|
63
|
+
{ "Year": "2020", "Make": "Mercedes", "Model": "GLC300" },
|
|
64
|
+
]
|
|
65
|
+
```
|
|
66
|
+
</br>
|
|
67
|
+
</br>
|
|
68
|
+
|
|
69
|
+
### Getting Select Row Data
|
|
70
|
+
To only get certain rows of data, pass the header values into the `getAgGridData()` command, like so:
|
|
71
|
+
|
|
72
|
+
```javascript
|
|
73
|
+
cy.get("#myGrid").getAgGridData({ onlyColumns: ["Year", "Make"] })
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
The above command will return the follwoing:
|
|
77
|
+
```json
|
|
78
|
+
[
|
|
79
|
+
{ "Year": "2020", "Make": "Toyota"},
|
|
80
|
+
{ "Year": "2020", "Make": "Ford"},
|
|
81
|
+
{ "Year": "2020", "Make": "Porsche"},
|
|
82
|
+
{ "Year": "2020", "Make": "BMW"},
|
|
83
|
+
{ "Year": "2020", "Make": "Mercedes"},
|
|
84
|
+
]
|
|
85
|
+
```
|
|
86
|
+
</br>
|
|
87
|
+
</br>
|
|
88
|
+
|
|
89
|
+
### Sorting Columns
|
|
90
|
+
This command will sort the specified column by the sort direction specified.
|
|
91
|
+
|
|
92
|
+
<b>Defintion</b>:
|
|
93
|
+
`.agGridSortColumn(columnName:String, sortDirection:String)`
|
|
94
|
+
|
|
95
|
+
Example:
|
|
96
|
+
|
|
97
|
+
```javascript
|
|
98
|
+
cy.get("#myGrid").agGridSortColumn("Model", "descending");
|
|
99
|
+
```
|
|
100
|
+
</br>
|
|
101
|
+
</br>
|
|
102
|
+
|
|
103
|
+
### Filter by Text - Column Menu
|
|
104
|
+
This command will filter a column by a text value from its menu. In the options, you must specify a `searchCriteria` objects containing one or more objects with `columnName`, `filterValue`, and optionally `operator` (i.e. Contains, Not contains, Equals, etc.).
|
|
105
|
+
|
|
106
|
+

|
|
107
|
+
|
|
108
|
+
<b>Definition:</b> `.agGridColumnFilterTextMenu(options: {})`
|
|
109
|
+
|
|
110
|
+
Example:
|
|
111
|
+
```javascript
|
|
112
|
+
cy.get("#myGrid").agGridColumnFilterTextMenu({
|
|
113
|
+
searchCriteria:[{
|
|
114
|
+
columnName: "Model",
|
|
115
|
+
filterValue: "GLC300",
|
|
116
|
+
operator:"Equals"
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
columnName: "Make",
|
|
120
|
+
filterValue: "Mercedes",
|
|
121
|
+
operator:"Equals"
|
|
122
|
+
}
|
|
123
|
+
],
|
|
124
|
+
hasApplyButton: false
|
|
125
|
+
})
|
|
126
|
+
````
|
|
127
|
+
The above command will filter the Model column for the value 'GLC300' and set the filter operator to 'Equals'. It will then apply a secondary filter on the Make column for 'Mercedes'.
|
|
128
|
+
</br>
|
|
129
|
+
</br>
|
|
130
|
+
### Filterby Text - Floating Filter
|
|
131
|
+
This command will filter a column by a text value from its floating filter (if applicable). This command will filter a column by a text value from its floating menu. In the options, you must specify a `searchCriteria` object with `columnName`, `filterValue`, and optionally `operator` (i.e. Contains, Not contains, Equals, etc.) and `searchInputIndex` in the event you wish to apply multiple text conditions (see below for multi-condition example).
|
|
132
|
+
|
|
133
|
+

|
|
134
|
+
|
|
135
|
+
<b>Definition:</b> .agGridColumnFilterTextFloating(options: {})
|
|
136
|
+
|
|
137
|
+
Example:
|
|
138
|
+
```
|
|
139
|
+
cy.get(agGridSelector).agGridColumnFilterTextFloating({
|
|
140
|
+
searchCriteria: {
|
|
141
|
+
columnName: "Make",
|
|
142
|
+
filterValue: "Ford",
|
|
143
|
+
},
|
|
144
|
+
hasApplyButton: true,
|
|
145
|
+
});
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
The above example will search for the Make `Ford` from the floating text menu filter.
|
|
149
|
+
|
|
150
|
+
If you have the option for multiple conditions on the floating filter, you can do two searches, specifying the `searchInputIndex` parameter in the `searchCriteria` object. The below example will ssarch for any `Make` that contains `B` AND `MW`:
|
|
151
|
+
|
|
152
|
+
Example:
|
|
153
|
+
```
|
|
154
|
+
cy.get(agGridSelector).agGridColumnFilterTextFloating({
|
|
155
|
+
searchCriteria: {
|
|
156
|
+
columnName: "Make",
|
|
157
|
+
filterValue: "B",
|
|
158
|
+
searchInputIndex: 0,
|
|
159
|
+
},
|
|
160
|
+
hasApplyButton: true,
|
|
161
|
+
});
|
|
162
|
+
cy.get(agGridSelector).agGridColumnFilterTextFloating({
|
|
163
|
+
searchCriteria: {
|
|
164
|
+
columnName: "Make",
|
|
165
|
+
filterValue: "MW",
|
|
166
|
+
searchInputIndex: 1,
|
|
167
|
+
},
|
|
168
|
+
hasApplyButton: true,
|
|
169
|
+
});
|
|
170
|
+
```
|
|
171
|
+

|
|
172
|
+
|
|
173
|
+
<br/>
|
|
174
|
+
</br>
|
|
175
|
+
|
|
176
|
+
### Filter by Checkbox - Column Menu
|
|
177
|
+
This command will filter a column by a checkbox text value from its menu.
|
|
178
|
+

|
|
179
|
+
|
|
180
|
+
Definition:
|
|
181
|
+
```javascript
|
|
182
|
+
.agGridColumnFilterCheckboxMenu(options={})
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Example:
|
|
186
|
+
```javascript
|
|
187
|
+
cy.get("#myGrid").agGridColumnFilterCheckboxMenu({
|
|
188
|
+
searchCriteria: {
|
|
189
|
+
columnName: "Model",
|
|
190
|
+
filterValue: "2002",
|
|
191
|
+
},
|
|
192
|
+
hasApplyButton: true,
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
```
|
|
196
|
+
</br>
|
|
197
|
+
</br>
|
|
198
|
+
|
|
199
|
+
### Add or Remove Columns
|
|
200
|
+
This command will toggle the specified column from the grid's sidebar.
|
|
201
|
+
|
|
202
|
+
<b>Definition:</b>`.agGridToggleColumnsSideBar(columnName:String, doRemove:boolean)`
|
|
203
|
+
|
|
204
|
+
Example:
|
|
205
|
+
```javascript
|
|
206
|
+
// This will remove the column "Year" from the grid
|
|
207
|
+
cy.get("#myGrid").agGridToggleColumnsSideBar("Year", true);
|
|
208
|
+
```
|
|
209
|
+
<br/>
|
|
210
|
+
<br/>
|
|
211
|
+
|
|
212
|
+
### Validate Paginated Table
|
|
213
|
+
This command will validate the paginated grid's data. The supplied expectedPaginatedTableData must be paginated as it's shown in the grid.
|
|
214
|
+
|
|
215
|
+
<b>Definition:</b> `agGridValidatePaginatedTable(expectedPaginatedTableData, onlyColumns = {})`
|
|
216
|
+
|
|
217
|
+
Example:
|
|
218
|
+
```javascript
|
|
219
|
+
const expectedPaginatedTableData = [
|
|
220
|
+
[
|
|
221
|
+
{ "Year": "2020", "Make": "Toyota", "Model": "Celica" },
|
|
222
|
+
{ "Year": "2020", "Make": "Ford", "Model": "Mondeo" },
|
|
223
|
+
{ "Year": "2020", "Make": "Porsche", "Model": "Boxter" },
|
|
224
|
+
{ "Year": "2020", "Make": "BMW", "Model": "3-series" },
|
|
225
|
+
{ "Year": "2020", "Make": "Mercedes", "Model": "GLC300" },
|
|
226
|
+
],
|
|
227
|
+
[
|
|
228
|
+
{ "Year": "2020", "Make": "Honda", "Model": "Civic" },
|
|
229
|
+
{ "Year": "2020", "Make": "Honda", "Model": "Accord" },
|
|
230
|
+
{ "Year": "2020", "Make": "Ford", "Model": "Taurus" },
|
|
231
|
+
{ "Year": "2020", "Make": "Hyundai", "Model": "Elantra" },
|
|
232
|
+
{ "Year": "2020", "Make": "Toyota", "Model": "Celica" },
|
|
233
|
+
],
|
|
234
|
+
...other table data
|
|
235
|
+
];
|
|
236
|
+
cy.get("#myGrid").agGridValidatePaginatedTable(
|
|
237
|
+
expectedPaginatedTableData, onlyColumns ={"Year", "Make", "Model"}
|
|
238
|
+
);
|
|
239
|
+
});
|
|
240
|
+
```
|
|
241
|
+
<br/>
|
|
242
|
+
<br/>
|
|
243
|
+
|
|
244
|
+
### Validate Table in the Exact Order
|
|
245
|
+
This command will verify the table data is displayed exactly in the same order as the supplied expected table data. This will ONLY validate the first page of a paginated table.
|
|
246
|
+
|
|
247
|
+
<b>Definition</b>: `.agGridValidateRowsExactOrder(actualTableData, expectedTableData)`
|
|
248
|
+
|
|
249
|
+
Example:
|
|
250
|
+
```javascript
|
|
251
|
+
cy.get("#myGrid")
|
|
252
|
+
.getAgGridData()
|
|
253
|
+
.then((actualTableData) => {
|
|
254
|
+
cy.get(agGridSelector).agGridValidateRowsExactOrder(actualTableData, expectedTableData);
|
|
255
|
+
});
|
|
256
|
+
```
|
|
257
|
+
<br/>
|
|
258
|
+
<br/>
|
|
259
|
+
|
|
260
|
+
### Validate Subset of Table Data
|
|
261
|
+
This command will validate a subset of the table data. Ideal for verifying one or more records, or verify records without specified columns.
|
|
262
|
+
|
|
263
|
+
<b>Definition:</b>: `agGridValidateRowsSubset(actualTableData, expectedTableData)`
|
|
264
|
+
|
|
265
|
+
Example:
|
|
266
|
+
```javascript
|
|
267
|
+
const expectedTableData = [
|
|
268
|
+
{ "Year": "2020", "Make": "Toyota", "Model": "Celica" },
|
|
269
|
+
{ "Year": "2020", "Make": "Ford", "Model": "Mondeo" },
|
|
270
|
+
{ "Year": "2020", "Make": "Porsche", "Model": "Boxter" },
|
|
271
|
+
{ "Year": "2020", "Make": "BMW", "Model": "3-series" },
|
|
272
|
+
{ "Year": "2020", "Make": "Mercedes", "Model": "GLC300" },
|
|
273
|
+
];
|
|
274
|
+
cy.get(agGridSelector)
|
|
275
|
+
.getAgGridData({ onlyColumns: ["Year", "Make", "Model"] })
|
|
276
|
+
.then((actualTableData) => {
|
|
277
|
+
cy.get(agGridSelector).agGridValidateRowsSubset(actualTableData, expectedTableData);
|
|
278
|
+
});
|
|
279
|
+
});
|
|
280
|
+
```
|
|
281
|
+
<br/>
|
|
282
|
+
<br/>
|
|
283
|
+
|
|
284
|
+
### Validate Empty Grid
|
|
285
|
+
This will verify the table data is empty.
|
|
286
|
+
|
|
287
|
+
<b>Definition</b>:`agGridValidateEmptyTable(actualTableData, expectedTableData)`
|
|
288
|
+
|
|
289
|
+
Example:
|
|
290
|
+
```javascript
|
|
291
|
+
cy.get(agGridSelector)
|
|
292
|
+
.getAgGridData()
|
|
293
|
+
.then((actualTableData) => {
|
|
294
|
+
cy.get(agGridSelector).agGridValidateEmptyTable(actualTableData);
|
|
295
|
+
});
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
## Limitations
|
|
299
|
+
* Unable to validate deeply nested row groups
|
|
300
|
+
* Unable to validate deeply nested column groups
|
|
301
|
+
* Unable to validate the entirety of an unlimited scrolling grid.
|
|
302
|
+
* Unable to validate data that is out of view. The DOM will register the ag grid data as it's scrolled into view.
|
|
303
|
+
* To combat this, in your code where the ag grid is called, check if the Cypress window is controlling the app and set the ag grid object to `.sizeColumnsToFit()`. You can see an example of this in the `app/grid.js` file of this repository. Read more [here](https://www.ag-grid.com/javascript-grid/column-sizing/#size-columns-to-fit)
|
|
304
|
+
* Example:
|
|
305
|
+
```javascript
|
|
306
|
+
if(window.Cypress){
|
|
307
|
+
this.api.sizeColumnsToFit();
|
|
308
|
+
}
|
|
309
|
+
```
|
|
310
|
+
## Credit
|
|
311
|
+
A portion of the logic to retrieve table data was expanded upon from the project [Cypress-Get-Table](https://github.com/roggerfe/cypress-get-table) by [Rogger Fernandez](https://github.com/roggerfe).
|
|
Binary file
|