@ministryofjustice/hmpps-digital-prison-reporting-frontend 4.26.4 → 4.26.5

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.
@@ -31,99 +31,99 @@ context('Viewing a report', () => {
31
31
  cy.visit(viewReportUrl)
32
32
  })
33
33
 
34
- // describe('Report details', () => {
35
- // it('should show the report details', () => {
36
- // cy.findAllByRole('group').contains('Report details').should('be.visible').click()
37
-
38
- // cy.findAllByRole('group')
39
- // .contains('Report details')
40
- // .parent()
41
- // .parent()
42
- // .within(() => {
43
- // cy.findAllByRole('row').each((row, index) => {
44
- // cy.wrap(row).within(() => {
45
- // switch (index) {
46
- // case 0:
47
- // cy.findAllByRole('cell', { name: 'Name:' }).should('exist')
48
- // cy.findAllByRole('cell', { name: 'Successful Report' }).should('exist')
49
- // break
50
- // case 1:
51
- // cy.findAllByRole('cell', { name: 'Product:' }).should('exist')
52
- // cy.findAllByRole('cell', { name: 'Successful Report' }).should('exist')
53
- // break
54
- // case 2:
55
- // cy.findAllByRole('cell', { name: 'Description:' }).should('exist')
56
- // cy.findAllByRole('cell', { name: 'this will succeed' }).should('exist')
57
- // break
58
- // case 3:
59
- // cy.findAllByRole('cell', { name: 'Classification:' }).should('exist')
60
- // cy.findAllByRole('cell', { name: 'OFFICIAL' }).should('exist')
61
- // break
62
- // case 4:
63
- // cy.findAllByRole('cell', { name: 'Requested at:' }).should('exist')
64
- // cy.findAllByRole('cell', { name: /\d{1,2}\/\d{1,2}\/\d{2,4}/ }).should('exist')
65
- // break
66
- // case 5:
67
- // cy.findAllByRole('cell', { name: 'Applied Filters:' }).should('exist')
68
- // cy.findAllByRole('listitem').each((item, i) => {
69
- // switch (i) {
70
- // case 0:
71
- // cy.wrap(item).contains('Field 1: value1.2')
72
- // break
73
- // case 1:
74
- // cy.wrap(item).contains('Field 3 start: 01/02/2003')
75
- // break
76
- // case 2:
77
- // cy.wrap(item).contains('Field 3 end: 04/05/2006')
78
- // break
79
- // case 3:
80
- // cy.wrap(item).contains('Field 7: 01/02/2005')
81
- // break
82
- // case 4:
83
- // cy.wrap(item).contains('Field 8: value8.2,value8.3')
84
- // break
85
- // case 5:
86
- // cy.wrap(item).contains('Sort column: Field 1')
87
- // break
88
- // case 6:
89
- // cy.wrap(item).contains('Sort direction: Descending')
90
- // break
91
- // default:
92
- // break
93
- // }
94
- // })
95
- // break
96
- // default:
97
- // break
98
- // }
99
- // })
100
- // })
101
- // })
102
- // })
103
- // })
104
-
105
- // describe('Actions', () => {
106
- // it('should show the actions and go to the filters page when refresh action is clicked', () => {
107
- // cy.findByLabelText('Refresh report').should('be.visible')
108
- // cy.findByLabelText(/download/).should('be.visible')
109
- // cy.findByLabelText(/Copy report link/).should('be.visible')
110
- // cy.findByRole('button', { name: /Add bookmark/ }).should('be.visible')
111
-
112
- // cy.findByLabelText('Refresh report').should('be.visible').click()
113
- // cy.url().should(
114
- // 'match',
115
- // /.*\/embedded\/platform\/dpr\/request-report\/report\/request-examples\/request-example-success\/filters/i,
116
- // )
117
-
118
- // cy.location().should((location) => {
119
- // expect(location.search).to.contain(`filters.field1=value1.2`)
120
- // expect(location.search).to.contain(`filters.field3.start=2003-02-01`)
121
- // expect(location.search).to.contain(`filters.field3.end=2006-05-04`)
122
- // expect(location.search).to.contain(`filters.field7=2005-02-01`)
123
- // expect(location.search).to.contain(`filters.field8=value8.2&filters.field8=value8.3`)
124
- // })
125
- // })
126
- // })
34
+ describe('Report details', () => {
35
+ it('should show the report details', () => {
36
+ cy.findAllByRole('group').contains('Report details').should('be.visible').click()
37
+
38
+ cy.findAllByRole('group')
39
+ .contains('Report details')
40
+ .parent()
41
+ .parent()
42
+ .within(() => {
43
+ cy.findAllByRole('row').each((row, index) => {
44
+ cy.wrap(row).within(() => {
45
+ switch (index) {
46
+ case 0:
47
+ cy.findAllByRole('cell', { name: 'Name:' }).should('exist')
48
+ cy.findAllByRole('cell', { name: 'Successful Report' }).should('exist')
49
+ break
50
+ case 1:
51
+ cy.findAllByRole('cell', { name: 'Product:' }).should('exist')
52
+ cy.findAllByRole('cell', { name: 'Successful Report' }).should('exist')
53
+ break
54
+ case 2:
55
+ cy.findAllByRole('cell', { name: 'Description:' }).should('exist')
56
+ cy.findAllByRole('cell', { name: 'this will succeed' }).should('exist')
57
+ break
58
+ case 3:
59
+ cy.findAllByRole('cell', { name: 'Classification:' }).should('exist')
60
+ cy.findAllByRole('cell', { name: 'OFFICIAL' }).should('exist')
61
+ break
62
+ case 4:
63
+ cy.findAllByRole('cell', { name: 'Requested at:' }).should('exist')
64
+ cy.findAllByRole('cell', { name: /\d{1,2}\/\d{1,2}\/\d{2,4}/ }).should('exist')
65
+ break
66
+ case 5:
67
+ cy.findAllByRole('cell', { name: 'Applied Filters:' }).should('exist')
68
+ cy.findAllByRole('listitem').each((item, i) => {
69
+ switch (i) {
70
+ case 0:
71
+ cy.wrap(item).contains('Field 1: value1.2')
72
+ break
73
+ case 1:
74
+ cy.wrap(item).contains('Field 3 start: 01/02/2003')
75
+ break
76
+ case 2:
77
+ cy.wrap(item).contains('Field 3 end: 04/05/2006')
78
+ break
79
+ case 3:
80
+ cy.wrap(item).contains('Field 7: 01/02/2005')
81
+ break
82
+ case 4:
83
+ cy.wrap(item).contains('Field 8: value8.2,value8.3')
84
+ break
85
+ case 5:
86
+ cy.wrap(item).contains('Sort column: Field 1')
87
+ break
88
+ case 6:
89
+ cy.wrap(item).contains('Sort direction: Descending')
90
+ break
91
+ default:
92
+ break
93
+ }
94
+ })
95
+ break
96
+ default:
97
+ break
98
+ }
99
+ })
100
+ })
101
+ })
102
+ })
103
+ })
104
+
105
+ describe('Actions', () => {
106
+ it('should show the actions and go to the filters page when refresh action is clicked', () => {
107
+ cy.findByLabelText('Refresh report').should('be.visible')
108
+ cy.findByLabelText(/download/).should('be.visible')
109
+ cy.findByLabelText(/Copy report link/).should('be.visible')
110
+ cy.findByRole('button', { name: /Add bookmark/ }).should('be.visible')
111
+
112
+ cy.findByLabelText('Refresh report').should('be.visible').click()
113
+ cy.url().should(
114
+ 'match',
115
+ /.*\/embedded\/platform\/dpr\/request-report\/report\/request-examples\/request-example-success\/filters/i,
116
+ )
117
+
118
+ cy.location().should((location) => {
119
+ expect(location.search).to.contain(`filters.field1=value1.2`)
120
+ expect(location.search).to.contain(`filters.field3.start=2003-02-01`)
121
+ expect(location.search).to.contain(`filters.field3.end=2006-05-04`)
122
+ expect(location.search).to.contain(`filters.field7=2005-02-01`)
123
+ expect(location.search).to.contain(`filters.field8=value8.2&filters.field8=value8.3`)
124
+ })
125
+ })
126
+ })
127
127
 
128
128
  describe('Column interactions', () => {
129
129
  const expectInitialisedColumns = () => {
@@ -152,7 +152,7 @@ context('Viewing a report', () => {
152
152
  .eq(0)
153
153
  .within(() => {
154
154
  cy.findAllByRole('row')
155
- .eq(0)
155
+ .eq(1)
156
156
  .within(() => {
157
157
  cy.findAllByRole('columnheader').should('have.length', 5)
158
158
  })
@@ -186,7 +186,7 @@ context('Viewing a report', () => {
186
186
  .eq(0)
187
187
  .within(() => {
188
188
  cy.findAllByRole('row')
189
- .eq(0)
189
+ .eq(1)
190
190
  .within(() => {
191
191
  cy.findAllByRole('columnheader').should('have.length', 4)
192
192
  })
@@ -372,7 +372,7 @@ context('Viewing a report', () => {
372
372
  .eq(0)
373
373
  .within(() => {
374
374
  cy.findAllByRole('row')
375
- .eq(0)
375
+ .eq(1)
376
376
  .within(() => {
377
377
  cy.findAllByRole('columnheader').should('have.length', 2)
378
378
  })
@@ -381,751 +381,751 @@ context('Viewing a report', () => {
381
381
  })
382
382
  })
383
383
 
384
- // describe('Paging interaction', () => {
385
- // it('should show the table totals', () => {
386
- // cy.findAllByRole('paragraph')
387
- // .contains(/Showing \d{1,4} to \d{1,4} of \d{1,4} results/)
388
- // .should('exist')
389
- // cy.findByLabelText(/Successful Report/).within(() => {
390
- // cy.findAllByRole('rowgroup')
391
- // .eq(1)
392
- // .within(() => {
393
- // cy.findAllByRole('row').should('have.length', 20)
394
- // })
395
- // })
396
- // })
397
-
398
- // it('should change the page size', () => {
399
- // cy.get('#page-size-select').select('10')
400
- // cy.findAllByRole('paragraph')
401
- // .contains(/Showing 1 to 10 of 100 results/)
402
- // .should('exist')
403
- // cy.findByLabelText(/Successful Report/).within(() => {
404
- // cy.findAllByRole('rowgroup')
405
- // .eq(1)
406
- // .within(() => {
407
- // cy.findAllByRole('row').should('have.length', 10)
408
- // })
409
- // })
410
- // })
411
-
412
- // it('should change the page size via the URL', () => {
413
- // cy.visit(
414
- // `/embedded/platform/dpr/view-report/async/report/request-examples/request-example-success/${tableId}/report?pageSize=100`,
415
- // )
416
- // cy.findAllByRole('paragraph')
417
- // .contains(/100 total results/)
418
- // .should('exist')
419
- // cy.findByLabelText(/Successful Report/).within(() => {
420
- // cy.findAllByRole('rowgroup')
421
- // .eq(1)
422
- // .within(() => {
423
- // cy.findAllByRole('row').should('have.length', 100)
424
- // })
425
- // })
426
- // })
427
-
428
- // it('should change the page', () => {
429
- // cy.findByLabelText('Page 5').click()
430
- // cy.location().should((location) => {
431
- // expect(location.search).to.contain(`selectedPage=5`)
432
- // })
433
- // })
434
-
435
- // it('should change the page via the URL', () => {
436
- // cy.visit(
437
- // `/embedded/platform/dpr/view-report/async/report/request-examples/request-example-success/${tableId}/report?selectedPage=3`,
438
- // )
439
- // cy.findByRole('link', { current: 'page' }).contains('3')
440
- // })
441
- // })
384
+ describe('Paging interaction', () => {
385
+ it('should show the table totals', () => {
386
+ cy.findAllByRole('paragraph')
387
+ .contains(/Showing \d{1,4} to \d{1,4} of \d{1,4} results/)
388
+ .should('exist')
389
+ cy.findByLabelText(/Successful Report/).within(() => {
390
+ cy.findAllByRole('rowgroup')
391
+ .eq(1)
392
+ .within(() => {
393
+ cy.findAllByRole('row').should('have.length', 20)
394
+ })
395
+ })
396
+ })
397
+
398
+ it('should change the page size', () => {
399
+ cy.get('#page-size-select').select('10')
400
+ cy.findAllByRole('paragraph')
401
+ .contains(/Showing 1 to 10 of 100 results/)
402
+ .should('exist')
403
+ cy.findByLabelText(/Successful Report/).within(() => {
404
+ cy.findAllByRole('rowgroup')
405
+ .eq(1)
406
+ .within(() => {
407
+ cy.findAllByRole('row').should('have.length', 10)
408
+ })
409
+ })
410
+ })
411
+
412
+ it('should change the page size via the URL', () => {
413
+ cy.visit(
414
+ `/embedded/platform/dpr/view-report/async/report/request-examples/request-example-success/${tableId}/report?pageSize=100`,
415
+ )
416
+ cy.findAllByRole('paragraph')
417
+ .contains(/100 total results/)
418
+ .should('exist')
419
+ cy.findByLabelText(/Successful Report/).within(() => {
420
+ cy.findAllByRole('rowgroup')
421
+ .eq(1)
422
+ .within(() => {
423
+ cy.findAllByRole('row').should('have.length', 100)
424
+ })
425
+ })
426
+ })
427
+
428
+ it('should change the page', () => {
429
+ cy.findByLabelText('Page 5').click()
430
+ cy.location().should((location) => {
431
+ expect(location.search).to.contain(`selectedPage=5`)
432
+ })
433
+ })
434
+
435
+ it('should change the page via the URL', () => {
436
+ cy.visit(
437
+ `/embedded/platform/dpr/view-report/async/report/request-examples/request-example-success/${tableId}/report?selectedPage=3`,
438
+ )
439
+ cy.findByRole('link', { current: 'page' }).contains('3')
440
+ })
441
+ })
442
442
  })
443
443
 
444
- // describe('Interactive report', () => {
445
- // const applyFilters = () => {
446
- // cy.findByRole('button', { name: 'Apply filters' }).click()
447
- // }
448
-
449
- // const showFilters = () => {
450
- // cy.findAllByRole('group')
451
- // .contains(/Show filters/)
452
- // .click()
453
- // }
454
-
455
- // before(() => {
456
- // executeReportStubs()
457
- // cy.task('stubDefinitionFeatureTestingInteractive')
458
- // cy.task('stubAsyncRequestSuccessReportTablesCount')
459
- // cy.task('stubRequestSuccessResult20')
460
- // cy.task('stubRequestSuccessResult100')
461
- // })
462
-
463
- // describe('Apply filters', () => {
464
- // before(() => {
465
- // requestReport({ name: 'Interactive Report', description: 'this is an interactive report', path })
466
- // cy.url().then((url) => {
467
- // viewReportUrl = url
468
- // })
469
- // })
470
-
471
- // beforeEach(() => {
472
- // cy.visit(viewReportUrl)
473
- // })
474
-
475
- // const removeAllFilters = () => {
476
- // for (let index = 0; index < 4; index += 1) {
477
- // cy.findByLabelText('Selected filters').within(() => {
478
- // cy.findAllByRole('link').first().click()
479
- // })
480
- // }
481
- // }
482
-
483
- // describe('Date range', () => {
484
- // it('should apply the date range', () => {
485
- // cy.findByRole('textbox', { name: 'From' }).should('have.value', '01/02/2003')
486
- // cy.findByRole('textbox', { name: 'To' }).should('have.value', '04/05/2006')
487
-
488
- // removeAllFilters()
489
- // showFilters()
490
-
491
- // cy.findByRole('textbox', { name: 'From' }).type('02/05/2025')
492
- // cy.findByRole('textbox', { name: 'To' }).type('05/07/2025').blur()
493
-
494
- // applyFilters()
495
-
496
- // cy.location().should((location) => {
497
- // expect(location.search).to.contain(`filters.field3.start=2025-05-02`)
498
- // expect(location.search).to.contain(`filters.field3.end=2025-07-05`)
499
- // })
500
-
501
- // checkSelectedFilterValues({ length: 2, buttonValues: [{ key: 'Field 3', value: '02/05/2025 - 05/07/2025' }] })
502
- // })
503
-
504
- // it('should apply the relative daterange', () => {
505
- // removeAllFilters()
506
- // showFilters()
507
-
508
- // cy.findByRole('tab', { name: 'Preset date ranges' }).click()
509
- // cy.findByRole('radio', { name: 'Tomorrow' }).check()
510
-
511
- // applyFilters()
512
-
513
- // let startValue: string | number | string[] | undefined
514
- // let endValue: string | number | string[] | undefined
515
- // cy.findByRole('textbox', { name: 'From' })
516
- // .invoke('val')
517
- // .should('not.be.empty')
518
- // .then((val) => {
519
- // startValue = val
520
- // })
521
- // cy.findByRole('textbox', { name: 'To' })
522
- // .invoke('val')
523
- // .should('not.be.empty')
524
- // .then((val) => {
525
- // endValue = val
526
- // })
527
-
528
- // const dateMapper = new DateMapper()
529
- // cy.location().should((location) => {
530
- // expect(location.search).to.contain(
531
- // `filters.field3.start=${dateMapper.toDateString(<string>startValue, 'iso')}`,
532
- // )
533
- // expect(location.search).to.contain(`filters.field3.end=${dateMapper.toDateString(<string>endValue, 'iso')}`)
534
- // expect(location.search).to.contain(`filters.field3.relative-duration=tomorrow`)
535
- // })
536
-
537
- // checkSelectedFilterValues({ length: 2, buttonValues: [{ key: 'Field 3', value: 'Tomorrow' }] })
538
- // })
539
- // })
540
-
541
- // describe('Multiselect', () => {
542
- // it('should apply the multiselect values', () => {
543
- // cy.findByRole('checkbox', { name: 'Value 8.2' }).should('be.checked')
544
- // cy.findByRole('checkbox', { name: 'Value 8.3' }).should('be.checked')
545
-
546
- // removeAllFilters()
547
-
548
- // cy.findByRole('checkbox', { name: 'Value 8.1' }).should('not.be.checked')
549
- // cy.findByRole('checkbox', { name: 'Value 8.2' }).should('not.be.checked')
550
- // cy.findByRole('checkbox', { name: 'Value 8.3' }).should('not.be.checked')
551
- // cy.findByRole('checkbox', { name: 'Value 8.4' }).should('not.be.checked')
552
-
553
- // showFilters()
554
-
555
- // cy.findByRole('checkbox', { name: 'Value 8.1' }).check()
556
- // cy.findByRole('checkbox', { name: 'Value 8.3' }).check()
557
-
558
- // applyFilters()
559
-
560
- // cy.findByRole('checkbox', { name: 'Value 8.1' }).should('be.checked')
561
- // cy.findByRole('checkbox', { name: 'Value 8.2' }).should('not.be.checked')
562
- // cy.findByRole('checkbox', { name: 'Value 8.3' }).should('be.checked')
563
- // cy.findByRole('checkbox', { name: 'Value 8.4' }).should('not.be.checked')
564
-
565
- // checkSelectedFilterValues({ length: 2, buttonValues: [{ key: 'Field 8', value: 'Value 8.1, Value 8.3' }] })
566
- // })
567
-
568
- // it('should set the selected filter values correctly', () => {
569
- // cy.findByRole('checkbox', { name: 'Value 8.2' }).should('be.checked')
570
- // cy.findByRole('checkbox', { name: 'Value 8.3' }).should('be.checked')
571
-
572
- // removeAllFilters()
573
-
574
- // cy.findByRole('checkbox', { name: 'Value 8.1' }).should('not.be.checked')
575
- // cy.findByRole('checkbox', { name: 'Value 8.2' }).should('not.be.checked')
576
- // cy.findByRole('checkbox', { name: 'Value 8.3' }).should('not.be.checked')
577
- // cy.findByRole('checkbox', { name: 'Value 8.4' }).should('not.be.checked')
578
-
579
- // showFilters()
580
-
581
- // cy.findByRole('checkbox', { name: 'Value 8.1' }).check()
582
- // cy.findByRole('checkbox', { name: 'Value 8.2' }).check()
583
- // cy.findByRole('checkbox', { name: 'Value 8.3' }).check()
584
- // cy.findByRole('checkbox', { name: 'Value 8.4' }).check()
585
-
586
- // applyFilters()
587
-
588
- // cy.findByRole('checkbox', { name: 'Value 8.1' }).should('be.checked')
589
- // cy.findByRole('checkbox', { name: 'Value 8.2' }).should('be.checked')
590
- // cy.findByRole('checkbox', { name: 'Value 8.3' }).should('be.checked')
591
- // cy.findByRole('checkbox', { name: 'Value 8.4' }).should('be.checked')
592
-
593
- // checkSelectedFilterValues({
594
- // length: 2,
595
- // buttonValues: [{ key: 'Field 8', value: 'Value 8.1, Value 8.2, Value 8.3 + 1 more' }],
596
- // })
597
- // })
598
-
599
- // it('should set the values correctly when only one checkbox selected', () => {
600
- // removeAllFilters()
601
-
602
- // cy.findByRole('checkbox', { name: 'Value 8.1' }).should('not.be.checked')
603
- // cy.findByRole('checkbox', { name: 'Value 8.2' }).should('not.be.checked')
604
- // cy.findByRole('checkbox', { name: 'Value 8.3' }).should('not.be.checked')
605
- // cy.findByRole('checkbox', { name: 'Value 8.4' }).should('not.be.checked')
606
-
607
- // showFilters()
608
-
609
- // cy.findByRole('checkbox', { name: 'Value 8.1' }).check()
610
-
611
- // applyFilters()
612
-
613
- // cy.findByRole('checkbox', { name: 'Value 8.1' }).should('be.checked')
614
- // cy.findByRole('checkbox', { name: 'Value 8.2' }).should('not.be.checked')
615
- // cy.findByRole('checkbox', { name: 'Value 8.3' }).should('not.be.checked')
616
- // cy.findByRole('checkbox', { name: 'Value 8.4' }).should('not.be.checked')
617
-
618
- // checkSelectedFilterValues({
619
- // length: 2,
620
- // buttonValues: [{ key: 'Field 8', value: 'Value 8.1' }],
621
- // })
622
- // })
623
- // })
624
-
625
- // it('Applying filters should persist current applied columns', () => {
626
- // cy.findAllByRole('group')
627
- // .contains(/Show columns/)
628
- // .should('be.visible')
629
- // .click()
630
-
631
- // cy.findByRole('checkbox', { name: 'Field 1' }).uncheck()
632
- // cy.findByRole('checkbox', { name: 'Field 3' }).uncheck()
633
- // cy.findByRole('checkbox', { name: 'Field 5' }).check()
634
- // cy.findByRole('checkbox', { name: 'Field 7' }).uncheck()
635
- // cy.findByRole('checkbox', { name: 'Field 8' }).check()
636
-
637
- // cy.findByRole('button', { name: 'Apply columns' }).click()
638
- // cy.findAllByRole('group').contains('Show columns (4 of 8 shown)')
639
-
640
- // showFilters()
641
- // cy.findByRole('checkbox', { name: 'Value 8.1' }).check()
642
- // cy.findByRole('checkbox', { name: 'Value 8.3' }).check()
643
- // applyFilters()
644
-
645
- // cy.findAllByRole('group').contains('Show columns (4 of 8 shown)')
646
- // })
647
- // })
648
-
649
- // describe('User defined interactive defaults', () => {
650
- // const saveDefaultsButton = () => {
651
- // return cy.findByRole('button', { name: 'Save current filter values as defaults' })
652
- // }
653
- // const updateDefaultsButton = () => {
654
- // return cy.findByRole('button', { name: 'Update defaults' })
655
- // }
656
- // const deleteDefaultsButton = () => {
657
- // return cy.findByRole('button', { name: 'Delete defaults' })
658
- // }
659
-
660
- // const checkSelectedFiltersInUserReports = ({
661
- // name,
662
- // product,
663
- // length,
664
- // selectedFilters,
665
- // }: {
666
- // name: string
667
- // product: string
668
- // length: number
669
- // selectedFilters: { key: string; value: string }[]
670
- // }) => {
671
- // cy.findByLabelText(/Viewed \(/).within(() => {
672
- // cy.findByRole('row', {
673
- // name: (_, element) => {
674
- // return Boolean(element.textContent?.includes(name)) && Boolean(element.textContent?.includes(product))
675
- // },
676
- // }).within(() => {
677
- // cy.findAllByRole('listitem')
678
- // .should('have.length', length)
679
- // .each((li, index) => {
680
- // if (selectedFilters[index]) {
681
- // const { key, value } = selectedFilters[index]
682
- // cy.wrap(li).contains(key)
683
- // cy.wrap(li).contains(value)
684
- // }
685
- // })
686
- // })
687
- // })
688
- // }
689
-
690
- // it('should save the interactive filters correctly', () => {
691
- // // request the report
692
- // requestReport({ name: 'Interactive Report', description: 'this is an interactive report', path })
693
-
694
- // // check the default filters
695
- // checkSelectedFilterValues({
696
- // length: 5,
697
- // buttonValues: [
698
- // { key: 'Field 1', value: 'Value 1.2' },
699
- // { key: 'Field 3', value: '01/02/2003 - 04/05/2006' },
700
- // { key: 'Field 7', value: '01/02/2005' },
701
- // { key: 'Field 8', value: 'Value 8.2, Value 8.3' },
702
- // ],
703
- // })
704
-
705
- // // update the filters
706
- // showFilters()
707
- // cy.findByRole('checkbox', { name: 'Value 8.1' }).check()
708
- // cy.findByRole('checkbox', { name: 'Value 8.4' }).check()
709
- // cy.findByRole('combobox', { name: 'Field 2' }).select('value2.2')
710
- // applyFilters()
711
-
712
- // const selectedFiltersButtonValues = [
713
- // { key: 'Field 1', value: 'Value 1.2' },
714
- // { key: 'Field 2', value: 'Value 2.2' },
715
- // { key: 'Field 3', value: '01/02/2003 - 04/05/2006' },
716
- // { key: 'Field 7', value: '01/02/2005' },
717
- // { key: 'Field 8', value: 'Value 8.1, Value 8.2, Value 8.3 + 1 more' },
718
- // ]
719
- // checkSelectedFilterValues({
720
- // length: 6,
721
- // buttonValues: selectedFiltersButtonValues,
722
- // })
723
-
724
- // // save the filters
725
- // saveDefaultsButton().click()
726
-
727
- // // check for saved page furniture
728
- // updateDefaultsButton().should('exist')
729
- // deleteDefaultsButton().should('exist')
730
-
731
- // // check the selected filters
732
- // checkSelectedFilterValues({
733
- // length: 6,
734
- // buttonValues: selectedFiltersButtonValues,
735
- // })
736
- // })
737
-
738
- // it('should init the report with saved interactive defaults', () => {
739
- // // request the report
740
- // requestReport({ name: 'Interactive Report', description: 'this is an interactive report', path })
741
- // cy.url().then((url) => {
742
- // viewReportUrl = url
743
- // })
744
-
745
- // // check saved defaults page furniture
746
- // updateDefaultsButton().should('exist')
747
- // deleteDefaultsButton().should('exist')
748
-
749
- // const selectedFiltersButtonValues = [
750
- // { key: 'Field 1', value: 'Value 1.2' },
751
- // { key: 'Field 2', value: 'Value 2.2' },
752
- // { key: 'Field 3', value: '01/02/2003 - 04/05/2006' },
753
- // { key: 'Field 7', value: '01/02/2005' },
754
- // { key: 'Field 8', value: 'Value 8.1, Value 8.2, Value 8.3 + 1 more' },
755
- // ]
756
- // checkSelectedFilterValues({
757
- // length: 6,
758
- // buttonValues: selectedFiltersButtonValues,
759
- // })
760
-
761
- // cy.visit(path)
762
- // cy.findByRole('tab', { name: /Viewed/ }).click()
763
- // checkSelectedFiltersInUserReports({
764
- // name: 'Interactive Report',
765
- // product: 'Interactive Report',
766
- // length: 5,
767
- // selectedFilters: selectedFiltersButtonValues,
768
- // })
769
- // })
770
-
771
- // it('should reset the filter values to the saved defaults', () => {
772
- // cy.visit(viewReportUrl)
773
-
774
- // // check saved defaults page furniture
775
- // updateDefaultsButton().should('exist')
776
- // deleteDefaultsButton().should('exist')
777
-
778
- // const savedDefaultSelectedFilters = [
779
- // { key: 'Field 1', value: 'Value 1.2' },
780
- // { key: 'Field 2', value: 'Value 2.2' },
781
- // { key: 'Field 3', value: '01/02/2003 - 04/05/2006' },
782
- // { key: 'Field 7', value: '01/02/2005' },
783
- // { key: 'Field 8', value: 'Value 8.1, Value 8.2, Value 8.3 + 1 more' },
784
- // ]
785
- // checkSelectedFilterValues({
786
- // length: 6,
787
- // buttonValues: savedDefaultSelectedFilters,
788
- // })
789
-
790
- // // apply some filters
791
- // showFilters()
792
- // cy.findByRole('checkbox', { name: 'Value 8.1' }).uncheck()
793
- // cy.findByRole('checkbox', { name: 'Value 8.3' }).uncheck()
794
- // cy.findByRole('combobox', { name: 'Field 2' }).select('value2.3')
795
- // applyFilters()
796
-
797
- // checkSelectedFilterValues({
798
- // length: 6,
799
- // buttonValues: [
800
- // { key: 'Field 1', value: 'Value 1.2' },
801
- // { key: 'Field 2', value: 'Value 2.3' },
802
- // { key: 'Field 3', value: '01/02/2003 - 04/05/2006' },
803
- // { key: 'Field 7', value: '01/02/2005' },
804
- // { key: 'Field 8', value: 'Value 8.4' },
805
- // ],
806
- // })
807
-
808
- // cy.visit(path)
809
- // cy.findByRole('tab', { name: /Viewed/ }).click()
810
- // checkSelectedFiltersInUserReports({
811
- // name: 'Interactive Report',
812
- // product: 'Interactive Report',
813
- // length: 5,
814
- // selectedFilters: [
815
- // { key: 'Field 1', value: 'Value 1.2' },
816
- // { key: 'Field 2', value: 'Value 2.3' },
817
- // { key: 'Field 3', value: '01/02/2003 - 04/05/2006' },
818
- // { key: 'Field 7', value: '01/02/2005' },
819
- // { key: 'Field 8', value: 'Value 8.4' },
820
- // ],
821
- // })
822
-
823
- // cy.visit(viewReportUrl)
824
-
825
- // cy.findByRole('link', { name: 'Reset filters' }).click()
826
-
827
- // checkSelectedFilterValues({
828
- // length: 6,
829
- // buttonValues: savedDefaultSelectedFilters,
830
- // })
831
-
832
- // cy.visit(path)
833
- // cy.findByRole('tab', { name: /Viewed/ }).click()
834
- // checkSelectedFiltersInUserReports({
835
- // name: 'Interactive Report',
836
- // product: 'Interactive Report',
837
- // length: 5,
838
- // selectedFilters: savedDefaultSelectedFilters,
839
- // })
840
- // })
841
-
842
- // it('should update the filter values and init the report with the updated interactive defaults', () => {
843
- // cy.visit(viewReportUrl)
844
-
845
- // // check saved defaults page furniture
846
- // updateDefaultsButton().should('exist')
847
- // deleteDefaultsButton().should('exist')
848
-
849
- // checkSelectedFilterValues({
850
- // length: 6,
851
- // buttonValues: [
852
- // { key: 'Field 1', value: 'Value 1.2' },
853
- // { key: 'Field 2', value: 'Value 2.2' },
854
- // { key: 'Field 3', value: '01/02/2003 - 04/05/2006' },
855
- // { key: 'Field 7', value: '01/02/2005' },
856
- // { key: 'Field 8', value: 'Value 8.1, Value 8.2, Value 8.3 + 1 more' },
857
- // ],
858
- // })
859
-
860
- // // apply some filters
861
- // showFilters()
862
- // cy.findByRole('checkbox', { name: 'Value 8.1' }).uncheck()
863
- // cy.findByRole('checkbox', { name: 'Value 8.3' }).uncheck()
864
- // cy.findByRole('combobox', { name: 'Field 2' }).select('value2.3')
865
- // applyFilters()
866
-
867
- // const expectedSelectedValues = [
868
- // { key: 'Field 1', value: 'Value 1.2' },
869
- // { key: 'Field 2', value: 'Value 2.3' },
870
- // { key: 'Field 3', value: '01/02/2003 - 04/05/2006' },
871
- // { key: 'Field 7', value: '01/02/2005' },
872
- // { key: 'Field 8', value: 'Value 8.2, Value 8.4' },
873
- // ]
874
-
875
- // checkSelectedFilterValues({
876
- // length: 6,
877
- // buttonValues: expectedSelectedValues,
878
- // })
879
-
880
- // updateDefaultsButton().click()
881
-
882
- // checkSelectedFilterValues({
883
- // length: 6,
884
- // buttonValues: expectedSelectedValues,
885
- // })
886
-
887
- // requestReport({ name: 'Interactive Report', description: 'this is an interactive report', path })
888
- // cy.url().then((url) => {
889
- // viewReportUrl = url
890
- // })
891
-
892
- // // check the initial filter values match the default
893
- // checkSelectedFilterValues({
894
- // length: 6,
895
- // buttonValues: expectedSelectedValues,
896
- // })
897
-
898
- // // check saved defaults page furniture
899
- // updateDefaultsButton().should('exist')
900
- // deleteDefaultsButton().should('exist')
901
-
902
- // cy.visit(path)
903
- // cy.findByRole('tab', { name: /Viewed/ }).click()
904
- // checkSelectedFiltersInUserReports({
905
- // name: 'Interactive Report',
906
- // product: 'Interactive Report',
907
- // length: 5,
908
- // selectedFilters: expectedSelectedValues,
909
- // })
910
- // })
911
-
912
- // it('should delete the saved defaults', () => {
913
- // cy.visit(viewReportUrl)
914
-
915
- // checkSelectedFilterValues({
916
- // length: 6,
917
- // buttonValues: [
918
- // { key: 'Field 1', value: 'Value 1.2' },
919
- // { key: 'Field 2', value: 'Value 2.3' },
920
- // { key: 'Field 3', value: '01/02/2003 - 04/05/2006' },
921
- // { key: 'Field 7', value: '01/02/2005' },
922
- // { key: 'Field 8', value: 'Value 8.2, Value 8.4' },
923
- // ],
924
- // })
925
-
926
- // deleteDefaultsButton().click()
927
-
928
- // // Expect DPD defaults to be applied
929
- // checkSelectedFilterValues({
930
- // length: 5,
931
- // buttonValues: [
932
- // { key: 'Field 1', value: 'Value 1.2' },
933
- // { key: 'Field 3', value: '01/02/2003 - 04/05/2006' },
934
- // { key: 'Field 7', value: '01/02/2005' },
935
- // { key: 'Field 8', value: 'Value 8.2, Value 8.3' },
936
- // ],
937
- // })
938
-
939
- // cy.visit(path)
940
- // cy.findByRole('tab', { name: /Viewed/ }).click()
941
- // checkSelectedFiltersInUserReports({
942
- // name: 'Interactive Report',
943
- // product: 'Interactive Report',
944
- // length: 4,
945
- // selectedFilters: [
946
- // { key: 'Field 1', value: 'Value 1.2' },
947
- // { key: 'Field 3', value: '01/02/2003 - 04/05/2006' },
948
- // { key: 'Field 7', value: '01/02/2005' },
949
- // { key: 'Field 8', value: 'Value 8.2, Value 8.3' },
950
- // ],
951
- // })
952
- // })
953
-
954
- // describe('Input types', () => {
955
- // describe('Relative date range', () => {
956
- // it('should save the relative daterange', () => {
957
- // // request the report
958
- // requestReport({ name: 'Interactive Report', description: 'this is an interactive report', path })
959
-
960
- // checkSelectedFilterValues({
961
- // length: 5,
962
- // buttonValues: [
963
- // { key: 'Field 1', value: 'Value 1.2' },
964
- // { key: 'Field 3', value: '01/02/2003 - 04/05/2006' },
965
- // { key: 'Field 7', value: '01/02/2005' },
966
- // { key: 'Field 8', value: 'Value 8.2, Value 8.3' },
967
- // ],
968
- // })
969
-
970
- // // update the filters
971
- // showFilters()
972
- // cy.findByRole('tab', { name: 'Preset date ranges' }).click()
973
- // cy.findByRole('radio', { name: 'Tomorrow' }).check()
974
- // applyFilters()
975
-
976
- // const expectedUpdatedSelected = [
977
- // { key: 'Field 1', value: 'Value 1.2' },
978
- // { key: 'Field 3', value: 'Tomorrow' },
979
- // { key: 'Field 7', value: '01/02/2005' },
980
- // { key: 'Field 8', value: 'Value 8.2, Value 8.3' },
981
- // ]
982
-
983
- // checkSelectedFilterValues({
984
- // length: 5,
985
- // buttonValues: expectedUpdatedSelected,
986
- // })
987
-
988
- // // save the filters
989
- // saveDefaultsButton().click()
990
-
991
- // // check for saved page furniture
992
- // updateDefaultsButton().should('exist')
993
- // deleteDefaultsButton().should('exist')
994
-
995
- // // check the selected filters
996
- // checkSelectedFilterValues({
997
- // length: 5,
998
- // buttonValues: expectedUpdatedSelected,
999
- // })
1000
-
1001
- // // request the report to check it defaults to saved
1002
- // requestReport({ name: 'Interactive Report', description: 'this is an interactive report', path })
1003
-
1004
- // // check the selected filters
1005
- // checkSelectedFilterValues({
1006
- // length: 5,
1007
- // buttonValues: expectedUpdatedSelected,
1008
- // })
1009
-
1010
- // deleteDefaultsButton().click()
1011
- // })
1012
- // })
1013
-
1014
- // describe('Multiselect', () => {
1015
- // it('should save a single multiselect value', () => {
1016
- // // request the report
1017
- // requestReport({ name: 'Interactive Report', description: 'this is an interactive report', path })
1018
-
1019
- // checkSelectedFilterValues({
1020
- // length: 5,
1021
- // buttonValues: [
1022
- // { key: 'Field 1', value: 'Value 1.2' },
1023
- // { key: 'Field 3', value: '01/02/2003 - 04/05/2006' },
1024
- // { key: 'Field 7', value: '01/02/2005' },
1025
- // { key: 'Field 8', value: 'Value 8.2, Value 8.3' },
1026
- // ],
1027
- // })
1028
-
1029
- // // update the filters
1030
- // showFilters()
1031
- // cy.findByRole('checkbox', { name: 'Value 8.3' }).uncheck()
1032
- // applyFilters()
1033
-
1034
- // const expectedUpdatedSelected = [
1035
- // { key: 'Field 1', value: 'Value 1.2' },
1036
- // { key: 'Field 3', value: '01/02/2003 - 04/05/2006' },
1037
- // { key: 'Field 7', value: '01/02/2005' },
1038
- // { key: 'Field 8', value: 'Value 8.2' },
1039
- // ]
1040
-
1041
- // checkSelectedFilterValues({
1042
- // length: 5,
1043
- // buttonValues: expectedUpdatedSelected,
1044
- // })
1045
-
1046
- // // save the filters
1047
- // saveDefaultsButton().click()
1048
-
1049
- // // check for saved page furniture
1050
- // updateDefaultsButton().should('exist')
1051
- // deleteDefaultsButton().should('exist')
1052
-
1053
- // // check the selected filters
1054
- // checkSelectedFilterValues({
1055
- // length: 5,
1056
- // buttonValues: expectedUpdatedSelected,
1057
- // })
1058
-
1059
- // // request the report to check it defaults to saved
1060
- // requestReport({ name: 'Interactive Report', description: 'this is an interactive report', path })
1061
-
1062
- // // check the selected filters
1063
- // checkSelectedFilterValues({
1064
- // length: 5,
1065
- // buttonValues: expectedUpdatedSelected,
1066
- // })
1067
-
1068
- // deleteDefaultsButton().click()
1069
- // })
1070
- // })
1071
- // })
1072
- // })
1073
-
1074
- // describe('Sorting', () => {
1075
- // before(() => {
1076
- // requestReport({ name: 'Interactive Report', description: 'this is an interactive report', path })
1077
- // cy.url().then((url) => {
1078
- // viewReportUrl = url
1079
- // })
1080
- // })
1081
-
1082
- // beforeEach(() => {
1083
- // cy.visit(viewReportUrl)
1084
- // })
1085
-
1086
- // it('should show the sort direction in the column header and the url', () => {
1087
- // cy.findByRole('link', { name: 'Reset filters' }).click()
1088
-
1089
- // // Initial state
1090
- // cy.findByRole('link', { name: 'Field 1' }).should('have.class', 'data-table-header-button-sort-ascending')
1091
- // cy.findByRole('link', { name: 'Field 2' }).should('have.class', 'data-table-header-button-sort-none')
1092
-
1093
- // // Sort desc by field 1
1094
- // cy.findByRole('link', { name: 'Field 1' }).click()
1095
- // cy.findByRole('link', { name: 'Field 1' }).should('have.class', 'data-table-header-button-sort-descending')
1096
- // cy.findByRole('link', { name: 'Field 2' }).should('have.class', 'data-table-header-button-sort-none')
1097
- // cy.location().should((location) => {
1098
- // expect(location.search).to.contain(`&sortColumn=field1&sortedAsc=false`)
1099
- // expect(location.search).to.contain(`filters.field8=value8.2&filters.field8=value8.3`)
1100
- // })
1101
-
1102
- // // Sort asc by field 1
1103
- // cy.findByRole('link', { name: 'Field 1' }).click()
1104
- // cy.findByRole('link', { name: 'Field 1' }).should('have.class', 'data-table-header-button-sort-ascending')
1105
- // cy.findByRole('link', { name: 'Field 2' }).should('have.class', 'data-table-header-button-sort-none')
1106
- // cy.location().should((location) => {
1107
- // expect(location.search).to.contain(`&sortColumn=field1&sortedAsc=true`)
1108
- // expect(location.search).to.contain(`filters.field8=value8.2&filters.field8=value8.3`)
1109
- // })
1110
-
1111
- // // Sort asc by field 2
1112
- // cy.findByRole('link', { name: 'Field 2' }).click()
1113
- // cy.findByRole('link', { name: 'Field 2' }).should('have.class', 'data-table-header-button-sort-ascending')
1114
- // cy.findByRole('link', { name: 'Field 1' }).should('have.class', 'data-table-header-button-sort-none')
1115
- // cy.location().should((location) => {
1116
- // expect(location.search).to.contain(`&sortColumn=field2&sortedAsc=true`)
1117
- // expect(location.search).to.contain(`filters.field8=value8.2&filters.field8=value8.3`)
1118
- // })
1119
-
1120
- // // Sort desc by field 2
1121
- // cy.findByRole('link', { name: 'Field 2' }).click()
1122
- // cy.findByRole('link', { name: 'Field 2' }).should('have.class', 'data-table-header-button-sort-descending')
1123
- // cy.findByRole('link', { name: 'Field 1' }).should('have.class', 'data-table-header-button-sort-none')
1124
- // cy.location().should((location) => {
1125
- // expect(location.search).to.contain(`&sortColumn=field2&sortedAsc=false`)
1126
- // expect(location.search).to.contain(`filters.field8=value8.2&filters.field8=value8.3`)
1127
- // })
1128
- // })
1129
- // })
1130
- // })
444
+ describe('Interactive report', () => {
445
+ const applyFilters = () => {
446
+ cy.findByRole('button', { name: 'Apply filters' }).click()
447
+ }
448
+
449
+ const showFilters = () => {
450
+ cy.findAllByRole('group')
451
+ .contains(/Show filters/)
452
+ .click()
453
+ }
454
+
455
+ before(() => {
456
+ executeReportStubs()
457
+ cy.task('stubDefinitionFeatureTestingInteractive')
458
+ cy.task('stubAsyncRequestSuccessReportTablesCount')
459
+ cy.task('stubRequestSuccessResult20')
460
+ cy.task('stubRequestSuccessResult100')
461
+ })
462
+
463
+ describe('Apply filters', () => {
464
+ before(() => {
465
+ requestReport({ name: 'Interactive Report', description: 'this is an interactive report', path })
466
+ cy.url().then((url) => {
467
+ viewReportUrl = url
468
+ })
469
+ })
470
+
471
+ beforeEach(() => {
472
+ cy.visit(viewReportUrl)
473
+ })
474
+
475
+ const removeAllFilters = () => {
476
+ for (let index = 0; index < 4; index += 1) {
477
+ cy.findByLabelText('Selected filters').within(() => {
478
+ cy.findAllByRole('link').first().click()
479
+ })
480
+ }
481
+ }
482
+
483
+ describe('Date range', () => {
484
+ it('should apply the date range', () => {
485
+ cy.findByRole('textbox', { name: 'From' }).should('have.value', '01/02/2003')
486
+ cy.findByRole('textbox', { name: 'To' }).should('have.value', '04/05/2006')
487
+
488
+ removeAllFilters()
489
+ showFilters()
490
+
491
+ cy.findByRole('textbox', { name: 'From' }).type('02/05/2025')
492
+ cy.findByRole('textbox', { name: 'To' }).type('05/07/2025').blur()
493
+
494
+ applyFilters()
495
+
496
+ cy.location().should((location) => {
497
+ expect(location.search).to.contain(`filters.field3.start=2025-05-02`)
498
+ expect(location.search).to.contain(`filters.field3.end=2025-07-05`)
499
+ })
500
+
501
+ checkSelectedFilterValues({ length: 2, buttonValues: [{ key: 'Field 3', value: '02/05/2025 - 05/07/2025' }] })
502
+ })
503
+
504
+ it('should apply the relative daterange', () => {
505
+ removeAllFilters()
506
+ showFilters()
507
+
508
+ cy.findByRole('tab', { name: 'Preset date ranges' }).click()
509
+ cy.findByRole('radio', { name: 'Tomorrow' }).check()
510
+
511
+ applyFilters()
512
+
513
+ let startValue: string | number | string[] | undefined
514
+ let endValue: string | number | string[] | undefined
515
+ cy.findByRole('textbox', { name: 'From' })
516
+ .invoke('val')
517
+ .should('not.be.empty')
518
+ .then((val) => {
519
+ startValue = val
520
+ })
521
+ cy.findByRole('textbox', { name: 'To' })
522
+ .invoke('val')
523
+ .should('not.be.empty')
524
+ .then((val) => {
525
+ endValue = val
526
+ })
527
+
528
+ const dateMapper = new DateMapper()
529
+ cy.location().should((location) => {
530
+ expect(location.search).to.contain(
531
+ `filters.field3.start=${dateMapper.toDateString(<string>startValue, 'iso')}`,
532
+ )
533
+ expect(location.search).to.contain(`filters.field3.end=${dateMapper.toDateString(<string>endValue, 'iso')}`)
534
+ expect(location.search).to.contain(`filters.field3.relative-duration=tomorrow`)
535
+ })
536
+
537
+ checkSelectedFilterValues({ length: 2, buttonValues: [{ key: 'Field 3', value: 'Tomorrow' }] })
538
+ })
539
+ })
540
+
541
+ describe('Multiselect', () => {
542
+ it('should apply the multiselect values', () => {
543
+ cy.findByRole('checkbox', { name: 'Value 8.2' }).should('be.checked')
544
+ cy.findByRole('checkbox', { name: 'Value 8.3' }).should('be.checked')
545
+
546
+ removeAllFilters()
547
+
548
+ cy.findByRole('checkbox', { name: 'Value 8.1' }).should('not.be.checked')
549
+ cy.findByRole('checkbox', { name: 'Value 8.2' }).should('not.be.checked')
550
+ cy.findByRole('checkbox', { name: 'Value 8.3' }).should('not.be.checked')
551
+ cy.findByRole('checkbox', { name: 'Value 8.4' }).should('not.be.checked')
552
+
553
+ showFilters()
554
+
555
+ cy.findByRole('checkbox', { name: 'Value 8.1' }).check()
556
+ cy.findByRole('checkbox', { name: 'Value 8.3' }).check()
557
+
558
+ applyFilters()
559
+
560
+ cy.findByRole('checkbox', { name: 'Value 8.1' }).should('be.checked')
561
+ cy.findByRole('checkbox', { name: 'Value 8.2' }).should('not.be.checked')
562
+ cy.findByRole('checkbox', { name: 'Value 8.3' }).should('be.checked')
563
+ cy.findByRole('checkbox', { name: 'Value 8.4' }).should('not.be.checked')
564
+
565
+ checkSelectedFilterValues({ length: 2, buttonValues: [{ key: 'Field 8', value: 'Value 8.1, Value 8.3' }] })
566
+ })
567
+
568
+ it('should set the selected filter values correctly', () => {
569
+ cy.findByRole('checkbox', { name: 'Value 8.2' }).should('be.checked')
570
+ cy.findByRole('checkbox', { name: 'Value 8.3' }).should('be.checked')
571
+
572
+ removeAllFilters()
573
+
574
+ cy.findByRole('checkbox', { name: 'Value 8.1' }).should('not.be.checked')
575
+ cy.findByRole('checkbox', { name: 'Value 8.2' }).should('not.be.checked')
576
+ cy.findByRole('checkbox', { name: 'Value 8.3' }).should('not.be.checked')
577
+ cy.findByRole('checkbox', { name: 'Value 8.4' }).should('not.be.checked')
578
+
579
+ showFilters()
580
+
581
+ cy.findByRole('checkbox', { name: 'Value 8.1' }).check()
582
+ cy.findByRole('checkbox', { name: 'Value 8.2' }).check()
583
+ cy.findByRole('checkbox', { name: 'Value 8.3' }).check()
584
+ cy.findByRole('checkbox', { name: 'Value 8.4' }).check()
585
+
586
+ applyFilters()
587
+
588
+ cy.findByRole('checkbox', { name: 'Value 8.1' }).should('be.checked')
589
+ cy.findByRole('checkbox', { name: 'Value 8.2' }).should('be.checked')
590
+ cy.findByRole('checkbox', { name: 'Value 8.3' }).should('be.checked')
591
+ cy.findByRole('checkbox', { name: 'Value 8.4' }).should('be.checked')
592
+
593
+ checkSelectedFilterValues({
594
+ length: 2,
595
+ buttonValues: [{ key: 'Field 8', value: 'Value 8.1, Value 8.2, Value 8.3 + 1 more' }],
596
+ })
597
+ })
598
+
599
+ it('should set the values correctly when only one checkbox selected', () => {
600
+ removeAllFilters()
601
+
602
+ cy.findByRole('checkbox', { name: 'Value 8.1' }).should('not.be.checked')
603
+ cy.findByRole('checkbox', { name: 'Value 8.2' }).should('not.be.checked')
604
+ cy.findByRole('checkbox', { name: 'Value 8.3' }).should('not.be.checked')
605
+ cy.findByRole('checkbox', { name: 'Value 8.4' }).should('not.be.checked')
606
+
607
+ showFilters()
608
+
609
+ cy.findByRole('checkbox', { name: 'Value 8.1' }).check()
610
+
611
+ applyFilters()
612
+
613
+ cy.findByRole('checkbox', { name: 'Value 8.1' }).should('be.checked')
614
+ cy.findByRole('checkbox', { name: 'Value 8.2' }).should('not.be.checked')
615
+ cy.findByRole('checkbox', { name: 'Value 8.3' }).should('not.be.checked')
616
+ cy.findByRole('checkbox', { name: 'Value 8.4' }).should('not.be.checked')
617
+
618
+ checkSelectedFilterValues({
619
+ length: 2,
620
+ buttonValues: [{ key: 'Field 8', value: 'Value 8.1' }],
621
+ })
622
+ })
623
+ })
624
+
625
+ it('Applying filters should persist current applied columns', () => {
626
+ cy.findAllByRole('group')
627
+ .contains(/Show columns/)
628
+ .should('be.visible')
629
+ .click()
630
+
631
+ cy.findByRole('checkbox', { name: 'Field 1' }).uncheck()
632
+ cy.findByRole('checkbox', { name: 'Field 3' }).uncheck()
633
+ cy.findByRole('checkbox', { name: 'Field 5' }).check()
634
+ cy.findByRole('checkbox', { name: 'Field 7' }).uncheck()
635
+ cy.findByRole('checkbox', { name: 'Field 8' }).check()
636
+
637
+ cy.findByRole('button', { name: 'Apply columns' }).click()
638
+ cy.findAllByRole('group').contains('Show columns (4 of 8 shown)')
639
+
640
+ showFilters()
641
+ cy.findByRole('checkbox', { name: 'Value 8.1' }).check()
642
+ cy.findByRole('checkbox', { name: 'Value 8.3' }).check()
643
+ applyFilters()
644
+
645
+ cy.findAllByRole('group').contains('Show columns (4 of 8 shown)')
646
+ })
647
+ })
648
+
649
+ describe('User defined interactive defaults', () => {
650
+ const saveDefaultsButton = () => {
651
+ return cy.findByRole('button', { name: 'Save current filter values as defaults' })
652
+ }
653
+ const updateDefaultsButton = () => {
654
+ return cy.findByRole('button', { name: 'Update defaults' })
655
+ }
656
+ const deleteDefaultsButton = () => {
657
+ return cy.findByRole('button', { name: 'Delete defaults' })
658
+ }
659
+
660
+ const checkSelectedFiltersInUserReports = ({
661
+ name,
662
+ product,
663
+ length,
664
+ selectedFilters,
665
+ }: {
666
+ name: string
667
+ product: string
668
+ length: number
669
+ selectedFilters: { key: string; value: string }[]
670
+ }) => {
671
+ cy.findByLabelText(/Viewed \(/).within(() => {
672
+ cy.findByRole('row', {
673
+ name: (_, element) => {
674
+ return Boolean(element.textContent?.includes(name)) && Boolean(element.textContent?.includes(product))
675
+ },
676
+ }).within(() => {
677
+ cy.findAllByRole('listitem')
678
+ .should('have.length', length)
679
+ .each((li, index) => {
680
+ if (selectedFilters[index]) {
681
+ const { key, value } = selectedFilters[index]
682
+ cy.wrap(li).contains(key)
683
+ cy.wrap(li).contains(value)
684
+ }
685
+ })
686
+ })
687
+ })
688
+ }
689
+
690
+ it('should save the interactive filters correctly', () => {
691
+ // request the report
692
+ requestReport({ name: 'Interactive Report', description: 'this is an interactive report', path })
693
+
694
+ // check the default filters
695
+ checkSelectedFilterValues({
696
+ length: 5,
697
+ buttonValues: [
698
+ { key: 'Field 1', value: 'Value 1.2' },
699
+ { key: 'Field 3', value: '01/02/2003 - 04/05/2006' },
700
+ { key: 'Field 7', value: '01/02/2005' },
701
+ { key: 'Field 8', value: 'Value 8.2, Value 8.3' },
702
+ ],
703
+ })
704
+
705
+ // update the filters
706
+ showFilters()
707
+ cy.findByRole('checkbox', { name: 'Value 8.1' }).check()
708
+ cy.findByRole('checkbox', { name: 'Value 8.4' }).check()
709
+ cy.findByRole('combobox', { name: 'Field 2' }).select('value2.2')
710
+ applyFilters()
711
+
712
+ const selectedFiltersButtonValues = [
713
+ { key: 'Field 1', value: 'Value 1.2' },
714
+ { key: 'Field 2', value: 'Value 2.2' },
715
+ { key: 'Field 3', value: '01/02/2003 - 04/05/2006' },
716
+ { key: 'Field 7', value: '01/02/2005' },
717
+ { key: 'Field 8', value: 'Value 8.1, Value 8.2, Value 8.3 + 1 more' },
718
+ ]
719
+ checkSelectedFilterValues({
720
+ length: 6,
721
+ buttonValues: selectedFiltersButtonValues,
722
+ })
723
+
724
+ // save the filters
725
+ saveDefaultsButton().click()
726
+
727
+ // check for saved page furniture
728
+ updateDefaultsButton().should('exist')
729
+ deleteDefaultsButton().should('exist')
730
+
731
+ // check the selected filters
732
+ checkSelectedFilterValues({
733
+ length: 6,
734
+ buttonValues: selectedFiltersButtonValues,
735
+ })
736
+ })
737
+
738
+ it('should init the report with saved interactive defaults', () => {
739
+ // request the report
740
+ requestReport({ name: 'Interactive Report', description: 'this is an interactive report', path })
741
+ cy.url().then((url) => {
742
+ viewReportUrl = url
743
+ })
744
+
745
+ // check saved defaults page furniture
746
+ updateDefaultsButton().should('exist')
747
+ deleteDefaultsButton().should('exist')
748
+
749
+ const selectedFiltersButtonValues = [
750
+ { key: 'Field 1', value: 'Value 1.2' },
751
+ { key: 'Field 2', value: 'Value 2.2' },
752
+ { key: 'Field 3', value: '01/02/2003 - 04/05/2006' },
753
+ { key: 'Field 7', value: '01/02/2005' },
754
+ { key: 'Field 8', value: 'Value 8.1, Value 8.2, Value 8.3 + 1 more' },
755
+ ]
756
+ checkSelectedFilterValues({
757
+ length: 6,
758
+ buttonValues: selectedFiltersButtonValues,
759
+ })
760
+
761
+ cy.visit(path)
762
+ cy.findByRole('tab', { name: /Viewed/ }).click()
763
+ checkSelectedFiltersInUserReports({
764
+ name: 'Interactive Report',
765
+ product: 'Interactive Report',
766
+ length: 5,
767
+ selectedFilters: selectedFiltersButtonValues,
768
+ })
769
+ })
770
+
771
+ it('should reset the filter values to the saved defaults', () => {
772
+ cy.visit(viewReportUrl)
773
+
774
+ // check saved defaults page furniture
775
+ updateDefaultsButton().should('exist')
776
+ deleteDefaultsButton().should('exist')
777
+
778
+ const savedDefaultSelectedFilters = [
779
+ { key: 'Field 1', value: 'Value 1.2' },
780
+ { key: 'Field 2', value: 'Value 2.2' },
781
+ { key: 'Field 3', value: '01/02/2003 - 04/05/2006' },
782
+ { key: 'Field 7', value: '01/02/2005' },
783
+ { key: 'Field 8', value: 'Value 8.1, Value 8.2, Value 8.3 + 1 more' },
784
+ ]
785
+ checkSelectedFilterValues({
786
+ length: 6,
787
+ buttonValues: savedDefaultSelectedFilters,
788
+ })
789
+
790
+ // apply some filters
791
+ showFilters()
792
+ cy.findByRole('checkbox', { name: 'Value 8.1' }).uncheck()
793
+ cy.findByRole('checkbox', { name: 'Value 8.3' }).uncheck()
794
+ cy.findByRole('combobox', { name: 'Field 2' }).select('value2.3')
795
+ applyFilters()
796
+
797
+ checkSelectedFilterValues({
798
+ length: 6,
799
+ buttonValues: [
800
+ { key: 'Field 1', value: 'Value 1.2' },
801
+ { key: 'Field 2', value: 'Value 2.3' },
802
+ { key: 'Field 3', value: '01/02/2003 - 04/05/2006' },
803
+ { key: 'Field 7', value: '01/02/2005' },
804
+ { key: 'Field 8', value: 'Value 8.4' },
805
+ ],
806
+ })
807
+
808
+ cy.visit(path)
809
+ cy.findByRole('tab', { name: /Viewed/ }).click()
810
+ checkSelectedFiltersInUserReports({
811
+ name: 'Interactive Report',
812
+ product: 'Interactive Report',
813
+ length: 5,
814
+ selectedFilters: [
815
+ { key: 'Field 1', value: 'Value 1.2' },
816
+ { key: 'Field 2', value: 'Value 2.3' },
817
+ { key: 'Field 3', value: '01/02/2003 - 04/05/2006' },
818
+ { key: 'Field 7', value: '01/02/2005' },
819
+ { key: 'Field 8', value: 'Value 8.4' },
820
+ ],
821
+ })
822
+
823
+ cy.visit(viewReportUrl)
824
+
825
+ cy.findByRole('link', { name: 'Reset filters' }).click()
826
+
827
+ checkSelectedFilterValues({
828
+ length: 6,
829
+ buttonValues: savedDefaultSelectedFilters,
830
+ })
831
+
832
+ cy.visit(path)
833
+ cy.findByRole('tab', { name: /Viewed/ }).click()
834
+ checkSelectedFiltersInUserReports({
835
+ name: 'Interactive Report',
836
+ product: 'Interactive Report',
837
+ length: 5,
838
+ selectedFilters: savedDefaultSelectedFilters,
839
+ })
840
+ })
841
+
842
+ it('should update the filter values and init the report with the updated interactive defaults', () => {
843
+ cy.visit(viewReportUrl)
844
+
845
+ // check saved defaults page furniture
846
+ updateDefaultsButton().should('exist')
847
+ deleteDefaultsButton().should('exist')
848
+
849
+ checkSelectedFilterValues({
850
+ length: 6,
851
+ buttonValues: [
852
+ { key: 'Field 1', value: 'Value 1.2' },
853
+ { key: 'Field 2', value: 'Value 2.2' },
854
+ { key: 'Field 3', value: '01/02/2003 - 04/05/2006' },
855
+ { key: 'Field 7', value: '01/02/2005' },
856
+ { key: 'Field 8', value: 'Value 8.1, Value 8.2, Value 8.3 + 1 more' },
857
+ ],
858
+ })
859
+
860
+ // apply some filters
861
+ showFilters()
862
+ cy.findByRole('checkbox', { name: 'Value 8.1' }).uncheck()
863
+ cy.findByRole('checkbox', { name: 'Value 8.3' }).uncheck()
864
+ cy.findByRole('combobox', { name: 'Field 2' }).select('value2.3')
865
+ applyFilters()
866
+
867
+ const expectedSelectedValues = [
868
+ { key: 'Field 1', value: 'Value 1.2' },
869
+ { key: 'Field 2', value: 'Value 2.3' },
870
+ { key: 'Field 3', value: '01/02/2003 - 04/05/2006' },
871
+ { key: 'Field 7', value: '01/02/2005' },
872
+ { key: 'Field 8', value: 'Value 8.2, Value 8.4' },
873
+ ]
874
+
875
+ checkSelectedFilterValues({
876
+ length: 6,
877
+ buttonValues: expectedSelectedValues,
878
+ })
879
+
880
+ updateDefaultsButton().click()
881
+
882
+ checkSelectedFilterValues({
883
+ length: 6,
884
+ buttonValues: expectedSelectedValues,
885
+ })
886
+
887
+ requestReport({ name: 'Interactive Report', description: 'this is an interactive report', path })
888
+ cy.url().then((url) => {
889
+ viewReportUrl = url
890
+ })
891
+
892
+ // check the initial filter values match the default
893
+ checkSelectedFilterValues({
894
+ length: 6,
895
+ buttonValues: expectedSelectedValues,
896
+ })
897
+
898
+ // check saved defaults page furniture
899
+ updateDefaultsButton().should('exist')
900
+ deleteDefaultsButton().should('exist')
901
+
902
+ cy.visit(path)
903
+ cy.findByRole('tab', { name: /Viewed/ }).click()
904
+ checkSelectedFiltersInUserReports({
905
+ name: 'Interactive Report',
906
+ product: 'Interactive Report',
907
+ length: 5,
908
+ selectedFilters: expectedSelectedValues,
909
+ })
910
+ })
911
+
912
+ it('should delete the saved defaults', () => {
913
+ cy.visit(viewReportUrl)
914
+
915
+ checkSelectedFilterValues({
916
+ length: 6,
917
+ buttonValues: [
918
+ { key: 'Field 1', value: 'Value 1.2' },
919
+ { key: 'Field 2', value: 'Value 2.3' },
920
+ { key: 'Field 3', value: '01/02/2003 - 04/05/2006' },
921
+ { key: 'Field 7', value: '01/02/2005' },
922
+ { key: 'Field 8', value: 'Value 8.2, Value 8.4' },
923
+ ],
924
+ })
925
+
926
+ deleteDefaultsButton().click()
927
+
928
+ // Expect DPD defaults to be applied
929
+ checkSelectedFilterValues({
930
+ length: 5,
931
+ buttonValues: [
932
+ { key: 'Field 1', value: 'Value 1.2' },
933
+ { key: 'Field 3', value: '01/02/2003 - 04/05/2006' },
934
+ { key: 'Field 7', value: '01/02/2005' },
935
+ { key: 'Field 8', value: 'Value 8.2, Value 8.3' },
936
+ ],
937
+ })
938
+
939
+ cy.visit(path)
940
+ cy.findByRole('tab', { name: /Viewed/ }).click()
941
+ checkSelectedFiltersInUserReports({
942
+ name: 'Interactive Report',
943
+ product: 'Interactive Report',
944
+ length: 4,
945
+ selectedFilters: [
946
+ { key: 'Field 1', value: 'Value 1.2' },
947
+ { key: 'Field 3', value: '01/02/2003 - 04/05/2006' },
948
+ { key: 'Field 7', value: '01/02/2005' },
949
+ { key: 'Field 8', value: 'Value 8.2, Value 8.3' },
950
+ ],
951
+ })
952
+ })
953
+
954
+ describe('Input types', () => {
955
+ describe('Relative date range', () => {
956
+ it('should save the relative daterange', () => {
957
+ // request the report
958
+ requestReport({ name: 'Interactive Report', description: 'this is an interactive report', path })
959
+
960
+ checkSelectedFilterValues({
961
+ length: 5,
962
+ buttonValues: [
963
+ { key: 'Field 1', value: 'Value 1.2' },
964
+ { key: 'Field 3', value: '01/02/2003 - 04/05/2006' },
965
+ { key: 'Field 7', value: '01/02/2005' },
966
+ { key: 'Field 8', value: 'Value 8.2, Value 8.3' },
967
+ ],
968
+ })
969
+
970
+ // update the filters
971
+ showFilters()
972
+ cy.findByRole('tab', { name: 'Preset date ranges' }).click()
973
+ cy.findByRole('radio', { name: 'Tomorrow' }).check()
974
+ applyFilters()
975
+
976
+ const expectedUpdatedSelected = [
977
+ { key: 'Field 1', value: 'Value 1.2' },
978
+ { key: 'Field 3', value: 'Tomorrow' },
979
+ { key: 'Field 7', value: '01/02/2005' },
980
+ { key: 'Field 8', value: 'Value 8.2, Value 8.3' },
981
+ ]
982
+
983
+ checkSelectedFilterValues({
984
+ length: 5,
985
+ buttonValues: expectedUpdatedSelected,
986
+ })
987
+
988
+ // save the filters
989
+ saveDefaultsButton().click()
990
+
991
+ // check for saved page furniture
992
+ updateDefaultsButton().should('exist')
993
+ deleteDefaultsButton().should('exist')
994
+
995
+ // check the selected filters
996
+ checkSelectedFilterValues({
997
+ length: 5,
998
+ buttonValues: expectedUpdatedSelected,
999
+ })
1000
+
1001
+ // request the report to check it defaults to saved
1002
+ requestReport({ name: 'Interactive Report', description: 'this is an interactive report', path })
1003
+
1004
+ // check the selected filters
1005
+ checkSelectedFilterValues({
1006
+ length: 5,
1007
+ buttonValues: expectedUpdatedSelected,
1008
+ })
1009
+
1010
+ deleteDefaultsButton().click()
1011
+ })
1012
+ })
1013
+
1014
+ describe('Multiselect', () => {
1015
+ it('should save a single multiselect value', () => {
1016
+ // request the report
1017
+ requestReport({ name: 'Interactive Report', description: 'this is an interactive report', path })
1018
+
1019
+ checkSelectedFilterValues({
1020
+ length: 5,
1021
+ buttonValues: [
1022
+ { key: 'Field 1', value: 'Value 1.2' },
1023
+ { key: 'Field 3', value: '01/02/2003 - 04/05/2006' },
1024
+ { key: 'Field 7', value: '01/02/2005' },
1025
+ { key: 'Field 8', value: 'Value 8.2, Value 8.3' },
1026
+ ],
1027
+ })
1028
+
1029
+ // update the filters
1030
+ showFilters()
1031
+ cy.findByRole('checkbox', { name: 'Value 8.3' }).uncheck()
1032
+ applyFilters()
1033
+
1034
+ const expectedUpdatedSelected = [
1035
+ { key: 'Field 1', value: 'Value 1.2' },
1036
+ { key: 'Field 3', value: '01/02/2003 - 04/05/2006' },
1037
+ { key: 'Field 7', value: '01/02/2005' },
1038
+ { key: 'Field 8', value: 'Value 8.2' },
1039
+ ]
1040
+
1041
+ checkSelectedFilterValues({
1042
+ length: 5,
1043
+ buttonValues: expectedUpdatedSelected,
1044
+ })
1045
+
1046
+ // save the filters
1047
+ saveDefaultsButton().click()
1048
+
1049
+ // check for saved page furniture
1050
+ updateDefaultsButton().should('exist')
1051
+ deleteDefaultsButton().should('exist')
1052
+
1053
+ // check the selected filters
1054
+ checkSelectedFilterValues({
1055
+ length: 5,
1056
+ buttonValues: expectedUpdatedSelected,
1057
+ })
1058
+
1059
+ // request the report to check it defaults to saved
1060
+ requestReport({ name: 'Interactive Report', description: 'this is an interactive report', path })
1061
+
1062
+ // check the selected filters
1063
+ checkSelectedFilterValues({
1064
+ length: 5,
1065
+ buttonValues: expectedUpdatedSelected,
1066
+ })
1067
+
1068
+ deleteDefaultsButton().click()
1069
+ })
1070
+ })
1071
+ })
1072
+ })
1073
+
1074
+ describe('Sorting', () => {
1075
+ before(() => {
1076
+ requestReport({ name: 'Interactive Report', description: 'this is an interactive report', path })
1077
+ cy.url().then((url) => {
1078
+ viewReportUrl = url
1079
+ })
1080
+ })
1081
+
1082
+ beforeEach(() => {
1083
+ cy.visit(viewReportUrl)
1084
+ })
1085
+
1086
+ it('should show the sort direction in the column header and the url', () => {
1087
+ cy.findByRole('link', { name: 'Reset filters' }).click()
1088
+
1089
+ // Initial state
1090
+ cy.findByRole('link', { name: 'Field 1' }).should('have.class', 'data-table-header-button-sort-ascending')
1091
+ cy.findByRole('link', { name: 'Field 2' }).should('have.class', 'data-table-header-button-sort-none')
1092
+
1093
+ // Sort desc by field 1
1094
+ cy.findByRole('link', { name: 'Field 1' }).click()
1095
+ cy.findByRole('link', { name: 'Field 1' }).should('have.class', 'data-table-header-button-sort-descending')
1096
+ cy.findByRole('link', { name: 'Field 2' }).should('have.class', 'data-table-header-button-sort-none')
1097
+ cy.location().should((location) => {
1098
+ expect(location.search).to.contain(`&sortColumn=field1&sortedAsc=false`)
1099
+ expect(location.search).to.contain(`filters.field8=value8.2&filters.field8=value8.3`)
1100
+ })
1101
+
1102
+ // Sort asc by field 1
1103
+ cy.findByRole('link', { name: 'Field 1' }).click()
1104
+ cy.findByRole('link', { name: 'Field 1' }).should('have.class', 'data-table-header-button-sort-ascending')
1105
+ cy.findByRole('link', { name: 'Field 2' }).should('have.class', 'data-table-header-button-sort-none')
1106
+ cy.location().should((location) => {
1107
+ expect(location.search).to.contain(`&sortColumn=field1&sortedAsc=true`)
1108
+ expect(location.search).to.contain(`filters.field8=value8.2&filters.field8=value8.3`)
1109
+ })
1110
+
1111
+ // Sort asc by field 2
1112
+ cy.findByRole('link', { name: 'Field 2' }).click()
1113
+ cy.findByRole('link', { name: 'Field 2' }).should('have.class', 'data-table-header-button-sort-ascending')
1114
+ cy.findByRole('link', { name: 'Field 1' }).should('have.class', 'data-table-header-button-sort-none')
1115
+ cy.location().should((location) => {
1116
+ expect(location.search).to.contain(`&sortColumn=field2&sortedAsc=true`)
1117
+ expect(location.search).to.contain(`filters.field8=value8.2&filters.field8=value8.3`)
1118
+ })
1119
+
1120
+ // Sort desc by field 2
1121
+ cy.findByRole('link', { name: 'Field 2' }).click()
1122
+ cy.findByRole('link', { name: 'Field 2' }).should('have.class', 'data-table-header-button-sort-descending')
1123
+ cy.findByRole('link', { name: 'Field 1' }).should('have.class', 'data-table-header-button-sort-none')
1124
+ cy.location().should((location) => {
1125
+ expect(location.search).to.contain(`&sortColumn=field2&sortedAsc=false`)
1126
+ expect(location.search).to.contain(`filters.field8=value8.2&filters.field8=value8.3`)
1127
+ })
1128
+ })
1129
+ })
1130
+ })
1131
1131
  })