cypress-ag-grid 1.4.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/README.md +41 -6
- package/ag-grid-example-filter-text-floating-multi-condition.png +0 -0
- package/app/grid.js +2 -2
- package/cypress/{integration/ag-grid-spec.js → e2e/ag-grid.cy.js} +76 -39
- package/cypress/support/{index.js → e2e.js} +0 -0
- package/cypress.config.js +11 -0
- package/package.json +2 -2
- package/src/agGrid/agGridInteractions.js +11 -7
- package/cypress.json +0 -1
package/README.md
CHANGED
|
@@ -70,7 +70,7 @@ The correct command will return the following:
|
|
|
70
70
|
To only get certain rows of data, pass the header values into the `getAgGridData()` command, like so:
|
|
71
71
|
|
|
72
72
|
```javascript
|
|
73
|
-
cy.get("#myGrid).getAgGridData({ onlyColumns: ["Year", "Make"] })
|
|
73
|
+
cy.get("#myGrid").getAgGridData({ onlyColumns: ["Year", "Make"] })
|
|
74
74
|
```
|
|
75
75
|
|
|
76
76
|
The above command will return the follwoing:
|
|
@@ -128,13 +128,48 @@ The above command will filter the Model column for the value 'GLC300' and set th
|
|
|
128
128
|
</br>
|
|
129
129
|
</br>
|
|
130
130
|
### Filterby Text - Floating Filter
|
|
131
|
-
This command will filter a column by a text value from its floating filter (if applicable).
|
|
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
132
|
|
|
133
133
|

|
|
134
134
|
|
|
135
|
-
<b>Definition:</b> .
|
|
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
|
+

|
|
136
172
|
|
|
137
|
-
See [Filter by Text - Column Menu](#filter-by-Text---Column-Menu) for example and usage.
|
|
138
173
|
<br/>
|
|
139
174
|
</br>
|
|
140
175
|
|
|
@@ -268,9 +303,9 @@ Example:
|
|
|
268
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)
|
|
269
304
|
* Example:
|
|
270
305
|
```javascript
|
|
271
|
-
if(Cypress
|
|
306
|
+
if(window.Cypress){
|
|
272
307
|
this.api.sizeColumnsToFit();
|
|
273
308
|
}
|
|
274
309
|
```
|
|
275
310
|
## 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).
|
|
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
|
package/app/grid.js
CHANGED
|
@@ -47,10 +47,10 @@ new agGrid.Grid(eGridDiv, gridOptions);
|
|
|
47
47
|
// Grab the grid data from the supplied API endpoint
|
|
48
48
|
agGrid
|
|
49
49
|
.simpleHttpRequest({
|
|
50
|
-
url: "https://api.jsonbin.io/b/608304f69a9aa933335613a6/2"
|
|
50
|
+
url: "https://api.jsonbin.io/v3/b/608304f69a9aa933335613a6/2"
|
|
51
51
|
})
|
|
52
52
|
.then((data) => {
|
|
53
|
-
gridOptions.api.setRowData(data);
|
|
53
|
+
gridOptions.api.setRowData(data.record);
|
|
54
54
|
});
|
|
55
55
|
|
|
56
56
|
function autoSizeAllColumns() {
|
|
@@ -10,10 +10,10 @@ import { filterOperator } from "../../src/agGrid/filterOperator.enum";
|
|
|
10
10
|
const _pageSize = 5;
|
|
11
11
|
const agGridSelector = "#myGrid";
|
|
12
12
|
|
|
13
|
-
describe("ag-grid scenarios", () => {
|
|
13
|
+
describe("ag-grid get data scenarios", () => {
|
|
14
14
|
beforeEach(() => {
|
|
15
15
|
cy.visit("../app/index.html");
|
|
16
|
-
cy.get(".ag-cell", {timeout: 10000}).should("be.visible");
|
|
16
|
+
cy.get(".ag-cell", { timeout: 10000 }).should("be.visible");
|
|
17
17
|
});
|
|
18
18
|
|
|
19
19
|
it("verify paginated table data - include all columns", () => {
|
|
@@ -98,38 +98,43 @@ describe("ag-grid scenarios", () => {
|
|
|
98
98
|
columnName: "Model",
|
|
99
99
|
filterValue: "2002",
|
|
100
100
|
},
|
|
101
|
-
selectAllLocaleText:
|
|
101
|
+
selectAllLocaleText: "Select All", // This is optional if you are using localText for ag grid
|
|
102
102
|
hasApplyButton: true,
|
|
103
103
|
});
|
|
104
104
|
cy.get(agGridSelector)
|
|
105
105
|
.getAgGridData()
|
|
106
106
|
.then((actualTableData) => {
|
|
107
|
-
cy.get(agGridSelector).agGridValidateRowsExactOrder(actualTableData, expectedTableData)
|
|
107
|
+
cy.get(agGridSelector).agGridValidateRowsExactOrder(actualTableData, expectedTableData)
|
|
108
108
|
});
|
|
109
109
|
});
|
|
110
110
|
|
|
111
111
|
it("able to filter by checkbox - multiple columns", () => {
|
|
112
112
|
const expectedTableData = [
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
113
|
+
{ Year: "2020", Make: "BMW", Model: "3-series", Price: "45000" },
|
|
114
|
+
{ Year: "2020", Make: "BMW", Model: "3-series", Price: "32000" },
|
|
115
|
+
{ Year: "2020", Make: "BMW", Model: "2002", Price: "88001" },
|
|
116
116
|
];
|
|
117
117
|
cy.get(agGridSelector).agGridColumnFilterCheckboxMenu({
|
|
118
|
-
searchCriteria: [
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
118
|
+
searchCriteria: [
|
|
119
|
+
{
|
|
120
|
+
columnName: "Model",
|
|
121
|
+
filterValue: "2002",
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
columnName: "Model",
|
|
125
|
+
filterValue: "3-series",
|
|
126
|
+
},
|
|
127
|
+
],
|
|
127
128
|
hasApplyButton: true,
|
|
128
129
|
});
|
|
129
130
|
cy.get(agGridSelector)
|
|
130
131
|
.getAgGridData()
|
|
131
132
|
.then((actualTableData) => {
|
|
132
|
-
cy.get(agGridSelector).agGridValidateRowsExactOrder(
|
|
133
|
+
cy.get(agGridSelector).agGridValidateRowsExactOrder(
|
|
134
|
+
actualTableData,
|
|
135
|
+
expectedTableData,
|
|
136
|
+
true
|
|
137
|
+
);
|
|
133
138
|
});
|
|
134
139
|
});
|
|
135
140
|
|
|
@@ -161,17 +166,18 @@ describe("ag-grid scenarios", () => {
|
|
|
161
166
|
];
|
|
162
167
|
cy.get(agGridSelector).agGridSortColumn("Model", sort.ascending);
|
|
163
168
|
cy.get(agGridSelector).agGridColumnFilterTextMenu({
|
|
164
|
-
searchCriteria: [
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
169
|
+
searchCriteria: [
|
|
170
|
+
{
|
|
171
|
+
columnName: "Price",
|
|
172
|
+
filterValue: "32000",
|
|
173
|
+
operator: filterOperator.equals,
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
columnName: "Make",
|
|
177
|
+
filterValue: "BMW",
|
|
178
|
+
operator: filterOperator.equals,
|
|
179
|
+
},
|
|
180
|
+
],
|
|
175
181
|
hasApplyButton: true,
|
|
176
182
|
});
|
|
177
183
|
cy.get(agGridSelector)
|
|
@@ -203,21 +209,27 @@ describe("ag-grid scenarios", () => {
|
|
|
203
209
|
});
|
|
204
210
|
});
|
|
205
211
|
|
|
206
|
-
it("able to filter by text - floating filter - multiple
|
|
212
|
+
it("able to filter by text - floating filter - multiple conditions", () => {
|
|
207
213
|
const expectedTableData = [
|
|
208
|
-
{ Year: "
|
|
214
|
+
{ Year: "2020", Make: "BMW", Model: "2002", Price: "88001" },
|
|
215
|
+
{ Year: "2020", Make: "BMW", Model: "3-series", Price: "45000" },
|
|
216
|
+
{ Year: "2020", Make: "BMW", Model: "3-series", Price: "32000" },
|
|
209
217
|
];
|
|
210
218
|
cy.get(agGridSelector).agGridSortColumn("Model", sort.ascending);
|
|
211
219
|
cy.get(agGridSelector).agGridColumnFilterTextFloating({
|
|
212
|
-
searchCriteria:
|
|
220
|
+
searchCriteria: {
|
|
221
|
+
columnName: "Make",
|
|
222
|
+
filterValue: "B",
|
|
223
|
+
searchInputIndex: 0,
|
|
224
|
+
},
|
|
225
|
+
hasApplyButton: true,
|
|
226
|
+
});
|
|
227
|
+
cy.get(agGridSelector).agGridColumnFilterTextFloating({
|
|
228
|
+
searchCriteria: {
|
|
213
229
|
columnName: "Make",
|
|
214
|
-
filterValue: "
|
|
230
|
+
filterValue: "MW",
|
|
231
|
+
searchInputIndex: 1,
|
|
215
232
|
},
|
|
216
|
-
{
|
|
217
|
-
columnName: "Year",
|
|
218
|
-
filterValue: "1990",
|
|
219
|
-
}
|
|
220
|
-
],
|
|
221
233
|
hasApplyButton: true,
|
|
222
234
|
});
|
|
223
235
|
cy.get(agGridSelector)
|
|
@@ -225,7 +237,32 @@ describe("ag-grid scenarios", () => {
|
|
|
225
237
|
.then((actualTableData) => {
|
|
226
238
|
cy.get(agGridSelector).agGridValidateRowsExactOrder(actualTableData, expectedTableData);
|
|
227
239
|
});
|
|
228
|
-
});
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
it("able to filter by text - floating filter - multiple columns", () => {
|
|
243
|
+
const expectedTableData = [
|
|
244
|
+
{ Year: "1990", Make: "Ford", Model: "Taurus", Price: "900" },
|
|
245
|
+
];
|
|
246
|
+
cy.get(agGridSelector).agGridSortColumn("Model", sort.ascending);
|
|
247
|
+
cy.get(agGridSelector).agGridColumnFilterTextFloating({
|
|
248
|
+
searchCriteria: [
|
|
249
|
+
{
|
|
250
|
+
columnName: "Make",
|
|
251
|
+
filterValue: "Ford",
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
columnName: "Year",
|
|
255
|
+
filterValue: "1990",
|
|
256
|
+
},
|
|
257
|
+
],
|
|
258
|
+
hasApplyButton: true,
|
|
259
|
+
});
|
|
260
|
+
cy.get(agGridSelector)
|
|
261
|
+
.getAgGridData()
|
|
262
|
+
.then((actualTableData) => {
|
|
263
|
+
cy.get(agGridSelector).agGridValidateRowsExactOrder(actualTableData, expectedTableData);
|
|
264
|
+
});
|
|
265
|
+
});
|
|
229
266
|
|
|
230
267
|
it("able to validate empty table", () => {
|
|
231
268
|
//Search for an entry that does not exist
|
|
@@ -447,4 +484,4 @@ function removePropertyFromCollection(expectedTableData, columnsToExclude) {
|
|
|
447
484
|
// .then(() => {
|
|
448
485
|
// return paginatedTableData;
|
|
449
486
|
// });
|
|
450
|
-
// }
|
|
487
|
+
// }
|
|
File without changes
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const { defineConfig } = require('cypress')
|
|
2
|
+
|
|
3
|
+
module.exports = defineConfig({
|
|
4
|
+
e2e: {
|
|
5
|
+
// We've imported your old cypress plugins here.
|
|
6
|
+
// You may want to clean this up later by importing these.
|
|
7
|
+
setupNodeEvents(on, config) {
|
|
8
|
+
return require('./cypress/plugins/index.js')(on, config)
|
|
9
|
+
},
|
|
10
|
+
},
|
|
11
|
+
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cypress-ag-grid",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "Cypress plugin to interact with ag grid",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -24,6 +24,6 @@
|
|
|
24
24
|
"author": "Kerry McKeever <kerry@kerrymckeever.com>",
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"cypress": "^
|
|
27
|
+
"cypress": "^10.1.0"
|
|
28
28
|
}
|
|
29
29
|
}
|
|
@@ -205,7 +205,12 @@ function getFilterColumnButtonElement(
|
|
|
205
205
|
* @param operator (optional) use if using a search operator (i.e. Less Than, Equals, etc...use filterOperator.enum values)
|
|
206
206
|
* @param noMenuTabs (optional) boolean indicating if the menu has tabs.
|
|
207
207
|
*/
|
|
208
|
-
function filterBySearchTerm(agGridElement,
|
|
208
|
+
function filterBySearchTerm(agGridElement, options) {
|
|
209
|
+
const filterValue = options.searchCriteria.filterValue;
|
|
210
|
+
const operator = options.searchCriteria.operator;
|
|
211
|
+
const searchInputIndex = options.searchCriteria.searchInputIndex || 0;
|
|
212
|
+
const noMenuTabs = options.noMenuTabs;
|
|
213
|
+
|
|
209
214
|
// Navigate to the filter tab
|
|
210
215
|
if (!noMenuTabs) {
|
|
211
216
|
selectMenuTab(agGridElement, filterTab.filter);
|
|
@@ -229,6 +234,8 @@ function filterBySearchTerm(agGridElement, filterValue, operator, noMenuTabs) {
|
|
|
229
234
|
.find(".ag-popup-child")
|
|
230
235
|
.find("input")
|
|
231
236
|
.filter(":visible")
|
|
237
|
+
.eq(searchInputIndex)
|
|
238
|
+
.clear()
|
|
232
239
|
.type(filterValue)
|
|
233
240
|
.wait(500);
|
|
234
241
|
}
|
|
@@ -322,9 +329,7 @@ function _filterBySearchTextColumnMenu(agGridElement, options) {
|
|
|
322
329
|
).click();
|
|
323
330
|
filterBySearchTerm(
|
|
324
331
|
agGridElement,
|
|
325
|
-
options
|
|
326
|
-
options.searchCriteria.operator,
|
|
327
|
-
options.noMenuTabs
|
|
332
|
+
options
|
|
328
333
|
);
|
|
329
334
|
applyColumnFilter(agGridElement, options.hasApplyButton, options.noMenuTabs);
|
|
330
335
|
}
|
|
@@ -336,6 +341,7 @@ function _filterBySearchTextColumnMenu(agGridElement, options) {
|
|
|
336
341
|
* @param options.searchCriteria JSON with search properties and options
|
|
337
342
|
* @param options.searchCriteria.columnName name of the column to filter
|
|
338
343
|
* @param options.searchCriteria.filterValue value to input into the filter textbox
|
|
344
|
+
* @param options.searchCriteria.searchInputIndex [Optional] Uses 0 by default. Index of which filter box to use in event of having multiple search conditionals
|
|
339
345
|
* @param options.searchCriteria.operator [Optional] Use if using a search operator (i.e. Less Than, Equals, etc...use filterOperator.enum values).
|
|
340
346
|
* @param options.hasApplyButton [Optional] True if "Apply" button is used, false if filters by text input automatically.
|
|
341
347
|
* @param options.noMenuTabs [Optional] True if you use for example the community edition of ag-grid, which has no menu tabs
|
|
@@ -365,9 +371,7 @@ function _filterBySearchTextColumnFloatingFilter(agGridElement, options) {
|
|
|
365
371
|
).click();
|
|
366
372
|
filterBySearchTerm(
|
|
367
373
|
agGridElement,
|
|
368
|
-
options
|
|
369
|
-
options.searchCriteria.operator,
|
|
370
|
-
options.noMenuTabs
|
|
374
|
+
options
|
|
371
375
|
);
|
|
372
376
|
applyColumnFilter(agGridElement, options.hasApplyButton, options.noMenuTabs);
|
|
373
377
|
});
|
package/cypress.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{}
|