cypress-ag-grid 3.3.2 → 3.3.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.
@@ -0,0 +1,842 @@
1
+ /// <reference types="cypress" />
2
+
3
+ import { sort } from "../../../src/agGrid/sort.enum";
4
+ import {
5
+ deleteKey,
6
+ sortedCollectionByProperty,
7
+ } from "../../../src/helpers/arrayHelpers";
8
+ import { filterOperator } from "../../../src/agGrid/filterOperator.enum";
9
+
10
+ const pageSize = 5;
11
+ const agGridSelector = "#myGrid";
12
+ const expectedPaginatedTableData = [
13
+ [
14
+ { Year: "2020", Make: "Toyota", Model: "Celica", Condition: "fair", Price: "35000" },
15
+ { Year: "2020", Make: "Ford", Model: "Mondeo", Condition: "excellent", Price: "32000" },
16
+ { Year: "2020", Make: "Porsche", Model: "Boxter", Condition: "good", Price: "72000" },
17
+ { Year: "2020", Make: "BMW", Model: "3-series", Condition: "fair", Price: "45000" },
18
+ { Year: "2020", Make: "Mercedes", Model: "GLC300", Condition: "good", Price: "53000" },
19
+ ],
20
+ [
21
+ { Year: "2020", Make: "Honda", Model: "Civic", Condition: "poor", Price: "22000" },
22
+ { Year: "2020", Make: "Honda", Model: "Accord", Condition: "poor", Price: "32000" },
23
+ { Year: "2020", Make: "Ford", Model: "Taurus", Condition: "excellent", Price: "19000" },
24
+ { Year: "2020", Make: "Hyundai", Model: "Elantra", Condition: "good", Price: "22000" },
25
+ { Year: "2020", Make: "Toyota", Model: "Celica", Condition: "poor", Price: "5000" },
26
+ ],
27
+ [
28
+ { Year: "2020", Make: "Ford", Model: "Mondeo", Condition: "good", Price: "25000" },
29
+ { Year: "2020", Make: "Porsche", Model: "Boxter", Condition: "good", Price: "99000" },
30
+ { Year: "2020", Make: "BMW", Model: "3-series", Condition: "poor", Price: "32000" },
31
+ { Year: "2020", Make: "Mercedes", Model: "GLC300", Condition: "excellent", Price: "35000" },
32
+ { Year: "2011", Make: "Honda", Model: "Civic", Condition: "good", Price: "9000" },
33
+ ],
34
+ [
35
+ { Year: "2020", Make: "Honda", Model: "Accord", Condition: "good", Price: "34000" },
36
+ { Year: "1990", Make: "Ford", Model: "Taurus", Condition: "excellent", Price: "900" },
37
+ { Year: "2020", Make: "Hyundai", Model: "Elantra", Condition: "fair", Price: "3000" },
38
+ { Year: "2020", Make: "BMW", Model: "2002", Condition: "excellent", Price: "88001" },
39
+ { Year: "2023", Make: "Hyundai", Model: "Santa Fe", Condition: "excellent", Price: "" },
40
+ ],
41
+ ];
42
+
43
+ export function runAgGridDataSuite({ pagePath, versionLabel }) {
44
+ describe(`ag-grid get data scenarios (${versionLabel})`, () => {
45
+ beforeEach(() => {
46
+ cy.visit(pagePath);
47
+ cy.contains(".example-version", `AG Grid ${versionLabel}`).should("be.visible");
48
+ cy.get(".ag-cell", { timeout: 10000 }).should("be.visible");
49
+ cy.get("#floating").click();
50
+ });
51
+
52
+ it("verify paginated table data - any order - include all columns", () => {
53
+ cy.get(agGridSelector).agGridValidatePaginatedTable(
54
+ expectedPaginatedTableData
55
+ );
56
+ });
57
+
58
+ it("verify paginated table data - exact order - include all columns", () => {
59
+ cy.get(agGridSelector)
60
+ .getAgGridData()
61
+ .then((actualTableData) => {
62
+ cy.agGridValidateRowsExactOrder(actualTableData, expectedPaginatedTableData[0]);
63
+ });
64
+ });
65
+
66
+ it("verify exact order table data when columns are not in order - include all columns", () => {
67
+ cy.get(agGridSelector).agGridPinColumn("Price", "left");
68
+
69
+ cy.get(agGridSelector)
70
+ .getAgGridData()
71
+ .then((actualTableData) => {
72
+ cy.agGridValidateRowsExactOrder(actualTableData, expectedPaginatedTableData[0]);
73
+ });
74
+ });
75
+
76
+ it("verify paginated table data - excluding columns", () => {
77
+ const expectedSubset = [
78
+ [
79
+ { Year: "2020", Make: "Toyota", Model: "Celica" },
80
+ { Year: "2020", Make: "Ford", Model: "Mondeo" },
81
+ { Year: "2020", Make: "Porsche", Model: "Boxter" },
82
+ { Year: "2020", Make: "BMW", Model: "3-series" },
83
+ { Year: "2020", Make: "Mercedes", Model: "GLC300" },
84
+ ],
85
+ [
86
+ { Year: "2020", Make: "Honda", Model: "Civic" },
87
+ { Year: "2020", Make: "Honda", Model: "Accord" },
88
+ { Year: "2020", Make: "Ford", Model: "Taurus" },
89
+ { Year: "2020", Make: "Hyundai", Model: "Elantra" },
90
+ { Year: "2020", Make: "Toyota", Model: "Celica" },
91
+ ],
92
+ [
93
+ { Year: "2020", Make: "Ford", Model: "Mondeo" },
94
+ { Year: "2020", Make: "Porsche", Model: "Boxter" },
95
+ { Year: "2020", Make: "BMW", Model: "3-series" },
96
+ { Year: "2020", Make: "Mercedes", Model: "GLC300" },
97
+ { Year: "2011", Make: "Honda", Model: "Civic" },
98
+ ],
99
+ [
100
+ { Year: "2020", Make: "Honda", Model: "Accord" },
101
+ { Year: "1990", Make: "Ford", Model: "Taurus" },
102
+ { Year: "2020", Make: "Hyundai", Model: "Elantra" },
103
+ { Year: "2020", Make: "BMW", Model: "2002" },
104
+ { Year: "2023", Make: "Hyundai", Model: "Santa Fe" },
105
+ ],
106
+ ];
107
+
108
+ cy.get(agGridSelector).agGridValidatePaginatedTable(expectedSubset, {
109
+ onlyColumns: ["Year", "Make", "Model"],
110
+ });
111
+ });
112
+
113
+ it("able to filter by checkbox", () => {
114
+ const expectedTableData = [
115
+ { Year: "2020", Make: "BMW", Model: "2002", Condition: "excellent", Price: "88001" },
116
+ ];
117
+ cy.get(agGridSelector).agGridColumnFilterTextFloating({
118
+ searchCriteria: {
119
+ columnName: "Model",
120
+ filterValue: "2002",
121
+ },
122
+ selectAllLocaleText: "(Select All)",
123
+ hasApplyButton: true,
124
+ });
125
+ cy.get(agGridSelector)
126
+ .getAgGridData()
127
+ .then((actualTableData) => {
128
+ cy.agGridValidateRowsExactOrder(actualTableData, expectedTableData);
129
+ });
130
+ });
131
+
132
+ it("able to filter by checkbox - multiple columns", () => {
133
+ cy.get("#nonFloating").click();
134
+ const expectedTableData = [
135
+ { Year: "2020", Make: "BMW", Model: "3-series", Condition: "fair", Price: "45000" },
136
+ { Year: "2020", Make: "BMW", Model: "3-series", Condition: "poor", Price: "32000" },
137
+ { Year: "2020", Make: "BMW", Model: "2002", Condition: "excellent", Price: "88001" },
138
+ ];
139
+
140
+ cy.get(agGridSelector).agGridColumnFilterCheckboxMenu({
141
+ searchCriteria: [
142
+ {
143
+ columnName: "Model",
144
+ filterValue: "2002",
145
+ },
146
+ {
147
+ columnName: "Model",
148
+ filterValue: "3-series",
149
+ },
150
+ ],
151
+ hasApplyButton: true,
152
+ });
153
+ cy.get(agGridSelector)
154
+ .getAgGridData()
155
+ .then((actualTableData) => {
156
+ cy.agGridValidateRowsExactOrder(actualTableData, expectedTableData, true);
157
+ });
158
+ });
159
+
160
+ it("able to filter by text - menu", () => {
161
+ const expectedTableData = [
162
+ { Year: "2020", Make: "BMW", Model: "3-series", Condition: "poor", Price: "32000" },
163
+ { Year: "2020", Make: "Honda", Model: "Accord", Condition: "poor", Price: "32000" },
164
+ { Year: "2020", Make: "Ford", Model: "Mondeo", Condition: "excellent", Price: "32000" },
165
+ ];
166
+ cy.get(agGridSelector).agGridSortColumn("Model", sort.ascending);
167
+ cy.get(agGridSelector).agGridColumnFilterTextMenu({
168
+ searchCriteria: {
169
+ columnName: "Price",
170
+ filterValue: "32000",
171
+ operator: filterOperator.equals,
172
+ },
173
+ hasApplyButton: true,
174
+ });
175
+ cy.get(agGridSelector)
176
+ .getAgGridData()
177
+ .then((actualTableData) => {
178
+ cy.agGridValidateRowsExactOrder(actualTableData, expectedTableData);
179
+ });
180
+ });
181
+
182
+ it("able to filter by text - menu - multiple columns", () => {
183
+ cy.get("#nonFloating").click();
184
+ const expectedTableData = [
185
+ { Year: "2020", Make: "BMW", Model: "3-series", Condition: "poor", Price: "32000" },
186
+ ];
187
+ cy.get(agGridSelector).agGridSortColumn("Model", sort.ascending);
188
+ cy.get(agGridSelector).agGridColumnFilterTextMenu({
189
+ searchCriteria: [
190
+ {
191
+ columnName: "Price",
192
+ filterValue: "32000",
193
+ operator: filterOperator.equals,
194
+ },
195
+ {
196
+ columnName: "Make",
197
+ filterValue: "BMW",
198
+ operator: filterOperator.equals,
199
+ },
200
+ ],
201
+ hasApplyButton: true,
202
+ });
203
+ cy.get(agGridSelector)
204
+ .getAgGridData()
205
+ .then((actualTableData) => {
206
+ cy.agGridValidateRowsExactOrder(actualTableData, expectedTableData);
207
+ });
208
+ });
209
+
210
+ it("able to filter by text - menu - contains operator", () => {
211
+ const expectedTableData = [
212
+ { Year: "2020", Make: "Ford", Model: "Mondeo", Condition: "excellent", Price: "32000" },
213
+ { Year: "2020", Make: "Ford", Model: "Mondeo", Condition: "good", Price: "25000" },
214
+ { Year: "2020", Make: "Ford", Model: "Taurus", Condition: "excellent", Price: "19000" },
215
+ { Year: "1990", Make: "Ford", Model: "Taurus", Condition: "excellent", Price: "900" },
216
+ ];
217
+
218
+ cy.get(agGridSelector).agGridSortColumn("Model", sort.ascending);
219
+ cy.get(agGridSelector).agGridColumnFilterTextFloating({
220
+ searchCriteria: {
221
+ columnName: "Make",
222
+ filterValue: "ord",
223
+ operator: filterOperator.contains,
224
+ floatingFilter: true,
225
+ },
226
+ hasApplyButton: true,
227
+ });
228
+
229
+ cy.get(agGridSelector)
230
+ .getAgGridData()
231
+ .then((actualTableData) => {
232
+ cy.agGridValidateRowsExactOrder(actualTableData, expectedTableData);
233
+ });
234
+ });
235
+
236
+ it("able to filter by text - menu - does not contain operator", () => {
237
+ cy.get(agGridSelector).agGridColumnFilterTextFloating({
238
+ searchCriteria: {
239
+ columnName: "Make",
240
+ filterValue: "ord",
241
+ operator: filterOperator.notContains,
242
+ },
243
+ hasApplyButton: true,
244
+ });
245
+
246
+ cy.get(agGridSelector)
247
+ .getAgGridData()
248
+ .then((actualTableData) => {
249
+ expect(actualTableData.length).to.be.greaterThan(0);
250
+ actualTableData.forEach((row) => {
251
+ expect(row.Make).to.not.contain("ord");
252
+ });
253
+ });
254
+ });
255
+
256
+ it("able to filter by text - menu - does not equal operator", () => {
257
+ cy.get(agGridSelector).agGridColumnFilterTextFloating({
258
+ searchCriteria: {
259
+ columnName: "Make",
260
+ filterValue: "Ford",
261
+ operator: filterOperator.notEquals,
262
+ },
263
+ hasApplyButton: true,
264
+ });
265
+
266
+ cy.get(agGridSelector)
267
+ .getAgGridData()
268
+ .then((actualTableData) => {
269
+ expect(actualTableData.length).to.be.greaterThan(0);
270
+ actualTableData.forEach((row) => {
271
+ expect(row.Make).to.not.equal("Ford");
272
+ });
273
+ });
274
+ });
275
+
276
+ it("able to filter by text - menu - less than operator", () => {
277
+ enableMileageNumberFilter();
278
+
279
+ cy.get(agGridSelector).agGridColumnFilterTextMenu({
280
+ searchCriteria: {
281
+ columnName: "Mileage",
282
+ filterValue: "5000",
283
+ operator: filterOperator.lessThan,
284
+ },
285
+ hasApplyButton: true,
286
+ });
287
+
288
+ cy.get(agGridSelector)
289
+ .getAgGridData()
290
+ .then((actualTableData) => {
291
+ expect(getSortedMileage(actualTableData)).to.deep.equal(["250", "1000", "3500", "4500"]);
292
+ });
293
+ });
294
+
295
+ it("able to filter by text - menu - less than or equal operator", () => {
296
+ enableMileageNumberFilter();
297
+
298
+ cy.get(agGridSelector).agGridColumnFilterTextMenu({
299
+ searchCriteria: {
300
+ columnName: "Mileage",
301
+ filterValue: "5000",
302
+ operator: filterOperator.lessThanOrEquals,
303
+ },
304
+ hasApplyButton: true,
305
+ });
306
+
307
+ cy.get(agGridSelector)
308
+ .getAgGridData()
309
+ .then((actualTableData) => {
310
+ expect(getSortedMileage(actualTableData)).to.deep.equal(["250", "1000", "3500", "4500", "5000"]);
311
+ });
312
+ });
313
+
314
+ it("able to filter by text - menu - greater than operator", () => {
315
+ enableMileageNumberFilter();
316
+
317
+ cy.get(agGridSelector).agGridColumnFilterTextMenu({
318
+ searchCriteria: {
319
+ columnName: "Mileage",
320
+ filterValue: "50000",
321
+ operator: filterOperator.greaterThan,
322
+ },
323
+ hasApplyButton: true,
324
+ });
325
+
326
+ cy.get(agGridSelector)
327
+ .getAgGridData()
328
+ .then((actualTableData) => {
329
+ expect(getSortedMileage(actualTableData)).to.deep.equal(["52000", "60000", "70000", "90000"]);
330
+ });
331
+ });
332
+
333
+ it("able to filter by text - menu - greater than or equal operator", () => {
334
+ enableMileageNumberFilter();
335
+
336
+ cy.get(agGridSelector).agGridColumnFilterTextMenu({
337
+ searchCriteria: {
338
+ columnName: "Mileage",
339
+ filterValue: "50000",
340
+ operator: filterOperator.greaterThanOrEquals,
341
+ },
342
+ hasApplyButton: true,
343
+ });
344
+
345
+ cy.get(agGridSelector)
346
+ .getAgGridData()
347
+ .then((actualTableData) => {
348
+ expect(getSortedMileage(actualTableData)).to.deep.equal(["52000", "60000", "70000", "90000"]);
349
+ });
350
+ });
351
+
352
+ it("able to filter by text - floating filter", () => {
353
+ const expectedTableData = [
354
+ { Year: "2020", Make: "Ford", Model: "Mondeo", Condition: "excellent", Price: "32000" },
355
+ { Year: "2020", Make: "Ford", Model: "Mondeo", Condition: "good", Price: "25000" },
356
+ { Year: "2020", Make: "Ford", Model: "Taurus", Condition: "excellent", Price: "19000" },
357
+ { Year: "1990", Make: "Ford", Model: "Taurus", Condition: "excellent", Price: "900" },
358
+ ];
359
+
360
+ cy.get(agGridSelector).agGridSortColumn("Model", sort.ascending);
361
+ cy.get(agGridSelector).agGridColumnFilterTextFloating({
362
+ searchCriteria: {
363
+ columnName: "Make",
364
+ filterValue: "Ford",
365
+ },
366
+ hasApplyButton: true,
367
+ });
368
+ cy.get(agGridSelector)
369
+ .getAgGridData()
370
+ .then((actualTableData) => {
371
+ cy.agGridValidateRowsExactOrder(actualTableData, expectedTableData);
372
+ });
373
+ });
374
+
375
+ it("able to filter by text - floating filter - multiple conditions", () => {
376
+ const expectedTableData = [
377
+ { Year: "2020", Make: "BMW", Model: "2002", Condition: "excellent", Price: "88001" },
378
+ { Year: "2020", Make: "BMW", Model: "3-series", Condition: "fair", Price: "45000" },
379
+ { Year: "2020", Make: "BMW", Model: "3-series", Condition: "poor", Price: "32000" },
380
+ ];
381
+
382
+ cy.get(agGridSelector).agGridSortColumn("Model", sort.ascending);
383
+ cy.get(agGridSelector).agGridColumnFilterTextFloating({
384
+ searchCriteria: {
385
+ columnName: "Make",
386
+ filterValue: "B",
387
+ searchInputIndex: 0,
388
+ },
389
+ hasApplyButton: true,
390
+ });
391
+ cy.get(agGridSelector).agGridColumnFilterTextFloating({
392
+ searchCriteria: {
393
+ columnName: "Make",
394
+ filterValue: "MW",
395
+ searchInputIndex: 1,
396
+ },
397
+ hasApplyButton: true,
398
+ });
399
+ cy.get(agGridSelector)
400
+ .getAgGridData()
401
+ .then((actualTableData) => {
402
+ cy.agGridValidateRowsExactOrder(actualTableData, expectedTableData);
403
+ });
404
+ });
405
+
406
+ it("able to filter by text - floating filter - multiple columns", () => {
407
+ const expectedTableData = [
408
+ { Year: "1990", Make: "Ford", Model: "Taurus", Condition: "excellent", Price: "900" },
409
+ ];
410
+ cy.get(agGridSelector).agGridSortColumn("Model", sort.ascending);
411
+ cy.get(agGridSelector).agGridColumnFilterTextFloating({
412
+ searchCriteria: [
413
+ {
414
+ columnName: "Make",
415
+ filterValue: "Ford",
416
+ },
417
+ {
418
+ columnName: "Year",
419
+ filterValue: "1990",
420
+ },
421
+ ],
422
+ hasApplyButton: true,
423
+ });
424
+ cy.get(agGridSelector)
425
+ .getAgGridData()
426
+ .then((actualTableData) => {
427
+ cy.get(agGridSelector).agGridValidateRowsExactOrder(
428
+ actualTableData,
429
+ expectedTableData
430
+ );
431
+ });
432
+ });
433
+
434
+ it("able to filter by text - floating filter - between operator", () => {
435
+ const expectedTableData = [
436
+ { Year: "2023", Make: "Hyundai", Model: "Santa Fe", Condition: "excellent", Mileage: "250", Price: "" },
437
+ { Year: "2020", Make: "Porsche", Model: "Boxter", Condition: "good", Mileage: "1000", Price: "99000" },
438
+ { Year: "2020", Make: "Hyundai", Model: "Elantra", Condition: "fair", Mileage: "3500", Price: "3000" },
439
+ { Year: "2020", Make: "BMW", Model: "2002", Condition: "excellent", Mileage: "4500", Price: "88001" },
440
+ ];
441
+
442
+ cy.window().then((win) => {
443
+ win.setColumnFilter("mileage", "agNumberColumnFilter", true, false);
444
+ });
445
+ cy.get(".ag-cell").should("be.visible");
446
+
447
+ cy.get(agGridSelector).agGridColumnFilterTextFloating({
448
+ searchCriteria: [
449
+ {
450
+ columnName: "Mileage",
451
+ filterValue: "0",
452
+ operator: filterOperator.inRange,
453
+ },
454
+ {
455
+ columnName: "Mileage",
456
+ filterValue: "5000",
457
+ operator: filterOperator.inRange,
458
+ },
459
+ ],
460
+ hasApplyButton: true,
461
+ });
462
+
463
+ cy.get(agGridSelector)
464
+ .getAgGridData()
465
+ .then((actualTableData) => {
466
+ const sortedActualTableData = [...actualTableData].sort(
467
+ (a, b) => Number(a.Mileage) - Number(b.Mileage)
468
+ );
469
+ const sortedExpectedTableData = [...expectedTableData].sort(
470
+ (a, b) => Number(a.Mileage) - Number(b.Mileage)
471
+ );
472
+
473
+ cy.agGridValidateRowsExactOrder(
474
+ sortedActualTableData,
475
+ sortedExpectedTableData
476
+ );
477
+ });
478
+ });
479
+
480
+ it("able to filter by text - floating filter - between operator with explicit indexes", () => {
481
+ enableMileageNumberFilter(true);
482
+
483
+ if (versionLabel === "v33") {
484
+ cy.get(agGridSelector).agGridColumnFilterTextFloating({
485
+ searchCriteria: [
486
+ {
487
+ columnName: "Mileage",
488
+ filterValue: "0",
489
+ operator: filterOperator.inRange,
490
+ searchInputIndex: 0,
491
+ operatorIndex: 0,
492
+ },
493
+ {
494
+ columnName: "Mileage",
495
+ filterValue: "5000",
496
+ operator: filterOperator.inRange,
497
+ searchInputIndex: 1,
498
+ operatorIndex: 0,
499
+ },
500
+ ],
501
+ hasApplyButton: true,
502
+ });
503
+ } else {
504
+ cy.get(agGridSelector).agGridColumnFilterTextFloating({
505
+ searchCriteria: {
506
+ columnName: "Mileage",
507
+ filterValue: "0",
508
+ operator: filterOperator.inRange,
509
+ searchInputIndex: 0,
510
+ operatorIndex: 0,
511
+ },
512
+ hasApplyButton: true,
513
+ });
514
+
515
+ cy.get(agGridSelector).agGridColumnFilterTextFloating({
516
+ searchCriteria: {
517
+ columnName: "Mileage",
518
+ filterValue: "5000",
519
+ operator: filterOperator.inRange,
520
+ searchInputIndex: 1,
521
+ operatorIndex: 0,
522
+ },
523
+ hasApplyButton: true,
524
+ });
525
+ }
526
+
527
+ cy.get(agGridSelector)
528
+ .getAgGridData()
529
+ .then((actualTableData) => {
530
+ expect(getSortedMileage(actualTableData)).to.deep.equal(["250", "1000", "3500", "4500"]);
531
+ });
532
+ });
533
+
534
+ it("able to filter by text - floating filter - between operator with mixed criteria", () => {
535
+ enableMileageNumberFilter(true);
536
+ cy.get(agGridSelector).agGridColumnFilterTextFloating({
537
+ searchCriteria: [
538
+ {
539
+ columnName: "Mileage",
540
+ filterValue: "0",
541
+ operator: filterOperator.inRange,
542
+ },
543
+ {
544
+ columnName: "Mileage",
545
+ filterValue: "500",
546
+ operator: filterOperator.inRange,
547
+ },
548
+ {
549
+ columnName: "Make",
550
+ filterValue: "Ford",
551
+ },
552
+ ],
553
+ hasApplyButton: true,
554
+ });
555
+
556
+ cy.get(agGridSelector)
557
+ .getAgGridData()
558
+ .then((actualTableData) => {
559
+ cy.agGridValidateEmptyTable(actualTableData);
560
+ });
561
+ });
562
+
563
+ it("able to filter by text - floating filter - between operator without apply button", () => {
564
+ enableMileageNumberFilter(true);
565
+
566
+ cy.get(agGridSelector).agGridColumnFilterTextFloating({
567
+ searchCriteria: [
568
+ {
569
+ columnName: "Mileage",
570
+ filterValue: "0",
571
+ operator: filterOperator.inRange,
572
+ },
573
+ {
574
+ columnName: "Mileage",
575
+ filterValue: "5000",
576
+ operator: filterOperator.inRange,
577
+ },
578
+ ],
579
+ hasApplyButton: false,
580
+ noMenuTabs: true,
581
+ });
582
+
583
+ cy.get(agGridSelector)
584
+ .getAgGridData()
585
+ .then((actualTableData) => {
586
+ expect(getSortedMileage(actualTableData)).to.deep.equal(["250", "1000", "3500", "4500"]);
587
+ });
588
+ });
589
+
590
+ it("able to filter by text - floating filter - multi filter", () => {
591
+ const expectedTableData = [
592
+ { Year: "2020", Make: "Ford", Model: "Taurus", Condition: "excellent", Price: "19000" },
593
+ { Year: "1990", Make: "Ford", Model: "Taurus", Condition: "excellent", Price: "900" },
594
+ ];
595
+ cy.get(agGridSelector).agGridSortColumn("Model", sort.ascending);
596
+ cy.get(agGridSelector).agGridColumnFilterTextFloating({
597
+ searchCriteria: [
598
+ {
599
+ columnName: "Model",
600
+ filterValue: "Taurus",
601
+ isMultiFilter: true,
602
+ },
603
+ ],
604
+ hasApplyButton: true,
605
+ });
606
+ cy.get(agGridSelector)
607
+ .getAgGridData()
608
+ .then((actualTableData) => {
609
+ cy.get(agGridSelector).agGridValidateRowsExactOrder(
610
+ actualTableData,
611
+ expectedTableData
612
+ );
613
+ });
614
+ });
615
+
616
+ it("able to validate empty table", () => {
617
+ cy.get(agGridSelector).agGridColumnFilterTextMenu({
618
+ searchCriteria: {
619
+ columnName: "Price",
620
+ filterValue: "0",
621
+ operator: filterOperator.equals,
622
+ },
623
+ hasApplyButton: true,
624
+ });
625
+ cy.get(agGridSelector)
626
+ .getAgGridData()
627
+ .then((actualTableData) => {
628
+ cy.agGridValidateEmptyTable(actualTableData);
629
+ });
630
+ });
631
+
632
+ it("able to sort by ascending order", () => {
633
+ cy.get(agGridSelector).agGridSortColumn("Make", sort.ascending);
634
+ cy.fixture("cardata").then((carData) => {
635
+ removePropertyFromCollection(carData, ["Mileage"]);
636
+ const expectedDataSortedByAscending = sortedCollectionByProperty(
637
+ carData,
638
+ "Make",
639
+ sort.ascending,
640
+ pageSize
641
+ );
642
+ cy.get(agGridSelector)
643
+ .getAgGridData()
644
+ .then((actualTableData) => {
645
+ cy.agGridValidateRowsExactOrder(
646
+ actualTableData,
647
+ expectedDataSortedByAscending
648
+ );
649
+ });
650
+ });
651
+ });
652
+
653
+ it("able to sort by descending order", () => {
654
+ cy.get(agGridSelector).agGridSortColumn("Make", sort.descending);
655
+ cy.fixture("cardata").then((carData) => {
656
+ removePropertyFromCollection(carData, ["Mileage"]);
657
+ const expectedDataSortedByDescending = sortedCollectionByProperty(
658
+ carData,
659
+ "Make",
660
+ sort.descending,
661
+ pageSize
662
+ );
663
+ cy.get(agGridSelector)
664
+ .getAgGridData()
665
+ .then((actualTableData) => {
666
+ cy.agGridValidateRowsExactOrder(
667
+ actualTableData,
668
+ expectedDataSortedByDescending
669
+ );
670
+ });
671
+ });
672
+ });
673
+
674
+ it("remove column from grid and verify select column data", () => {
675
+ cy.get(agGridSelector).agGridToggleColumnsSideBar("Year", true);
676
+ cy.fixture("cardata").then((expectedTableData) => {
677
+ removePropertyFromCollection(expectedTableData, ["Mileage"]);
678
+ const expectedDataYearColumnRemoved = removePropertyFromCollection(
679
+ expectedTableData,
680
+ ["Year"]
681
+ );
682
+ cy.get(agGridSelector)
683
+ .getAgGridData()
684
+ .then((actualTableData) => {
685
+ cy.agGridValidateRowsExactOrder(
686
+ actualTableData,
687
+ expectedDataYearColumnRemoved.slice(0, pageSize)
688
+ );
689
+ });
690
+ });
691
+ });
692
+
693
+ it("remove single pinned column from grid and verify select column data", () => {
694
+ cy.get(agGridSelector).agGridToggleColumnsSideBar("Price", true);
695
+ cy.fixture("cardata").then((expectedTableData) => {
696
+ removePropertyFromCollection(expectedTableData, ["Mileage"]);
697
+ const expectedDataPriceColumnRemoved = removePropertyFromCollection(
698
+ expectedTableData,
699
+ ["Price"]
700
+ );
701
+
702
+ cy.get(agGridSelector)
703
+ .getAgGridData()
704
+ .then((actualTableData) => {
705
+ cy.agGridValidateRowsExactOrder(
706
+ actualTableData,
707
+ expectedDataPriceColumnRemoved.slice(0, pageSize)
708
+ );
709
+ });
710
+ });
711
+ });
712
+
713
+ it("remove multiple columns from grid and verify select column data", () => {
714
+ cy.get(agGridSelector).agGridToggleColumnsSideBar("Price", true);
715
+ cy.get(agGridSelector).agGridToggleColumnsSideBar("Make", true);
716
+ cy.fixture("cardata").then((expectedTableData) => {
717
+ removePropertyFromCollection(expectedTableData, ["Mileage"]);
718
+ const expectedDataMultipleColumnsRemoved = removePropertyFromCollection(
719
+ expectedTableData,
720
+ ["Price", "Make"]
721
+ );
722
+ cy.get(agGridSelector)
723
+ .getAgGridData()
724
+ .then((actualTableData) => {
725
+ cy.agGridValidateRowsExactOrder(
726
+ actualTableData,
727
+ expectedDataMultipleColumnsRemoved.slice(0, pageSize)
728
+ );
729
+ });
730
+ });
731
+ });
732
+
733
+ it("only validate select column data", () => {
734
+ const expectedTableData = [
735
+ { Year: "2020", Make: "Toyota", Model: "Celica" },
736
+ { Year: "2020", Make: "Ford", Model: "Mondeo" },
737
+ { Year: "2020", Make: "Porsche", Model: "Boxter" },
738
+ { Year: "2020", Make: "BMW", Model: "3-series" },
739
+ { Year: "2020", Make: "Mercedes", Model: "GLC300" },
740
+ ];
741
+ cy.get(agGridSelector)
742
+ .getAgGridData({ onlyColumns: ["Year", "Make", "Model"] })
743
+ .then((actualTableData) => {
744
+ cy.agGridValidateRowsSubset(actualTableData, expectedTableData);
745
+ });
746
+ });
747
+
748
+ it("able to filter by 'Blank'", () => {
749
+ const expectedTableData = [
750
+ { Year: "2023", Make: "Hyundai", Model: "Santa Fe", Condition: "excellent", Price: "" },
751
+ ];
752
+
753
+ cy.get(agGridSelector).agGridColumnFilterTextMenu({
754
+ searchCriteria: {
755
+ columnName: "Price",
756
+ operator: filterOperator.blank,
757
+ },
758
+ hasApplyButton: true,
759
+ });
760
+ cy.get(agGridSelector)
761
+ .getAgGridData()
762
+ .then((actualTableData) => {
763
+ cy.agGridValidateRowsSubset(actualTableData, expectedTableData);
764
+ });
765
+ });
766
+
767
+ it("able to filter by 'Not blank'", () => {
768
+ cy.get(agGridSelector).agGridColumnFilterTextMenu({
769
+ searchCriteria: {
770
+ columnName: "Price",
771
+ operator: filterOperator.notBlank,
772
+ },
773
+ hasApplyButton: true,
774
+ });
775
+ cy.get(agGridSelector)
776
+ .getAgGridData()
777
+ .then((actualTableData) => {
778
+ expect(actualTableData.length).to.be.greaterThan(0);
779
+ actualTableData.forEach((row) => {
780
+ expect(row.Price).to.not.equal("");
781
+ });
782
+ });
783
+ });
784
+
785
+ it("able to filter by agTextColumnFilter with join operator", () => {
786
+ const expectedTableData = [
787
+ { Year: "2020", Make: "Toyota", Model: "Celica", Condition: "fair", Price: "35000" },
788
+ { Year: "2020", Make: "BMW", Model: "3-series", Condition: "fair", Price: "45000" },
789
+ { Year: "2020", Make: "Hyundai", Model: "Elantra", Condition: "fair", Price: "3000" },
790
+ ];
791
+ cy.get(agGridSelector).agGridColumnFilterTextFloating({
792
+ searchCriteria: {
793
+ columnName: "Condition",
794
+ operator: filterOperator.startsWith,
795
+ filterValue: "f",
796
+ searchInputIndex: 0,
797
+ },
798
+ multiple: true,
799
+ hasApplyButton: true,
800
+ });
801
+
802
+ cy.get(agGridSelector).agGridColumnFilterTextFloating({
803
+ searchCriteria: {
804
+ columnName: "Condition",
805
+ operator: filterOperator.endsWith,
806
+ filterValue: "ir",
807
+ searchInputIndex: 1,
808
+ },
809
+ multiple: true,
810
+ hasApplyButton: true,
811
+ });
812
+
813
+ cy.get(agGridSelector)
814
+ .getAgGridData()
815
+ .then((actualTableData) => {
816
+ cy.agGridValidateRowsSubset(actualTableData, expectedTableData);
817
+ });
818
+ });
819
+ });
820
+ }
821
+
822
+ function removePropertyFromCollection(expectedTableData, columnsToExclude) {
823
+ if (columnsToExclude) {
824
+ columnsToExclude.forEach((excludedColumn) => {
825
+ expectedTableData.forEach((obj) => deleteKey(obj, excludedColumn));
826
+ });
827
+ }
828
+ return expectedTableData;
829
+ }
830
+
831
+ function enableMileageNumberFilter(floatingFilter = false) {
832
+ cy.window().then((win) => {
833
+ win.setColumnFilter("mileage", "agNumberColumnFilter", floatingFilter, false);
834
+ });
835
+ cy.get(".ag-cell").should("be.visible");
836
+ }
837
+
838
+ function getSortedMileage(actualTableData) {
839
+ return actualTableData
840
+ .map((row) => row.Mileage)
841
+ .sort((a, b) => Number(a) - Number(b));
842
+ }