@@ -18,6 +18,20 @@ function selectEntireCart() {
1818 } ) ;
1919}
2020
21+ const cartRows = ( ) =>
22+ cy . get ( '.cart-table tbody' , { timeout : 20000 } ) . find ( 'tr' ) ;
23+
24+ const assertEmptyCart = ( ) => {
25+ cy . get ( 'body' ) . then ( ( $body ) => {
26+ const table = $body . find ( '.cart-table tbody' ) ;
27+ if ( table . length ) {
28+ cy . wrap ( table . find ( 'tr' ) ) . should ( 'have.length' , 0 ) ;
29+ } else {
30+ cy . get ( '.ui.container .ccl-container h2' ) . should ( 'contain' , 'Empty cart' ) ;
31+ }
32+ } ) ;
33+ } ;
34+
2135const fsc2016p20med_cart = [
2236 {
2337 id : '10ee0f23fcb146ea89dcdacc40b0900d' ,
@@ -170,7 +184,7 @@ describe('Cart Tests', () => {
170184 cy . wait ( '@projections' ) ;
171185 cy . get ( '.ui.container h1' ) . should ( 'contain' , 'Cart' ) ;
172186 cy . get ( '.ui.container .ccl-container h2' ) . should ( 'contain' , 'Empty cart' ) ;
173- cy . get ( 'li a.header-login-link strong' ) . should ( 'contain' , '0' ) ;
187+ assertEmptyCart ( ) ;
174188 } ) ;
175189 // afterEach(() => {
176190 // cy.clearLocalStorage();
@@ -248,7 +262,7 @@ describe('Cart Tests', () => {
248262 } ) ;
249263 cy . wait ( '@projections' ) ;
250264 cy . wait ( 10000 ) ;
251- cy . get ( 'li a.header-login-link strong' ) . should ( 'contain ' , '4' ) ;
265+ cartRows ( ) . should ( 'have.length ' , 4 ) ;
252266 cy . get ( 'td.table-td-projections' ) . contains ( 'EPSG:3035' ) . should ( 'exist' ) ;
253267
254268 // first cart item check and modify the selection
@@ -307,7 +321,7 @@ describe('Cart Tests', () => {
307321
308322 // Duplicate the last element
309323 cy . get ( 'td.text-end' ) . eq ( 3 ) . find ( '.info-icon' ) . eq ( 0 ) . find ( 'button' ) . click ( ) ;
310- cy . get ( 'li a.header-login-link strong' ) . should ( 'contain ' , '5' ) ;
324+ cartRows ( ) . should ( 'have.length.at.least ' , 5 ) ;
311325 cy . get ( 'td.table-td-projections' , { timeout : 10000 } )
312326 . should ( 'have.length.at.least' , 5 )
313327 . eq ( 4 )
@@ -322,7 +336,7 @@ describe('Cart Tests', () => {
322336
323337 // Duplicate the second element
324338 cy . get ( 'td.text-end' ) . eq ( 1 ) . find ( '.info-icon' ) . eq ( 0 ) . find ( 'button' ) . click ( ) ;
325- cy . get ( 'li a.header-login-link strong' ) . should ( 'contain ' , '6' ) ;
339+ cartRows ( ) . should ( 'have.length.at.least ' , 6 ) ;
326340 cy . get ( 'td.table-td-projections' , { timeout : 10000 } )
327341 . should ( 'have.length.at.least' , 6 )
328342 . eq ( 2 )
@@ -368,7 +382,7 @@ describe('Cart Tests', () => {
368382 cy . visit ( '/en/cart' ) ;
369383 cy . get ( '.ui.container h1' ) . should ( 'contain' , 'Cart' ) ;
370384 cy . get ( '.ui.container .ccl-container h2' ) . should ( 'contain' , 'Empty cart' ) ;
371- cy . get ( 'li a.header-login-link strong' ) . should ( 'contain' , '0' ) ;
385+ assertEmptyCart ( ) ;
372386 } ) ;
373387
374388 it ( 'Test Timeseries calendar' , ( ) => {
@@ -381,7 +395,7 @@ describe('Cart Tests', () => {
381395 } ,
382396 } ) ;
383397 cy . wait ( '@projections' ) ;
384- cy . get ( 'li a.header-login-link strong' ) . should ( 'contain ' , '1' ) ;
398+ cartRows ( ) . should ( 'have.length ' , 1 ) ;
385399
386400 cy . get ( 'td.table-td-timeseries' )
387401 . should ( 'have.length.at.least' , 1 )
@@ -416,7 +430,7 @@ describe('Cart Tests', () => {
416430
417431 cy . get ( '.ui.container h1' ) . should ( 'contain' , 'Cart' ) ;
418432 cy . get ( '.ui.container .ccl-container h2' ) . should ( 'contain' , 'Empty cart' ) ;
419- cy . get ( 'li a.header-login-link strong' ) . should ( 'contain' , '0' ) ;
433+ assertEmptyCart ( ) ;
420434 } ) ;
421435
422436 it ( 'Test dataset without date' , ( ) => {
@@ -429,7 +443,7 @@ describe('Cart Tests', () => {
429443 } ,
430444 } ) ;
431445 cy . wait ( '@projections' ) ;
432- cy . get ( 'li a.header-login-link strong' ) . should ( 'contain ' , '1' ) ;
446+ cartRows ( ) . should ( 'have.length ' , 1 ) ;
433447
434448 cy . get ( 'td.table-td-timeseries' , { timeout : 10000 } )
435449 . should ( 'have.length.at.least' , 1 )
@@ -455,7 +469,7 @@ describe('Cart Tests', () => {
455469 'not.contain' ,
456470 'Empty cart' ,
457471 ) ;
458- cy . get ( 'li a.header-login-link strong' ) . should ( 'contain ' , '1' ) ;
472+ cartRows ( ) . should ( 'have.length ' , 1 ) ;
459473 } ) ;
460474
461475 it ( 'Test Layer/Band selector' , ( ) => {
@@ -468,7 +482,7 @@ describe('Cart Tests', () => {
468482 } ,
469483 } ) ;
470484 cy . wait ( '@projections' ) ;
471- cy . get ( 'li a.header-login-link strong' ) . should ( 'contain ' , '2' ) ;
485+ cartRows ( ) . should ( 'have.length ' , 2 ) ;
472486
473487 // first cart item check and modify the selection
474488 cy . get ( 'td .ui.selection.dropdown.layer-selector' )
@@ -514,7 +528,7 @@ describe('Cart Tests', () => {
514528
515529 cy . get ( '.ui.container h1' ) . should ( 'contain' , 'Cart' ) ;
516530 cy . get ( '.ui.container .ccl-container h2' ) . should ( 'contain' , 'Empty cart' ) ;
517- cy . get ( 'li a.header-login-link strong' ) . should ( 'contain' , '0' ) ;
531+ assertEmptyCart ( ) ;
518532 } ) ;
519533
520534 it ( 'Test Collection selector' , ( ) => {
@@ -528,7 +542,7 @@ describe('Cart Tests', () => {
528542 } ) ;
529543
530544 cy . wait ( '@projections' ) ;
531- cy . get ( 'li a.header-login-link strong' ) . should ( 'contain ' , '2' ) ;
545+ cartRows ( ) . should ( 'have.length ' , 2 ) ;
532546
533547 // first cart item check and modify the selectors
534548 cy . get ( 'td .ui.selection.dropdown.collection-selector' )
@@ -572,7 +586,7 @@ describe('Cart Tests', () => {
572586
573587 cy . get ( '.ui.container h1' ) . should ( 'contain' , 'Cart' ) ;
574588 cy . get ( '.ui.container .ccl-container h2' ) . should ( 'contain' , 'Empty cart' ) ;
575- cy . get ( 'li a.header-login-link strong' ) . should ( 'contain' , '0' ) ;
589+ assertEmptyCart ( ) ;
576590 } ) ;
577591
578592 it ( 'Test Type and Format selectors' , ( ) => {
@@ -586,7 +600,7 @@ describe('Cart Tests', () => {
586600 } ) ;
587601
588602 cy . wait ( '@projections' ) ;
589- cy . get ( 'li a.header-login-link strong' ) . should ( 'contain ' , '2' ) ;
603+ cartRows ( ) . should ( 'have.length ' , 2 ) ;
590604 cy . get ( 'td .collection-container' ) . eq ( 0 ) . should ( 'have.text' , '-' ) ;
591605 cy . get ( 'td .ui.selection.dropdown.format-selector' )
592606 . eq ( 0 )
@@ -645,7 +659,7 @@ describe('Cart Tests', () => {
645659
646660 cy . get ( '.ui.container h1' ) . should ( 'contain' , 'Cart' ) ;
647661 cy . get ( '.ui.container .ccl-container h2' ) . should ( 'contain' , 'Empty cart' ) ;
648- cy . get ( 'li a.header-login-link strong' ) . should ( 'contain' , '0' ) ;
662+ assertEmptyCart ( ) ;
649663 } ) ;
650664
651665 it ( 'Test Cart pagination and clearing' , ( ) => {
@@ -659,13 +673,13 @@ describe('Cart Tests', () => {
659673 } ) ;
660674
661675 cy . wait ( '@projections' ) ;
662- cy . get ( 'li a.header-login-link strong' ) . should ( 'contain ' , '10' ) ;
676+ cartRows ( ) . should ( 'have.length ' , 10 ) ;
663677 cy . get ( '.pagination-wrapper' ) . should ( 'not.exist' ) ;
664678 cy . get ( 'tbody' ) . find ( 'tr' ) . should ( 'have.length' , 10 ) ;
665679
666680 // Duplicate the last element
667681 cy . get ( 'td.text-end' ) . eq ( 3 ) . find ( '.info-icon' ) . eq ( 0 ) . find ( 'button' ) . click ( ) ;
668- cy . get ( 'li a.header-login-link strong' ) . should ( 'contain ' , '11' ) ;
682+ cartRows ( ) . should ( 'have.length ' , 10 ) ;
669683 cy . get ( '.pagination-wrapper' ) . should ( 'exist' ) ;
670684 cy . get ( 'tbody' ) . find ( 'tr' ) . should ( 'have.length' , 10 ) ;
671685
@@ -680,27 +694,27 @@ describe('Cart Tests', () => {
680694
681695 //Remove all the elements
682696 cy . get ( 'td.text-end' ) . eq ( 0 ) . find ( '.info-icon' ) . eq ( 1 ) . find ( 'button' ) . click ( ) ;
683- cy . get ( 'li a.header-login-link strong' ) . should ( 'contain ' , '9' ) ;
697+ cartRows ( ) . should ( 'have.length ' , 9 ) ;
684698 cy . get ( 'td.text-end' ) . eq ( 0 ) . find ( '.info-icon' ) . eq ( 1 ) . find ( 'button' ) . click ( ) ;
685- cy . get ( 'li a.header-login-link strong' ) . should ( 'contain ' , '8' ) ;
699+ cartRows ( ) . should ( 'have.length ' , 8 ) ;
686700 cy . get ( 'td.text-end' ) . eq ( 0 ) . find ( '.info-icon' ) . eq ( 1 ) . find ( 'button' ) . click ( ) ;
687- cy . get ( 'li a.header-login-link strong' ) . should ( 'contain ' , '7' ) ;
701+ cartRows ( ) . should ( 'have.length ' , 7 ) ;
688702 cy . get ( 'td.text-end' ) . eq ( 0 ) . find ( '.info-icon' ) . eq ( 1 ) . find ( 'button' ) . click ( ) ;
689- cy . get ( 'li a.header-login-link strong' ) . should ( 'contain ' , '6' ) ;
703+ cartRows ( ) . should ( 'have.length ' , 6 ) ;
690704 cy . get ( 'td.text-end' ) . eq ( 0 ) . find ( '.info-icon' ) . eq ( 1 ) . find ( 'button' ) . click ( ) ;
691- cy . get ( 'li a.header-login-link strong' ) . should ( 'contain ' , '5' ) ;
705+ cartRows ( ) . should ( 'have.length ' , 5 ) ;
692706 cy . get ( 'td.text-end' ) . eq ( 0 ) . find ( '.info-icon' ) . eq ( 1 ) . find ( 'button' ) . click ( ) ;
693- cy . get ( 'li a.header-login-link strong' ) . should ( 'contain ' , '4' ) ;
707+ cartRows ( ) . should ( 'have.length ' , 4 ) ;
694708 cy . get ( 'td.text-end' ) . eq ( 0 ) . find ( '.info-icon' ) . eq ( 1 ) . find ( 'button' ) . click ( ) ;
695- cy . get ( 'li a.header-login-link strong' ) . should ( 'contain ' , '3' ) ;
709+ cartRows ( ) . should ( 'have.length ' , 3 ) ;
696710 cy . get ( 'td.text-end' ) . eq ( 0 ) . find ( '.info-icon' ) . eq ( 1 ) . find ( 'button' ) . click ( ) ;
697- cy . get ( 'li a.header-login-link strong' ) . should ( 'contain ' , '2' ) ;
711+ cartRows ( ) . should ( 'have.length ' , 2 ) ;
698712 cy . get ( 'td.text-end' ) . eq ( 0 ) . find ( '.info-icon' ) . eq ( 1 ) . find ( 'button' ) . click ( ) ;
699- cy . get ( 'li a.header-login-link strong' ) . should ( 'contain ' , '1' ) ;
713+ cartRows ( ) . should ( 'have.length ' , 1 ) ;
700714 cy . get ( 'td.text-end' ) . eq ( 0 ) . find ( '.info-icon' ) . eq ( 1 ) . find ( 'button' ) . click ( ) ;
701715 cy . get ( '.ui.container h1' ) . should ( 'contain' , 'Cart' ) ;
702716 cy . get ( '.ui.container .ccl-container h2' ) . should ( 'contain' , 'Empty cart' ) ;
703- cy . get ( 'li a.header-login-link strong' ) . should ( 'contain' , '0' ) ;
717+ assertEmptyCart ( ) ;
704718 } ) ;
705719
706720 it ( 'Test Cart downloading dataset with auxiliary calendar without dates' , ( ) => {
@@ -713,7 +727,7 @@ describe('Cart Tests', () => {
713727 } ,
714728 } ) ;
715729 cy . wait ( '@projections' ) ;
716- cy . get ( 'li a.header-login-link strong' ) . should ( 'contain ' , '1' ) ;
730+ cartRows ( ) . should ( 'have.length ' , 1 ) ;
717731
718732 cy . get ( 'td.table-td-timeseries' )
719733 . eq ( 0 )
@@ -768,6 +782,6 @@ describe('Cart Tests', () => {
768782
769783 cy . get ( '.ui.container h1' ) . should ( 'contain' , 'Cart' ) ;
770784 cy . get ( '.ui.container .ccl-container h2' ) . should ( 'contain' , 'Empty cart' ) ;
771- cy . get ( 'li a.header-login-link strong' ) . should ( 'contain' , '0' ) ;
785+ assertEmptyCart ( ) ;
772786 } ) ;
773787} ) ;
0 commit comments