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.
@@ -1,641 +0,0 @@
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
- describe("ag-grid get data scenarios", () => {
44
- beforeEach(() => {
45
- cy.visit("../app/index.html");
46
- cy.get(".ag-cell", { timeout: 10000 }).should("be.visible");
47
- cy.get('#floating').click()
48
- });
49
-
50
- it("verify paginated table data - any order - include all columns", () => {
51
- cy.get(agGridSelector).agGridValidatePaginatedTable(
52
- expectedPaginatedTableData
53
- );
54
- });
55
-
56
- it("verify paginated table data - exact order - include all columns", () => {
57
- cy.get(agGridSelector)
58
- .getAgGridData()
59
- .then((actualTableData) => {
60
- cy.agGridValidateRowsExactOrder(actualTableData, expectedPaginatedTableData[0]);
61
- });
62
- });
63
-
64
- it("verify exact order table data when columns are not in order - include all columns", () => {
65
- cy.get(agGridSelector).agGridPinColumn('Price', 'left');
66
-
67
- cy.get(agGridSelector)
68
- .getAgGridData()
69
- .then((actualTableData) => {
70
- cy.agGridValidateRowsExactOrder(actualTableData, expectedPaginatedTableData[0]);
71
- });
72
- });
73
-
74
- it("verify paginated table data - excluding columns", () => {
75
- const expectedPaginatedTableData = [
76
- [
77
- { Year: "2020", Make: "Toyota", Model: "Celica" },
78
- { Year: "2020", Make: "Ford", Model: "Mondeo" },
79
- { Year: "2020", Make: "Porsche", Model: "Boxter" },
80
- { Year: "2020", Make: "BMW", Model: "3-series" },
81
- { Year: "2020", Make: "Mercedes", Model: "GLC300" },
82
- ],
83
- [
84
- { Year: "2020", Make: "Honda", Model: "Civic" },
85
- { Year: "2020", Make: "Honda", Model: "Accord" },
86
- { Year: "2020", Make: "Ford", Model: "Taurus" },
87
- { Year: "2020", Make: "Hyundai", Model: "Elantra" },
88
- { Year: "2020", Make: "Toyota", Model: "Celica" },
89
- ],
90
- [
91
- { Year: "2020", Make: "Ford", Model: "Mondeo" },
92
- { Year: "2020", Make: "Porsche", Model: "Boxter" },
93
- { Year: "2020", Make: "BMW", Model: "3-series" },
94
- { Year: "2020", Make: "Mercedes", Model: "GLC300" },
95
- { Year: "2011", Make: "Honda", Model: "Civic" },
96
- ],
97
- [
98
- { Year: "2020", Make: "Honda", Model: "Accord" },
99
- { Year: "1990", Make: "Ford", Model: "Taurus" },
100
- { Year: "2020", Make: "Hyundai", Model: "Elantra" },
101
- { Year: "2020", Make: "BMW", Model: "2002" },
102
- { Year: "2023", Make: "Hyundai", Model: "Santa Fe" },
103
- ],
104
- ];
105
- cy.get(agGridSelector).agGridValidatePaginatedTable(
106
- expectedPaginatedTableData,
107
- {
108
- onlyColumns: ["Year", "Make", "Model"],
109
- }
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)", // This is optional if you are using localText for ag grid
123
- hasApplyButton: true,
124
-
125
- });
126
- cy.get(agGridSelector)
127
- .getAgGridData()
128
- .then((actualTableData) => {
129
- cy.agGridValidateRowsExactOrder(actualTableData, expectedTableData);
130
- });
131
- });
132
-
133
- it("able to filter by checkbox - multiple columns", () => {
134
- cy.get('#nonFloating').click()
135
- const expectedTableData = [
136
- { Year: "2020", Make: "BMW", Model: "3-series", Condition: "fair", Price: "45000" },
137
- { Year: "2020", Make: "BMW", Model: "3-series", Condition: "poor", Price: "32000" },
138
- { Year: "2020", Make: "BMW", Model: "2002", Condition: "excellent", Price: "88001" },
139
- ];
140
-
141
- cy.get(agGridSelector).agGridColumnFilterCheckboxMenu({
142
- searchCriteria: [
143
- {
144
- columnName: "Model",
145
- filterValue: "2002",
146
- },
147
- {
148
- columnName: "Model",
149
- filterValue: "3-series",
150
- },
151
- ],
152
- hasApplyButton: true,
153
- });
154
- cy.get(agGridSelector)
155
- .getAgGridData()
156
- .then((actualTableData) => {
157
- cy.agGridValidateRowsExactOrder(
158
- actualTableData,
159
- expectedTableData,
160
- true
161
- );
162
- });
163
- });
164
-
165
- it("able to filter by text - menu", () => {
166
- const expectedTableData = [
167
- { Year: "2020", Make: "BMW", Model: "3-series", Condition: "poor", Price: "32000" },
168
- { Year: "2020", Make: "Honda", Model: "Accord", Condition: "poor", Price: "32000" },
169
- { Year: "2020", Make: "Ford", Model: "Mondeo", Condition: "excellent", Price: "32000" },
170
- ];
171
- cy.get(agGridSelector).agGridSortColumn("Model", sort.ascending);
172
- cy.get(agGridSelector).agGridColumnFilterTextMenu({
173
- searchCriteria: {
174
- columnName: "Price",
175
- filterValue: "32000",
176
- operator: filterOperator.equals,
177
- },
178
- hasApplyButton: true,
179
- });
180
- cy.get(agGridSelector)
181
- .getAgGridData()
182
- .then((actualTableData) => {
183
- cy.agGridValidateRowsExactOrder(actualTableData, expectedTableData);
184
- });
185
- });
186
-
187
- it("able to filter by text - menu - multiple columns", () => {
188
- cy.get('#nonFloating').click()
189
- const expectedTableData = [
190
- { Year: "2020", Make: "BMW", Model: "3-series", Condition: "poor", Price: "32000" },
191
- ];
192
- cy.get(agGridSelector).agGridSortColumn("Model", sort.ascending);
193
- cy.get(agGridSelector).agGridColumnFilterTextMenu({
194
- searchCriteria: [
195
- {
196
- columnName: "Price",
197
- filterValue: "32000",
198
- operator: filterOperator.equals,
199
- },
200
- {
201
- columnName: "Make",
202
- filterValue: "BMW",
203
- operator: filterOperator.equals,
204
- },
205
- ],
206
- hasApplyButton: true,
207
- });
208
- cy.get(agGridSelector)
209
- .getAgGridData()
210
- .then((actualTableData) => {
211
- cy.agGridValidateRowsExactOrder(actualTableData, expectedTableData);
212
- });
213
- });
214
-
215
- it("able to filter by text - floating filter", () => {
216
- const expectedTableData = [
217
- { Year: "2020", Make: "Ford", Model: "Mondeo", Condition: "excellent", Price: "32000" },
218
- { Year: "2020", Make: "Ford", Model: "Mondeo", Condition: "good", Price: "25000" },
219
- { Year: "2020", Make: "Ford", Model: "Taurus", Condition: "excellent", Price: "19000" },
220
- { Year: "1990", Make: "Ford", Model: "Taurus", Condition: "excellent", Price: "900" },
221
- ];
222
-
223
- cy.get(agGridSelector).agGridSortColumn("Model", sort.ascending);
224
- cy.get(agGridSelector).agGridColumnFilterTextFloating({
225
- searchCriteria: {
226
- columnName: "Make",
227
- filterValue: "Ford",
228
- },
229
- hasApplyButton: true,
230
- });
231
- cy.get(agGridSelector)
232
- .getAgGridData()
233
- .then((actualTableData) => {
234
- cy.agGridValidateRowsExactOrder(actualTableData, expectedTableData);
235
- });
236
- });
237
-
238
- it("able to filter by text - floating filter - multiple conditions", () => {
239
- const expectedTableData = [
240
- { Year: "2020", Make: "BMW", Model: "2002", Condition: "excellent", Price: "88001" },
241
- { Year: "2020", Make: "BMW", Model: "3-series", Condition: "fair", Price: "45000" },
242
- { Year: "2020", Make: "BMW", Model: "3-series", Condition: "poor", Price: "32000" },
243
- ];
244
-
245
- cy.get(agGridSelector).agGridSortColumn("Model", sort.ascending);
246
- cy.get(agGridSelector).agGridColumnFilterTextFloating({
247
- searchCriteria: {
248
- columnName: "Make",
249
- filterValue: "B",
250
- searchInputIndex: 0,
251
- },
252
- hasApplyButton: true,
253
- });
254
- cy.get(agGridSelector).agGridColumnFilterTextFloating({
255
- searchCriteria: {
256
- columnName: "Make",
257
- filterValue: "MW",
258
- searchInputIndex: 1,
259
- },
260
- hasApplyButton: true,
261
- });
262
- cy.get(agGridSelector)
263
- .getAgGridData()
264
- .then((actualTableData) => {
265
- cy.agGridValidateRowsExactOrder(actualTableData, expectedTableData);
266
- });
267
- });
268
-
269
- it("able to filter by text - floating filter - multiple columns", () => {
270
- const expectedTableData = [
271
- { Year: "1990", Make: "Ford", Model: "Taurus", Condition: "excellent", Price: "900" },
272
- ];
273
- cy.get(agGridSelector).agGridSortColumn("Model", sort.ascending);
274
- cy.get(agGridSelector).agGridColumnFilterTextFloating({
275
- searchCriteria: [
276
- {
277
- columnName: "Make",
278
- filterValue: "Ford",
279
- },
280
- {
281
- columnName: "Year",
282
- filterValue: "1990",
283
- },
284
- ],
285
- hasApplyButton: true,
286
- });
287
- cy.get(agGridSelector)
288
- .getAgGridData()
289
- .then((actualTableData) => {
290
- cy.get(agGridSelector).agGridValidateRowsExactOrder(
291
- actualTableData,
292
- expectedTableData
293
- );
294
- });
295
- });
296
-
297
- it("able to filter by text - floating filter - multi filter", () => {
298
- const expectedTableData = [
299
- { Year: "2020", Make: "Ford", Model: "Taurus", Condition: "excellent", Price: "19000" },
300
- { Year: "1990", Make: "Ford", Model: "Taurus", Condition: "excellent", Price: "900" },
301
- ];
302
- cy.get(agGridSelector).agGridSortColumn("Model", sort.ascending);
303
- cy.get(agGridSelector).agGridColumnFilterTextFloating({
304
- searchCriteria: [
305
- {
306
- columnName: "Model",
307
- filterValue: "Taurus",
308
- isMultiFilter: true,
309
- },
310
- ],
311
- hasApplyButton: true,
312
- });
313
- cy.get(agGridSelector)
314
- .getAgGridData()
315
- .then((actualTableData) => {
316
- cy.get(agGridSelector).agGridValidateRowsExactOrder(
317
- actualTableData,
318
- expectedTableData
319
- );
320
- });
321
- });
322
-
323
- it("able to validate empty table", () => {
324
- //Search for an entry that does not exist
325
- cy.get(agGridSelector).agGridColumnFilterTextMenu({
326
- searchCriteria: {
327
- columnName: "Price",
328
- filterValue: "0",
329
- operator: filterOperator.equals,
330
- },
331
- hasApplyButton: true,
332
- });
333
- cy.get(agGridSelector)
334
- .getAgGridData()
335
- .then((actualTableData) => {
336
- cy.agGridValidateEmptyTable(actualTableData);
337
- });
338
- });
339
-
340
- it("able to sort by ascending order", () => {
341
- cy.get(agGridSelector).agGridSortColumn("Make", sort.ascending);
342
- cy.fixture("cardata").then((carData) => {
343
- // This will sort the entirety of our collection by the specified columnName and sort order
344
- // and will return only the # of records specified. In this example, I include only the first
345
- // page of data.
346
- const expectedData_sortedByAscending = sortedCollectionByProperty(
347
- carData,
348
- "Make",
349
- sort.ascending,
350
- _pageSize
351
- );
352
- cy.get(agGridSelector)
353
- .getAgGridData()
354
- .then((actualTableData) => {
355
- cy.agGridValidateRowsExactOrder(
356
- actualTableData,
357
- expectedData_sortedByAscending
358
- );
359
- });
360
- });
361
- });
362
-
363
- it("able to sort by descending order", () => {
364
- cy.get(agGridSelector).agGridSortColumn("Make", sort.descending);
365
- cy.fixture("cardata").then((carData) => {
366
- // This will sort the entirety of our collection by the specified columnName and sort order
367
- // and will return only the # of records specified. In this example, I include only the first
368
- // page of data.
369
- const expectedData_sortedByDescending = sortedCollectionByProperty(
370
- carData,
371
- "Make",
372
- sort.descending,
373
- _pageSize
374
- );
375
- cy.get(agGridSelector)
376
- .getAgGridData()
377
- .then((actualTableData) => {
378
- cy.agGridValidateRowsExactOrder(
379
- actualTableData,
380
- expectedData_sortedByDescending
381
- );
382
- });
383
- });
384
- });
385
-
386
- it("remove column from grid and verify select column data", () => {
387
- cy.get(agGridSelector).agGridToggleColumnsSideBar("Year", true);
388
- cy.fixture("cardata").then((expectedTableData) => {
389
- const expectedData_yearColumnRemoved = removePropertyFromCollection(
390
- expectedTableData,
391
- ["Year"]
392
- );
393
- cy.get(agGridSelector)
394
- .getAgGridData()
395
- .then((actualTableData) => {
396
- cy.agGridValidateRowsExactOrder(
397
- actualTableData,
398
- expectedData_yearColumnRemoved.slice(0, _pageSize)
399
- );
400
- });
401
- });
402
- });
403
-
404
- it("remove single pinned column from grid and verify select column data", () => {
405
- cy.get(agGridSelector).agGridToggleColumnsSideBar("Price", true);
406
- cy.fixture("cardata").then((expectedTableData) => {
407
- const expectedData_priceColumnRemoved = removePropertyFromCollection(
408
- expectedTableData,
409
- ["Price"]
410
- );
411
-
412
- cy.get(agGridSelector)
413
- .getAgGridData()
414
- .then((actualTableData) => {
415
- cy.agGridValidateRowsExactOrder(
416
- actualTableData,
417
- expectedData_priceColumnRemoved.slice(0, _pageSize)
418
- );
419
- });
420
- });
421
- });
422
-
423
- it("remove multiple columns from grid and verify select column data", () => {
424
- cy.get(agGridSelector).agGridToggleColumnsSideBar("Price", true);
425
- cy.get(agGridSelector).agGridToggleColumnsSideBar("Make", true);
426
- cy.fixture("cardata").then((expectedTableData) => {
427
- const expectedData_multipleColumnsRemoved = removePropertyFromCollection(
428
- expectedTableData,
429
- ["Price", "Make"]
430
- );
431
- cy.get(agGridSelector)
432
- .getAgGridData()
433
- .then((actualTableData) => {
434
- cy.agGridValidateRowsExactOrder(
435
- actualTableData,
436
- expectedData_multipleColumnsRemoved.slice(0, _pageSize)
437
- );
438
- });
439
- });
440
- });
441
-
442
- it("only validate select column data", () => {
443
- const expectedTableData = [
444
- { Year: "2020", Make: "Toyota", Model: "Celica" },
445
- { Year: "2020", Make: "Ford", Model: "Mondeo" },
446
- { Year: "2020", Make: "Porsche", Model: "Boxter" },
447
- { Year: "2020", Make: "BMW", Model: "3-series" },
448
- { Year: "2020", Make: "Mercedes", Model: "GLC300" },
449
- ];
450
- cy.get(agGridSelector)
451
- .getAgGridData({ onlyColumns: ["Year", "Make", "Model"] })
452
- .then((actualTableData) => {
453
- cy.agGridValidateRowsSubset(actualTableData, expectedTableData);
454
- });
455
- });
456
-
457
- it("able to filter by 'Blank'", () => {
458
- const expectedTableData = [
459
- { Year: "2023", Make: "Hyundai", Model: "Santa Fe", Condition: "excellent", Price: "" }
460
- ]
461
-
462
- cy.get(agGridSelector).agGridColumnFilterTextMenu({
463
- searchCriteria: {
464
- columnName: "Price",
465
- operator: filterOperator.blank,
466
- },
467
- hasApplyButton: true,
468
- });
469
- cy.get(agGridSelector)
470
- .getAgGridData()
471
- .then((actualTableData) => {
472
- cy.agGridValidateRowsSubset(actualTableData, expectedTableData);
473
- });
474
-
475
- });
476
-
477
- it("able to filter by 'Not blank'", () => {
478
- const expectedTableData = [
479
- { Year: "2020", Make: "Toyota", Model: "Celica", Condition: "fair", Price: "35000" },
480
- { Year: "2020", Make: "Ford", Model: "Mondeo", Condition: "excellent", Price: "32000" },
481
- { Year: "2020", Make: "Porsche", Model: "Boxter", Condition: "good", Price: "72000" },
482
- { Year: "2020", Make: "BMW", Model: "3-series", Condition: "fair", Price: "45000" },
483
- { Year: "2020", Make: "Mercedes", Model: "GLC300", Condition: "good", Price: "53000" },
484
- { Year: "2020", Make: "Honda", Model: "Civic", Condition: "poor", Price: "22000" },
485
- { Year: "2020", Make: "Honda", Model: "Accord", Condition: "poor", Price: "32000" },
486
- { Year: "2020", Make: "Ford", Model: "Taurus", Condition: "excellent", Price: "19000" },
487
- { Year: "2020", Make: "Hyundai", Model: "Elantra", Condition: "good", Price: "22000" },
488
- { Year: "2020", Make: "Toyota", Model: "Celica", Condition: "poor", Price: "5000" },
489
- { Year: "2020", Make: "Ford", Model: "Mondeo", Condition: "good", Price: "25000" },
490
- { Year: "2020", Make: "Porsche", Model: "Boxter", Condition: "good", Price: "99000" },
491
- { Year: "2020", Make: "BMW", Model: "3-series", Condition: "poor", Price: "32000" },
492
- { Year: "2020", Make: "Mercedes", Model: "GLC300", Condition: "excellent", Price: "35000" },
493
- { Year: "2011", Make: "Honda", Model: "Civic", Condition: "good", Price: "9000" },
494
- { Year: "2020", Make: "Honda", Model: "Accord", Condition: "good", Price: "34000" },
495
- { Year: "1990", Make: "Ford", Model: "Taurus", Condition: "excellent", Price: "900" },
496
- { Year: "2020", Make: "Hyundai", Model: "Elantra", Condition: "fair", Price: "3000" },
497
- { Year: "2020", Make: "BMW", Model: "2002", Condition: "excellent", Price: "88001" }
498
- ]
499
-
500
- cy.get('.ag-picker-field-display').eq(0).type('{downArrow}{downArrow}{downArrow}{enter}')
501
-
502
- cy.get(agGridSelector).agGridColumnFilterTextMenu({
503
- searchCriteria: {
504
- columnName: "Price",
505
- operator: filterOperator.notBlank,
506
- },
507
- hasApplyButton: true,
508
- });
509
- cy.get(agGridSelector)
510
- .getAgGridData()
511
- .then((actualTableData) => {
512
- cy.agGridValidateRowsSubset(actualTableData, expectedTableData);
513
- });
514
- });
515
-
516
- it('able to filter by agTextColumnFilter with join operator', () => {
517
- const expectedTableData = [
518
- { Year: "2020", Make: "Toyota", Model: "Celica", Condition: "fair", Price: "35000" },
519
- { Year: "2020", Make: "BMW", Model: "3-series", Condition: "fair", Price: "45000" },
520
- { Year: "2020", Make: "Hyundai", Model: "Elantra", Condition: "fair", Price: "3000" },
521
- ]
522
- cy.get(agGridSelector).agGridColumnFilterTextFloating({
523
- searchCriteria:
524
- {
525
- columnName: "Condition",
526
- operator: filterOperator.startsWith,
527
- filterValue: 'f',
528
- searchInputIndex: 0,
529
- },
530
-
531
- multiple: true,
532
- hasApplyButton: true,
533
- });
534
-
535
- cy.get(agGridSelector).agGridColumnFilterTextFloating({
536
- searchCriteria:
537
- {
538
- columnName: "Condition",
539
- operator: filterOperator.endsWith,
540
- filterValue: "ir",
541
- searchInputIndex: 1,
542
- },
543
-
544
- multiple: true,
545
- hasApplyButton: true,
546
- });
547
-
548
- cy.get(agGridSelector)
549
- .getAgGridData()
550
- .then((actualTableData) => {
551
- cy.agGridValidateRowsSubset(actualTableData, expectedTableData);
552
- });
553
- });
554
- });
555
-
556
- function removePropertyFromCollection(expectedTableData, columnsToExclude) {
557
- //Exclude any specified columns
558
- if (columnsToExclude) {
559
- columnsToExclude.forEach((excludedColumn) => {
560
- expectedTableData.forEach((obj) => deleteKey(obj, excludedColumn));
561
- });
562
- }
563
- return expectedTableData;
564
- }
565
-
566
- // /// THE BELOW METHODS SHOWCASE HOW TO DYNAMICALLY GET THE EXPECTED DATA AND MANIPULATE IT FOR VALIDATION
567
- // /// THIS INCLUDES PAGINATION, FILTERING, and COLUMN EXCLUSION
568
-
569
- // export const carColumns = {
570
- // year: "Year",
571
- // make: "Make",
572
- // model: "Model",
573
- // price: "Price",
574
- // };
575
-
576
- // /**
577
- // * Returns ALL expected table data populated from the expected test data call and does not factor in pagination
578
- // * @param columnsToExclude Provide an array of string values for columns to not return in the data set
579
- // * @param filters a "\^" delimited string of all columns and values to search for in the grid (i.e. "Name=John Smith^Rate Plan=Standard"
580
- // */
581
- // export function getExpectedTableData(columnsToExclude, filters) {
582
- // let table = [];
583
-
584
- // // Get the expected table data from the cardata fixture file and process it with columns exclusions and filters
585
- // return cy
586
- // .fixture("cardata")
587
- // .then((cars) => {
588
- // table = cars;
589
- // })
590
- // .then(() => {
591
- // // Iterate over all filter strings and filter table results in the order in which they are provided
592
- // if (filters) {
593
- // filters.split("^").forEach((filter) => {
594
- // const [key, value] = filter.split("=");
595
- // const getKey = getKeyByValue(carColumns, key);
596
- // table = table.filter((a) => a[getKey].includes(value));
597
- // });
598
- // }
599
- // })
600
- // .then(() => {
601
- // // Update the property key values to match what is represented in the grid for validation purposes
602
- // // (i.e. in this example, we change make to Make, model to Model, and price to Price to match
603
- // // what is shown in the grid headers exactly).
604
- // for (const key in carColumns)
605
- // table.forEach((obj) => renameKey(obj, key, carColumns[key]));
606
-
607
- // //Exclude any specified columns
608
- // if (columnsToExclude) {
609
- // columnsToExclude.forEach((excludedColumn) => {
610
- // table.forEach((obj) => deleteKey(obj, excludedColumn));
611
- // });
612
- // }
613
- // return table;
614
- // });
615
- // }
616
-
617
- // /**
618
- // * Returns ALL expected table data and paginates the data based on the pageSize
619
- // * @param columnsToExclude Provide an array of string values for columns to not return in the data set
620
- // * @param pageSize If no value is provided, default value of 5 items per page is used
621
- // */
622
- // function getExpectedPaginatedTableData(columnsToExclude, pageSize = 5) {
623
- // const paginatedTableData = [];
624
- // // paginates the expected table data, and removes specified column exclusions
625
- // return getExpectedTableData(columnsToExclude)
626
- // .then((tableData) => {
627
- // const pages = Math.floor(tableData.length / pageSize);
628
- // const finalPageCount = tableData.length % pageSize;
629
- // let iterator = 0;
630
- // for (let i = 0; i < pages; i++) {
631
- // paginatedTableData.push(tableData.slice(iterator, iterator + pageSize));
632
- // iterator += pageSize;
633
- // }
634
- // paginatedTableData.push(
635
- // tableData.slice(iterator, iterator + finalPageCount)
636
- // );
637
- // })
638
- // .then(() => {
639
- // return paginatedTableData;
640
- // });
641
- // }