cypress-ag-grid 2.0.2 → 2.0.4
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 +1 -1
- package/README.md +2 -2
- package/app/ag-grid.css +6682 -0
- package/app/ag-theme-alpine.css +338 -0
- package/app/data.json +22 -0
- package/app/grid-basic.js +14 -6
- package/app/grid-grouped.js +2 -2
- package/app/index.html +2 -2
- package/cypress/e2e/ag-grid-data.cy.js +117 -44
- package/cypress/fixtures/cardata.json +20 -20
- package/package.json +2 -2
- package/src/agGrid/agGridInteractions.js +24 -23
- package/src/agGrid/filterOperator.enum.js +3 -1
- package/src/agGrid/sort.enum.js +2 -2
|
@@ -19,34 +19,35 @@ describe("ag-grid get data scenarios", () => {
|
|
|
19
19
|
it("verify paginated table data - include all columns", () => {
|
|
20
20
|
const expectedPaginatedTableData = [
|
|
21
21
|
[
|
|
22
|
-
{ Year: "2020", Make: "Toyota", Model: "Celica", Price: "35000" },
|
|
23
|
-
{ Year: "2020", Make: "Ford", Model: "Mondeo", Price: "32000" },
|
|
24
|
-
{ Year: "2020", Make: "Porsche", Model: "Boxter", Price: "72000" },
|
|
25
|
-
{ Year: "2020", Make: "BMW", Model: "3-series", Price: "45000" },
|
|
26
|
-
{ Year: "2020", Make: "Mercedes", Model: "GLC300", Price: "53000" },
|
|
22
|
+
{ Year: "2020", Make: "Toyota", Model: "Celica", Condition: "fair", Price: "35000" },
|
|
23
|
+
{ Year: "2020", Make: "Ford", Model: "Mondeo", Condition: "excellent", Price: "32000" },
|
|
24
|
+
{ Year: "2020", Make: "Porsche", Model: "Boxter", Condition: "good", Price: "72000" },
|
|
25
|
+
{ Year: "2020", Make: "BMW", Model: "3-series", Condition: "fair", Price: "45000" },
|
|
26
|
+
{ Year: "2020", Make: "Mercedes", Model: "GLC300", Condition: "good", Price: "53000" },
|
|
27
27
|
],
|
|
28
28
|
[
|
|
29
|
-
{ Year: "2020", Make: "Honda", Model: "Civic", Price: "22000" },
|
|
30
|
-
{ Year: "2020", Make: "Honda", Model: "Accord", Price: "32000" },
|
|
31
|
-
{ Year: "2020", Make: "Ford", Model: "Taurus", Price: "19000" },
|
|
32
|
-
{ Year: "2020", Make: "Hyundai", Model: "Elantra", Price: "22000" },
|
|
33
|
-
{ Year: "2020", Make: "Toyota", Model: "Celica", Price: "5000" },
|
|
29
|
+
{ Year: "2020", Make: "Honda", Model: "Civic", Condition: "poor", Price: "22000" },
|
|
30
|
+
{ Year: "2020", Make: "Honda", Model: "Accord", Condition: "poor", Price: "32000" },
|
|
31
|
+
{ Year: "2020", Make: "Ford", Model: "Taurus", Condition: "excellent", Price: "19000" },
|
|
32
|
+
{ Year: "2020", Make: "Hyundai", Model: "Elantra", Condition: "good", Price: "22000" },
|
|
33
|
+
{ Year: "2020", Make: "Toyota", Model: "Celica", Condition: "poor", Price: "5000" },
|
|
34
34
|
],
|
|
35
35
|
[
|
|
36
|
-
{ Year: "2020", Make: "Ford", Model: "Mondeo", Price: "25000" },
|
|
37
|
-
{ Year: "2020", Make: "Porsche", Model: "Boxter", Price: "99000" },
|
|
38
|
-
{ Year: "2020", Make: "BMW", Model: "3-series", Price: "32000" },
|
|
39
|
-
{ Year: "2020", Make: "Mercedes", Model: "GLC300", Price: "35000" },
|
|
40
|
-
{ Year: "2011", Make: "Honda", Model: "Civic", Price: "9000" },
|
|
36
|
+
{ Year: "2020", Make: "Ford", Model: "Mondeo", Condition: "good", Price: "25000" },
|
|
37
|
+
{ Year: "2020", Make: "Porsche", Model: "Boxter", Condition: "good", Price: "99000" },
|
|
38
|
+
{ Year: "2020", Make: "BMW", Model: "3-series", Condition: "poor", Price: "32000" },
|
|
39
|
+
{ Year: "2020", Make: "Mercedes", Model: "GLC300", Condition: "excellent", Price: "35000" },
|
|
40
|
+
{ Year: "2011", Make: "Honda", Model: "Civic", Condition: "good", Price: "9000" },
|
|
41
41
|
],
|
|
42
42
|
[
|
|
43
|
-
{ Year: "2020", Make: "Honda", Model: "Accord", Price: "34000" },
|
|
44
|
-
{ Year: "1990", Make: "Ford", Model: "Taurus", Price: "900" },
|
|
45
|
-
{ Year: "2020", Make: "Hyundai", Model: "Elantra", Price: "3000" },
|
|
46
|
-
{ Year: "2020", Make: "BMW", Model: "2002", Price: "88001" },
|
|
43
|
+
{ Year: "2020", Make: "Honda", Model: "Accord", Condition: "good", Price: "34000" },
|
|
44
|
+
{ Year: "1990", Make: "Ford", Model: "Taurus", Condition: "excellent", Price: "900" },
|
|
45
|
+
{ Year: "2020", Make: "Hyundai", Model: "Elantra", Condition: "fair", Price: "3000" },
|
|
46
|
+
{ Year: "2020", Make: "BMW", Model: "2002", Condition: "excellent", Price: "88001" },
|
|
47
|
+
{ Year: "2023", Make: "Hyundai", Model: "Santa Fe", Condition: "excellent", Price: "" },
|
|
47
48
|
],
|
|
48
49
|
];
|
|
49
|
-
|
|
50
|
+
cy.get(agGridSelector).agGridValidatePaginatedTable(
|
|
50
51
|
expectedPaginatedTableData
|
|
51
52
|
);
|
|
52
53
|
});
|
|
@@ -79,6 +80,7 @@ describe("ag-grid get data scenarios", () => {
|
|
|
79
80
|
{ Year: "1990", Make: "Ford", Model: "Taurus" },
|
|
80
81
|
{ Year: "2020", Make: "Hyundai", Model: "Elantra" },
|
|
81
82
|
{ Year: "2020", Make: "BMW", Model: "2002" },
|
|
83
|
+
{ Year: "2023", Make: "Hyundai", Model: "Santa Fe"},
|
|
82
84
|
],
|
|
83
85
|
];
|
|
84
86
|
cy.get(agGridSelector).agGridValidatePaginatedTable(
|
|
@@ -91,7 +93,7 @@ describe("ag-grid get data scenarios", () => {
|
|
|
91
93
|
|
|
92
94
|
it("able to filter by checkbox", () => {
|
|
93
95
|
const expectedTableData = [
|
|
94
|
-
{ Year: "2020", Make: "BMW", Model: "2002", Price: "88001" },
|
|
96
|
+
{ Year: "2020", Make: "BMW", Model: "2002", Condition: "excellent", Price: "88001" },
|
|
95
97
|
];
|
|
96
98
|
cy.get(agGridSelector).agGridColumnFilterCheckboxMenu({
|
|
97
99
|
searchCriteria: {
|
|
@@ -110,10 +112,11 @@ describe("ag-grid get data scenarios", () => {
|
|
|
110
112
|
|
|
111
113
|
it("able to filter by checkbox - multiple columns", () => {
|
|
112
114
|
const expectedTableData = [
|
|
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" },
|
|
115
|
+
{ Year: "2020", Make: "BMW", Model: "3-series", Condition: "fair", Price: "45000" },
|
|
116
|
+
{ Year: "2020", Make: "BMW", Model: "3-series", Condition: "poor", Price: "32000" },
|
|
117
|
+
{ Year: "2020", Make: "BMW", Model: "2002", Condition: "excellent", Price: "88001" },
|
|
116
118
|
];
|
|
119
|
+
|
|
117
120
|
cy.get(agGridSelector).agGridColumnFilterCheckboxMenu({
|
|
118
121
|
searchCriteria: [
|
|
119
122
|
{
|
|
@@ -130,15 +133,19 @@ describe("ag-grid get data scenarios", () => {
|
|
|
130
133
|
cy.get(agGridSelector)
|
|
131
134
|
.getAgGridData()
|
|
132
135
|
.then((actualTableData) => {
|
|
133
|
-
cy.agGridValidateRowsExactOrder(
|
|
136
|
+
cy.agGridValidateRowsExactOrder(
|
|
137
|
+
actualTableData,
|
|
138
|
+
expectedTableData,
|
|
139
|
+
true
|
|
140
|
+
);
|
|
134
141
|
});
|
|
135
142
|
});
|
|
136
143
|
|
|
137
144
|
it("able to filter by text - menu", () => {
|
|
138
145
|
const expectedTableData = [
|
|
139
|
-
{ Year: "2020", Make: "BMW", Model: "3-series", Price: "32000" },
|
|
140
|
-
{ Year: "2020", Make: "Honda", Model: "Accord", Price: "32000" },
|
|
141
|
-
{ Year: "2020", Make: "Ford", Model: "Mondeo", Price: "32000" },
|
|
146
|
+
{ Year: "2020", Make: "BMW", Model: "3-series", Condition: "poor", Price: "32000" },
|
|
147
|
+
{ Year: "2020", Make: "Honda", Model: "Accord", Condition: "poor", Price: "32000" },
|
|
148
|
+
{ Year: "2020", Make: "Ford", Model: "Mondeo", Condition: "excellent", Price: "32000" },
|
|
142
149
|
];
|
|
143
150
|
cy.get(agGridSelector).agGridSortColumn("Model", sort.ascending);
|
|
144
151
|
cy.get(agGridSelector).agGridColumnFilterTextMenu({
|
|
@@ -158,7 +165,7 @@ describe("ag-grid get data scenarios", () => {
|
|
|
158
165
|
|
|
159
166
|
it("able to filter by text - menu - multiple columns", () => {
|
|
160
167
|
const expectedTableData = [
|
|
161
|
-
{ Year: "2020", Make: "BMW", Model: "3-series", Price: "32000" },
|
|
168
|
+
{ Year: "2020", Make: "BMW", Model: "3-series", Condition: "poor", Price: "32000" },
|
|
162
169
|
];
|
|
163
170
|
cy.get(agGridSelector).agGridSortColumn("Model", sort.ascending);
|
|
164
171
|
cy.get(agGridSelector).agGridColumnFilterTextMenu({
|
|
@@ -185,11 +192,12 @@ describe("ag-grid get data scenarios", () => {
|
|
|
185
192
|
|
|
186
193
|
it("able to filter by text - floating filter", () => {
|
|
187
194
|
const expectedTableData = [
|
|
188
|
-
{ Year: "2020", Make: "Ford", Model: "Mondeo", Price: "32000" },
|
|
189
|
-
{ Year: "2020", Make: "Ford", Model: "Mondeo", Price: "25000" },
|
|
190
|
-
{ Year: "2020", Make: "Ford", Model: "Taurus", Price: "19000" },
|
|
191
|
-
{ Year: "1990", Make: "Ford", Model: "Taurus", Price: "900" },
|
|
195
|
+
{ Year: "2020", Make: "Ford", Model: "Mondeo", Condition: "excellent", Price: "32000" },
|
|
196
|
+
{ Year: "2020", Make: "Ford", Model: "Mondeo", Condition: "good", Price: "25000" },
|
|
197
|
+
{ Year: "2020", Make: "Ford", Model: "Taurus", Condition: "excellent", Price: "19000" },
|
|
198
|
+
{ Year: "1990", Make: "Ford", Model: "Taurus", Condition: "excellent", Price: "900" },
|
|
192
199
|
];
|
|
200
|
+
|
|
193
201
|
cy.get(agGridSelector).agGridSortColumn("Model", sort.ascending);
|
|
194
202
|
cy.get(agGridSelector).agGridColumnFilterTextFloating({
|
|
195
203
|
searchCriteria: {
|
|
@@ -207,10 +215,11 @@ describe("ag-grid get data scenarios", () => {
|
|
|
207
215
|
|
|
208
216
|
it("able to filter by text - floating filter - multiple conditions", () => {
|
|
209
217
|
const expectedTableData = [
|
|
210
|
-
{ Year: "2020", Make: "BMW", Model: "2002", Price: "88001" },
|
|
211
|
-
{ Year: "2020", Make: "BMW", Model: "3-series", Price: "45000" },
|
|
212
|
-
{ Year: "2020", Make: "BMW", Model: "3-series", Price: "32000" },
|
|
218
|
+
{ Year: "2020", Make: "BMW", Model: "2002", Condition: "excellent", Price: "88001" },
|
|
219
|
+
{ Year: "2020", Make: "BMW", Model: "3-series", Condition: "fair", Price: "45000" },
|
|
220
|
+
{ Year: "2020", Make: "BMW", Model: "3-series", Condition: "poor", Price: "32000" },
|
|
213
221
|
];
|
|
222
|
+
|
|
214
223
|
cy.get(agGridSelector).agGridSortColumn("Model", sort.ascending);
|
|
215
224
|
cy.get(agGridSelector).agGridColumnFilterTextFloating({
|
|
216
225
|
searchCriteria: {
|
|
@@ -237,7 +246,7 @@ describe("ag-grid get data scenarios", () => {
|
|
|
237
246
|
|
|
238
247
|
it("able to filter by text - floating filter - multiple columns", () => {
|
|
239
248
|
const expectedTableData = [
|
|
240
|
-
{ Year: "1990", Make: "Ford", Model: "Taurus", Price: "900" },
|
|
249
|
+
{ Year: "1990", Make: "Ford", Model: "Taurus", Condition: "excellent", Price: "900" },
|
|
241
250
|
];
|
|
242
251
|
cy.get(agGridSelector).agGridSortColumn("Model", sort.ascending);
|
|
243
252
|
cy.get(agGridSelector).agGridColumnFilterTextFloating({
|
|
@@ -256,14 +265,17 @@ describe("ag-grid get data scenarios", () => {
|
|
|
256
265
|
cy.get(agGridSelector)
|
|
257
266
|
.getAgGridData()
|
|
258
267
|
.then((actualTableData) => {
|
|
259
|
-
cy.get(agGridSelector).agGridValidateRowsExactOrder(
|
|
268
|
+
cy.get(agGridSelector).agGridValidateRowsExactOrder(
|
|
269
|
+
actualTableData,
|
|
270
|
+
expectedTableData
|
|
271
|
+
);
|
|
260
272
|
});
|
|
261
273
|
});
|
|
262
274
|
|
|
263
275
|
it("able to filter by text - floating filter - multi filter", () => {
|
|
264
276
|
const expectedTableData = [
|
|
265
|
-
{ Year: "2020", Make: "Ford", Model: "Taurus", Price: "19000" },
|
|
266
|
-
{ Year: "1990", Make: "Ford", Model: "Taurus", Price: "900" },
|
|
277
|
+
{ Year: "2020", Make: "Ford", Model: "Taurus", Condition: "excellent", Price: "19000" },
|
|
278
|
+
{ Year: "1990", Make: "Ford", Model: "Taurus", Condition: "excellent", Price: "900" },
|
|
267
279
|
];
|
|
268
280
|
cy.get(agGridSelector).agGridSortColumn("Model", sort.ascending);
|
|
269
281
|
cy.get(agGridSelector).agGridColumnFilterTextFloating({
|
|
@@ -271,7 +283,7 @@ describe("ag-grid get data scenarios", () => {
|
|
|
271
283
|
{
|
|
272
284
|
columnName: "Model",
|
|
273
285
|
filterValue: "Taurus",
|
|
274
|
-
isMultiFilter: true
|
|
286
|
+
isMultiFilter: true,
|
|
275
287
|
},
|
|
276
288
|
],
|
|
277
289
|
hasApplyButton: true,
|
|
@@ -279,11 +291,13 @@ describe("ag-grid get data scenarios", () => {
|
|
|
279
291
|
cy.get(agGridSelector)
|
|
280
292
|
.getAgGridData()
|
|
281
293
|
.then((actualTableData) => {
|
|
282
|
-
cy.get(agGridSelector).agGridValidateRowsExactOrder(
|
|
294
|
+
cy.get(agGridSelector).agGridValidateRowsExactOrder(
|
|
295
|
+
actualTableData,
|
|
296
|
+
expectedTableData
|
|
297
|
+
);
|
|
283
298
|
});
|
|
284
299
|
});
|
|
285
300
|
|
|
286
|
-
|
|
287
301
|
it("able to validate empty table", () => {
|
|
288
302
|
//Search for an entry that does not exist
|
|
289
303
|
cy.get(agGridSelector).agGridColumnFilterTextMenu({
|
|
@@ -417,6 +431,65 @@ describe("ag-grid get data scenarios", () => {
|
|
|
417
431
|
cy.agGridValidateRowsSubset(actualTableData, expectedTableData);
|
|
418
432
|
});
|
|
419
433
|
});
|
|
434
|
+
|
|
435
|
+
it("able to filter by 'Blank'", () =>{
|
|
436
|
+
const expectedTableData = [
|
|
437
|
+
{ Year: "2023", Make: "Hyundai", Model: "Santa Fe", Condition: "excellent", Price: "" }
|
|
438
|
+
]
|
|
439
|
+
|
|
440
|
+
cy.get(agGridSelector).agGridColumnFilterTextMenu({
|
|
441
|
+
searchCriteria: {
|
|
442
|
+
columnName: "Price",
|
|
443
|
+
operator: filterOperator.blank,
|
|
444
|
+
},
|
|
445
|
+
hasApplyButton: true,
|
|
446
|
+
});
|
|
447
|
+
cy.get(agGridSelector)
|
|
448
|
+
.getAgGridData()
|
|
449
|
+
.then((actualTableData) => {
|
|
450
|
+
cy.agGridValidateRowsSubset(actualTableData, expectedTableData);
|
|
451
|
+
});
|
|
452
|
+
|
|
453
|
+
});
|
|
454
|
+
|
|
455
|
+
it('able to filter by agTextColumnFilter with join operator', ()=>{
|
|
456
|
+
const expectedTableData = [
|
|
457
|
+
{ Year: "2020", Make: "Toyota", Model: "Celica", Condition: "fair", Price: "35000" },
|
|
458
|
+
{ Year: "2020", Make: "BMW", Model: "3-series", Condition: "fair", Price: "45000" },
|
|
459
|
+
{ Year: "2020", Make: "Hyundai", Model: "Elantra", Condition: "fair", Price: "3000" },
|
|
460
|
+
]
|
|
461
|
+
cy.get(agGridSelector).agGridColumnFilterTextFloating({
|
|
462
|
+
searchCriteria:
|
|
463
|
+
{
|
|
464
|
+
columnName: "Condition",
|
|
465
|
+
operator: "Starts with",
|
|
466
|
+
filterValue: 'f',
|
|
467
|
+
searchInputIndex: 0,
|
|
468
|
+
},
|
|
469
|
+
|
|
470
|
+
multiple: true,
|
|
471
|
+
hasApplyButton: true,
|
|
472
|
+
});
|
|
473
|
+
|
|
474
|
+
cy.get(agGridSelector).agGridColumnFilterTextFloating({
|
|
475
|
+
searchCriteria:
|
|
476
|
+
{
|
|
477
|
+
columnName: "Condition",
|
|
478
|
+
operator:"Ends with",
|
|
479
|
+
filterValue: "ir",
|
|
480
|
+
searchInputIndex: 1,
|
|
481
|
+
},
|
|
482
|
+
|
|
483
|
+
multiple: true,
|
|
484
|
+
hasApplyButton: true,
|
|
485
|
+
});
|
|
486
|
+
|
|
487
|
+
cy.get(agGridSelector)
|
|
488
|
+
.getAgGridData()
|
|
489
|
+
.then((actualTableData) => {
|
|
490
|
+
cy.agGridValidateRowsSubset(actualTableData, expectedTableData);
|
|
491
|
+
});
|
|
492
|
+
});
|
|
420
493
|
});
|
|
421
494
|
|
|
422
495
|
function removePropertyFromCollection(expectedTableData, columnsToExclude) {
|
|
@@ -504,4 +577,4 @@ function removePropertyFromCollection(expectedTableData, columnsToExclude) {
|
|
|
504
577
|
// .then(() => {
|
|
505
578
|
// return paginatedTableData;
|
|
506
579
|
// });
|
|
507
|
-
// }
|
|
580
|
+
// }
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
[
|
|
2
|
-
{ "Year": "2020", "Make": "Toyota", "Model": "Celica", "Price": "35000" },
|
|
3
|
-
{ "Year": "2020", "Make": "Ford", "Model": "Mondeo", "Price": "32000" },
|
|
4
|
-
{ "Year": "2020", "Make": "Porsche", "Model": "Boxter", "Price": "72000" },
|
|
5
|
-
{ "Year": "2020", "Make": "BMW", "Model": "3-series", "Price": "45000" },
|
|
6
|
-
{ "Year": "2020", "Make": "Mercedes", "Model": "GLC300", "Price": "53000" },
|
|
7
|
-
{ "Year": "2020", "Make": "Honda", "Model": "Civic", "Price": "22000" },
|
|
8
|
-
{ "Year": "2020", "Make": "Honda", "Model": "Accord", "Price": "32000" },
|
|
9
|
-
{ "Year": "2020", "Make": "Ford", "Model": "Taurus", "Price": "19000" },
|
|
10
|
-
{ "Year": "2020", "Make": "Hyundai", "Model": "Elantra", "Price": "22000" },
|
|
11
|
-
{ "Year": "2020", "Make": "Toyota", "Model": "Celica", "Price": "5000" },
|
|
12
|
-
{ "Year": "2020", "Make": "Ford", "Model": "Mondeo", "Price": "25000" },
|
|
13
|
-
{ "Year": "2020", "Make": "Porsche", "Model": "Boxter", "Price": "99000" },
|
|
14
|
-
{ "Year": "2020", "Make": "BMW", "Model": "3-series", "Price": "32000" },
|
|
15
|
-
{ "Year": "2020", "Make": "Mercedes", "Model": "GLC300", "Price": "35000" },
|
|
16
|
-
{ "Year": "2011", "Make": "Honda", "Model": "Civic", "Price": "9000" },
|
|
17
|
-
{ "Year": "2020", "Make": "Honda", "Model": "Accord", "Price": "34000" },
|
|
18
|
-
{ "Year": "1990", "Make": "Ford", "Model": "Taurus", "Price": "900" },
|
|
19
|
-
{ "Year": "2020", "Make": "Hyundai", "Model": "Elantra", "Price": "3000" },
|
|
20
|
-
{ "Year": "2020", "Make": "BMW", "Model": "2002", "Price": "88001" }
|
|
21
|
-
]
|
|
2
|
+
{ "Year": "2020", "Make": "Toyota", "Model": "Celica", "Condition": "fair", "Price": "35000" },
|
|
3
|
+
{ "Year": "2020", "Make": "Ford", "Model": "Mondeo", "Condition": "excellent", "Price": "32000" },
|
|
4
|
+
{ "Year": "2020", "Make": "Porsche", "Model": "Boxter", "Condition": "good", "Price": "72000" },
|
|
5
|
+
{ "Year": "2020", "Make": "BMW", "Model": "3-series", "Condition": "fair", "Price": "45000" },
|
|
6
|
+
{ "Year": "2020", "Make": "Mercedes", "Model": "GLC300", "Condition": "good", "Price": "53000" },
|
|
7
|
+
{ "Year": "2020", "Make": "Honda", "Model": "Civic", "Condition": "poor", "Price": "22000" },
|
|
8
|
+
{ "Year": "2020", "Make": "Honda", "Model": "Accord", "Condition": "poor", "Price": "32000" },
|
|
9
|
+
{ "Year": "2020", "Make": "Ford", "Model": "Taurus", "Condition": "excellent", "Price": "19000" },
|
|
10
|
+
{ "Year": "2020", "Make": "Hyundai", "Model": "Elantra", "Condition": "good", "Price": "22000" },
|
|
11
|
+
{ "Year": "2020", "Make": "Toyota", "Model": "Celica", "Condition": "poor", "Price": "5000" },
|
|
12
|
+
{ "Year": "2020", "Make": "Ford", "Model": "Mondeo", "Condition": "good", "Price": "25000" },
|
|
13
|
+
{ "Year": "2020", "Make": "Porsche", "Model": "Boxter", "Condition": "good", "Price": "99000" },
|
|
14
|
+
{ "Year": "2020", "Make": "BMW", "Model": "3-series", "Condition": "poor", "Price": "32000" },
|
|
15
|
+
{ "Year": "2020", "Make": "Mercedes", "Model": "GLC300", "Condition": "excellent", "Price": "35000" },
|
|
16
|
+
{ "Year": "2011", "Make": "Honda", "Model": "Civic", "Condition": "good", "Price": "9000" },
|
|
17
|
+
{ "Year": "2020", "Make": "Honda", "Model": "Accord", "Condition": "good", "Price": "34000" },
|
|
18
|
+
{ "Year": "1990", "Make": "Ford", "Model": "Taurus", "Condition": "excellent", "Price": "900" },
|
|
19
|
+
{ "Year": "2020", "Make": "Hyundai", "Model": "Elantra", "Condition": "fair", "Price": "3000" },
|
|
20
|
+
{ "Year": "2020", "Make": "BMW", "Model": "2002", "Condition": "excellent", "Price": "88001" }
|
|
21
|
+
]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cypress-ag-grid",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.4",
|
|
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": "^13.3.0"
|
|
28
28
|
}
|
|
29
29
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="cypress" />
|
|
2
2
|
import { sort } from "./sort.enum";
|
|
3
3
|
import { filterTab } from "./menuTab.enum";
|
|
4
|
+
import { filterOperator } from "./filterOperator.enum";
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Uses the attribute value's index and sorts the data accordingly.
|
|
@@ -37,7 +38,7 @@ export const getAgGridElements = (agGridElement, options = {}) => {
|
|
|
37
38
|
|
|
38
39
|
function _getAgGrid(agGridElement, options = {}, returnElements) {
|
|
39
40
|
const agGridColumnSelectors =
|
|
40
|
-
".ag-pinned-left-cols-container^.ag-center-cols-clipper^.ag-pinned-right-cols-container";
|
|
41
|
+
".ag-pinned-left-cols-container^.ag-center-cols-clipper^.ag-center-cols-viewport^.ag-pinned-right-cols-container";
|
|
41
42
|
if (agGridElement.get().length > 1)
|
|
42
43
|
throw new Error(
|
|
43
44
|
`Selector "${agGridElement.selector}" returned more than 1 element.`
|
|
@@ -150,20 +151,26 @@ function getColumnHeaderElement(agGridElement, columnName) {
|
|
|
150
151
|
* @returns
|
|
151
152
|
*/
|
|
152
153
|
export function sortColumnBy(agGridElement, columnName, sortDirection) {
|
|
154
|
+
if(sortDirection.toLowerCase() === "ascending"){
|
|
155
|
+
sortDirection = "asc"
|
|
156
|
+
}else if(sortDirection.toLowerCase() === "descending"){
|
|
157
|
+
sortDirection = "desc"
|
|
158
|
+
}
|
|
159
|
+
|
|
153
160
|
if (sortDirection === sort.ascending || sortDirection === sort.descending) {
|
|
154
161
|
return getColumnHeaderElement(agGridElement, columnName)
|
|
155
|
-
.parents(".ag-header-cell")
|
|
156
|
-
.invoke("attr", "
|
|
162
|
+
.parents(".ag-header-cell .ag-cell-label-container")
|
|
163
|
+
.invoke("attr", "class")
|
|
157
164
|
.then((value) => {
|
|
158
165
|
cy.log(`sort: ${sortDirection}`);
|
|
159
|
-
if
|
|
166
|
+
if(!value.includes(`ag-header-cell-sorted-${sortDirection}`)){
|
|
160
167
|
getColumnHeaderElement(agGridElement, columnName).click().wait(250);
|
|
161
168
|
sortColumnBy(agGridElement, columnName, sortDirection);
|
|
162
169
|
}
|
|
163
170
|
});
|
|
164
171
|
} else {
|
|
165
172
|
throw new Error(
|
|
166
|
-
"sortDirection must be either '
|
|
173
|
+
"sortDirection must be either 'asc' or 'desc'."
|
|
167
174
|
);
|
|
168
175
|
}
|
|
169
176
|
}
|
|
@@ -243,10 +250,12 @@ function getFilterColumnButtonElement(
|
|
|
243
250
|
if (!noMenuTabs) {
|
|
244
251
|
selectMenuTab(agGridElement, filterTab.filter);
|
|
245
252
|
}
|
|
253
|
+
|
|
246
254
|
if (operator) {
|
|
247
255
|
cy.get(agGridElement)
|
|
248
256
|
.find(".ag-picker-field-wrapper")
|
|
249
257
|
.filter(":visible")
|
|
258
|
+
.eq(searchInputIndex)
|
|
250
259
|
.click();
|
|
251
260
|
cy.get(agGridElement)
|
|
252
261
|
.find(".ag-popup")
|
|
@@ -276,13 +285,15 @@ function getFilterColumnButtonElement(
|
|
|
276
285
|
}
|
|
277
286
|
|
|
278
287
|
// Get the saved filter input and enter the search term
|
|
279
|
-
|
|
280
|
-
cy.
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
288
|
+
if(operator !== filterOperator.blank && operator !== filterOperator.notBlank){
|
|
289
|
+
cy.get("@filterInput").then(($ele)=>{
|
|
290
|
+
cy.wrap($ele)
|
|
291
|
+
.eq(searchInputIndex)
|
|
292
|
+
.clear()
|
|
293
|
+
.type(filterValue)
|
|
294
|
+
.wait(500);
|
|
295
|
+
})
|
|
296
|
+
}
|
|
286
297
|
|
|
287
298
|
// Finally, if a multi-filter, select the filter value's checkbox
|
|
288
299
|
if(isMultiFilter){
|
|
@@ -335,19 +346,9 @@ function populateSearchCriteria(
|
|
|
335
346
|
selectAllLocaleText = 'Select All'
|
|
336
347
|
) {
|
|
337
348
|
const options = {};
|
|
338
|
-
|
|
339
|
-
options.searchCriteria = {};
|
|
340
|
-
//@ts-ignore
|
|
341
|
-
options.searchCriteria.columnName = searchCriteria.columnName;
|
|
342
|
-
//@ts-ignore
|
|
343
|
-
options.searchCriteria.filterValue = searchCriteria.filterValue;
|
|
344
|
-
//@ts-ignore
|
|
345
|
-
options.searchCriteria.isMultiFilter = searchCriteria.isMultiFilter;
|
|
346
|
-
//@ts-ignore
|
|
349
|
+
options.searchCriteria = {...searchCriteria};
|
|
347
350
|
options.selectAllLocaleText = selectAllLocaleText;
|
|
348
|
-
//@ts-ignore
|
|
349
351
|
options.hasApplyButton = hasApplyButton;
|
|
350
|
-
//@ts-ignore
|
|
351
352
|
options.noMenuTabs = noMenuTabs;
|
|
352
353
|
return options;
|
|
353
354
|
}
|
package/src/agGrid/sort.enum.js
CHANGED