cypress-ag-grid 1.1.1 → 1.4.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.
@@ -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,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
- ![alt text](./ag-grid-example.png "AG Grid")
38
-
39
- With the following DOM structure:
40
- ![alt text](./ag-grid-example-dom.png "AG Grid Dom")
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
- ![alt text](./ag-grid-example-filter-text-menu.png "AG Grid Dom - Filter by Text Menu")
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
- ![alt text](./ag-grid-example-filter-text-floating.png "AG Grid Dom - Filter by Text Floating")
134
-
135
- <b>Definition:</b> .agGridColumnFilterTextMenu(options: {})
136
-
137
- See [Filter by Text - Column Menu](#filter-by-Text---Column-Menu) for example and usage.
138
- <br/>
139
- </br>
140
-
141
- ### Filter by Checkbox - Column Menu
142
- This command will filter a column by a checkbox text value from its menu.
143
- ![alt text](./ag-grid-example-filter-checkbox-menu.png "AG Grid Dom - Filter by Checkbox Menu")
144
-
145
- Definition:
146
- ```javascript
147
- .agGridColumnFilterCheckboxMenu(options={})
148
- ```
149
-
150
- Example:
151
- ```javascript
152
- cy.get("#myGrid").agGridColumnFilterCheckboxMenu({
153
- searchCriteria: {
154
- columnName: "Model",
155
- filterValue: "2002",
156
- },
157
- hasApplyButton: true,
158
- });
159
-
160
- ```
161
- </br>
162
- </br>
163
-
164
- ### Add or Remove Columns
165
- This command will toggle the specified column from the grid's sidebar.
166
-
167
- <b>Definition:</b>`.agGridToggleColumnsSideBar(columnName:String, doRemove:boolean)`
168
-
169
- Example:
170
- ```javascript
171
- // This will remove the column "Year" from the grid
172
- cy.get("#myGrid").agGridToggleColumnsSideBar("Year", true);
173
- ```
174
- <br/>
175
- <br/>
176
-
177
- ### Validate Paginated Table
178
- This command will validate the paginated grid's data. The supplied expectedPaginatedTableData must be paginated as it's shown in the grid.
179
-
180
- <b>Definition:</b> `agGridValidatePaginatedTable(expectedPaginatedTableData, onlyColumns = {})`
181
-
182
- Example:
183
- ```javascript
184
- const expectedPaginatedTableData = [
185
- [
186
- { "Year": "2020", "Make": "Toyota", "Model": "Celica" },
187
- { "Year": "2020", "Make": "Ford", "Model": "Mondeo" },
188
- { "Year": "2020", "Make": "Porsche", "Model": "Boxter" },
189
- { "Year": "2020", "Make": "BMW", "Model": "3-series" },
190
- { "Year": "2020", "Make": "Mercedes", "Model": "GLC300" },
191
- ],
192
- [
193
- { "Year": "2020", "Make": "Honda", "Model": "Civic" },
194
- { "Year": "2020", "Make": "Honda", "Model": "Accord" },
195
- { "Year": "2020", "Make": "Ford", "Model": "Taurus" },
196
- { "Year": "2020", "Make": "Hyundai", "Model": "Elantra" },
197
- { "Year": "2020", "Make": "Toyota", "Model": "Celica" },
198
- ],
199
- ...other table data
200
- ];
201
- cy.get("#myGrid").agGridValidatePaginatedTable(
202
- expectedPaginatedTableData, onlyColumns ={"Year", "Make", "Model"}
203
- );
204
- });
205
- ```
206
- <br/>
207
- <br/>
208
-
209
- ### Validate Table in the Exact Order
210
- 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.
211
-
212
- <b>Definition</b>: `.agGridValidateRowsExactOrder(actualTableData, expectedTableData)`
213
-
214
- Example:
215
- ```javascript
216
- cy.get("#myGrid")
217
- .getAgGridData()
218
- .then((actualTableData) => {
219
- cy.get(agGridSelector).agGridValidateRowsExactOrder(actualTableData, expectedTableData);
220
- });
221
- ```
222
- <br/>
223
- <br/>
224
-
225
- ### Validate Subset of Table Data
226
- This command will validate a subset of the table data. Ideal for verifying one or more records, or verify records without specified columns.
227
-
228
- <b>Definition:</b>: `agGridValidateRowsSubset(actualTableData, expectedTableData)`
229
-
230
- Example:
231
- ```javascript
232
- const expectedTableData = [
233
- { "Year": "2020", "Make": "Toyota", "Model": "Celica" },
234
- { "Year": "2020", "Make": "Ford", "Model": "Mondeo" },
235
- { "Year": "2020", "Make": "Porsche", "Model": "Boxter" },
236
- { "Year": "2020", "Make": "BMW", "Model": "3-series" },
237
- { "Year": "2020", "Make": "Mercedes", "Model": "GLC300" },
238
- ];
239
- cy.get(agGridSelector)
240
- .getAgGridData({ onlyColumns: ["Year", "Make", "Model"] })
241
- .then((actualTableData) => {
242
- cy.get(agGridSelector).agGridValidateRowsSubset(actualTableData, expectedTableData);
243
- });
244
- });
245
- ```
246
- <br/>
247
- <br/>
248
-
249
- ### Validate Empty Grid
250
- This will verify the table data is empty.
251
-
252
- <b>Definition</b>:`agGridValidateEmptyTable(actualTableData, expectedTableData)`
253
-
254
- Example:
255
- ```javascript
256
- cy.get(agGridSelector)
257
- .getAgGridData()
258
- .then((actualTableData) => {
259
- cy.get(agGridSelector).agGridValidateEmptyTable(actualTableData);
260
- });
261
- ```
262
-
263
- ## Limitations
264
- * Unable to validate deeply nested row groups
265
- * Unable to validate deeply nested column groups
266
- * Unable to validate the entirety of an unlimited scrolling grid.
267
- * Unable to validate data that is out of view. The DOM will register the ag grid data as it's scrolled into view.
268
- * 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)
269
- * Example:
270
- ```javascript
271
- if(Cypress.window){
272
- this.api.sizeColumnsToFit();
273
- }
274
- ```
275
- ## Credit
276
- 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).
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
+ ![alt text](./ag-grid-example.png "AG Grid")
38
+
39
+ With the following DOM structure:
40
+ ![alt text](./ag-grid-example-dom.png "AG Grid Dom")
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
+ ![alt text](./ag-grid-example-filter-text-menu.png "AG Grid Dom - Filter by Text Menu")
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
+ ![alt text](./ag-grid-example-filter-text-floating.png "AG Grid Dom - Filter by Text Floating")
134
+
135
+ <b>Definition:</b> .agGridColumnFilterTextMenu(options: {})
136
+
137
+ See [Filter by Text - Column Menu](#filter-by-Text---Column-Menu) for example and usage.
138
+ <br/>
139
+ </br>
140
+
141
+ ### Filter by Checkbox - Column Menu
142
+ This command will filter a column by a checkbox text value from its menu.
143
+ ![alt text](./ag-grid-example-filter-checkbox-menu.png "AG Grid Dom - Filter by Checkbox Menu")
144
+
145
+ Definition:
146
+ ```javascript
147
+ .agGridColumnFilterCheckboxMenu(options={})
148
+ ```
149
+
150
+ Example:
151
+ ```javascript
152
+ cy.get("#myGrid").agGridColumnFilterCheckboxMenu({
153
+ searchCriteria: {
154
+ columnName: "Model",
155
+ filterValue: "2002",
156
+ },
157
+ hasApplyButton: true,
158
+ });
159
+
160
+ ```
161
+ </br>
162
+ </br>
163
+
164
+ ### Add or Remove Columns
165
+ This command will toggle the specified column from the grid's sidebar.
166
+
167
+ <b>Definition:</b>`.agGridToggleColumnsSideBar(columnName:String, doRemove:boolean)`
168
+
169
+ Example:
170
+ ```javascript
171
+ // This will remove the column "Year" from the grid
172
+ cy.get("#myGrid").agGridToggleColumnsSideBar("Year", true);
173
+ ```
174
+ <br/>
175
+ <br/>
176
+
177
+ ### Validate Paginated Table
178
+ This command will validate the paginated grid's data. The supplied expectedPaginatedTableData must be paginated as it's shown in the grid.
179
+
180
+ <b>Definition:</b> `agGridValidatePaginatedTable(expectedPaginatedTableData, onlyColumns = {})`
181
+
182
+ Example:
183
+ ```javascript
184
+ const expectedPaginatedTableData = [
185
+ [
186
+ { "Year": "2020", "Make": "Toyota", "Model": "Celica" },
187
+ { "Year": "2020", "Make": "Ford", "Model": "Mondeo" },
188
+ { "Year": "2020", "Make": "Porsche", "Model": "Boxter" },
189
+ { "Year": "2020", "Make": "BMW", "Model": "3-series" },
190
+ { "Year": "2020", "Make": "Mercedes", "Model": "GLC300" },
191
+ ],
192
+ [
193
+ { "Year": "2020", "Make": "Honda", "Model": "Civic" },
194
+ { "Year": "2020", "Make": "Honda", "Model": "Accord" },
195
+ { "Year": "2020", "Make": "Ford", "Model": "Taurus" },
196
+ { "Year": "2020", "Make": "Hyundai", "Model": "Elantra" },
197
+ { "Year": "2020", "Make": "Toyota", "Model": "Celica" },
198
+ ],
199
+ ...other table data
200
+ ];
201
+ cy.get("#myGrid").agGridValidatePaginatedTable(
202
+ expectedPaginatedTableData, onlyColumns ={"Year", "Make", "Model"}
203
+ );
204
+ });
205
+ ```
206
+ <br/>
207
+ <br/>
208
+
209
+ ### Validate Table in the Exact Order
210
+ 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.
211
+
212
+ <b>Definition</b>: `.agGridValidateRowsExactOrder(actualTableData, expectedTableData)`
213
+
214
+ Example:
215
+ ```javascript
216
+ cy.get("#myGrid")
217
+ .getAgGridData()
218
+ .then((actualTableData) => {
219
+ cy.get(agGridSelector).agGridValidateRowsExactOrder(actualTableData, expectedTableData);
220
+ });
221
+ ```
222
+ <br/>
223
+ <br/>
224
+
225
+ ### Validate Subset of Table Data
226
+ This command will validate a subset of the table data. Ideal for verifying one or more records, or verify records without specified columns.
227
+
228
+ <b>Definition:</b>: `agGridValidateRowsSubset(actualTableData, expectedTableData)`
229
+
230
+ Example:
231
+ ```javascript
232
+ const expectedTableData = [
233
+ { "Year": "2020", "Make": "Toyota", "Model": "Celica" },
234
+ { "Year": "2020", "Make": "Ford", "Model": "Mondeo" },
235
+ { "Year": "2020", "Make": "Porsche", "Model": "Boxter" },
236
+ { "Year": "2020", "Make": "BMW", "Model": "3-series" },
237
+ { "Year": "2020", "Make": "Mercedes", "Model": "GLC300" },
238
+ ];
239
+ cy.get(agGridSelector)
240
+ .getAgGridData({ onlyColumns: ["Year", "Make", "Model"] })
241
+ .then((actualTableData) => {
242
+ cy.get(agGridSelector).agGridValidateRowsSubset(actualTableData, expectedTableData);
243
+ });
244
+ });
245
+ ```
246
+ <br/>
247
+ <br/>
248
+
249
+ ### Validate Empty Grid
250
+ This will verify the table data is empty.
251
+
252
+ <b>Definition</b>:`agGridValidateEmptyTable(actualTableData, expectedTableData)`
253
+
254
+ Example:
255
+ ```javascript
256
+ cy.get(agGridSelector)
257
+ .getAgGridData()
258
+ .then((actualTableData) => {
259
+ cy.get(agGridSelector).agGridValidateEmptyTable(actualTableData);
260
+ });
261
+ ```
262
+
263
+ ## Limitations
264
+ * Unable to validate deeply nested row groups
265
+ * Unable to validate deeply nested column groups
266
+ * Unable to validate the entirety of an unlimited scrolling grid.
267
+ * Unable to validate data that is out of view. The DOM will register the ag grid data as it's scrolled into view.
268
+ * 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)
269
+ * Example:
270
+ ```javascript
271
+ if(Cypress.window){
272
+ this.api.sizeColumnsToFit();
273
+ }
274
+ ```
275
+ ## Credit
276
+ 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).