@@ -11,14 +11,7 @@ describe('Rates', () => {
1111 } ) ;
1212
1313 it ( 'Loads the default compute chargeback rate' , ( ) => {
14- cy . get ( '.clickable-row' ) . then ( ( rows ) => {
15- const nums = [ ...Array ( rows . length ) . keys ( ) ] ;
16- nums . forEach ( ( index ) => {
17- if ( rows [ index ] . children [ 1 ] . innerText === 'Default' && rows [ index ] . children [ 2 ] . innerText === 'Compute' ) {
18- cy . get ( rows [ index ] ) . click ( ) ;
19- }
20- } ) ;
21- } ) . then ( ( ) => {
14+ cy . gtlClickRow ( [ { title : 'Default' , number : 1 } , { title : 'Compute' , number : 2 } ] ) . then ( ( ) => {
2215 cy . get ( ':nth-child(1) > .col-md-8 > .form-control-static' ) . contains ( 'Default' ) ;
2316 cy . get ( ':nth-child(2) > .col-md-8 > .form-control-static' ) . contains ( 'Compute' ) ;
2417
@@ -127,14 +120,7 @@ describe('Rates', () => {
127120 } ) ;
128121
129122 it ( 'Loads the default storage chargeback rate' , ( ) => {
130- cy . get ( '.clickable-row' ) . then ( ( rows ) => {
131- const nums = [ ...Array ( rows . length ) . keys ( ) ] ;
132- nums . forEach ( ( index ) => {
133- if ( rows [ index ] . children [ 1 ] . innerText === 'Default' && rows [ index ] . children [ 2 ] . innerText === 'Storage' ) {
134- cy . get ( rows [ index ] ) . click ( ) ;
135- }
136- } ) ;
137- } ) . then ( ( ) => {
123+ cy . gtlClickRow ( [ { title : 'Default' , number : 1 } , { title : 'Storage' , number : 2 } ] ) . then ( ( ) => {
138124 cy . get ( ':nth-child(1) > .col-md-8 > .form-control-static' ) . contains ( 'Default' ) ;
139125 cy . get ( ':nth-child(2) > .col-md-8 > .form-control-static' ) . contains ( 'Storage' ) ;
140126
@@ -185,14 +171,7 @@ describe('Rates', () => {
185171 } ) ;
186172
187173 it ( 'Loads the default container image chargeback rate' , ( ) => {
188- cy . get ( '.clickable-row' ) . then ( ( rows ) => {
189- const nums = [ ...Array ( rows . length ) . keys ( ) ] ;
190- nums . forEach ( ( index ) => {
191- if ( rows [ index ] . children [ 1 ] . innerText === 'Default Container Image Rate' ) {
192- cy . get ( rows [ index ] ) . click ( ) ;
193- }
194- } ) ;
195- } ) . then ( ( ) => {
174+ cy . gtlClickRow ( [ { title : 'Default Container Image Rate' , number : 1 } ] ) . then ( ( ) => {
196175 cy . get ( ':nth-child(1) > .col-md-8 > .form-control-static' ) . contains ( 'Default Container Image Rate' ) ;
197176 cy . get ( ':nth-child(2) > .col-md-8 > .form-control-static' ) . contains ( 'Compute' ) ;
198177
@@ -301,24 +280,17 @@ describe('Rates', () => {
301280 } ) ;
302281
303282 it ( 'Cancel button works on the form' , ( ) => {
304- const rates = [ ] ;
305- cy . get ( '.clickable-row' ) . then ( ( rows ) => {
306- const nums = [ ...Array ( rows . length ) . keys ( ) ] ;
307- nums . forEach ( ( index ) => {
308- rates . push ( rows [ index ] . children [ 1 ] . innerText ) ;
309- } ) ;
310- } ) . then ( ( ) => {
283+ cy . gtlGetRows ( ) . then ( ( originalRates ) => {
311284 cy . get ( '#chargeback_rates_vmdb_choice' ) . click ( ) ;
312285 cy . get ( ':nth-child(1) > .bx--overflow-menu-options__btn > div' ) . click ( ) ;
313286 cy . get ( '[width="100%"] > tbody > tr > td > .btn-default' ) . click ( ) ;
314287 cy . get ( '.miq-toolbar-group' ) ;
315288 cy . url ( ) . should ( 'include' , 'chargeback_rate/show_list' ) ;
316289 cy . get ( '.alert' ) . contains ( 'Add of new Chargeback Rate was cancelled by the user' ) ;
317- cy . get ( '.clickable-row' ) . then ( ( rows ) => {
318- const nums = [ ...Array ( rows . length ) . keys ( ) ] ;
319- nums . forEach ( ( index ) => {
320- expect ( rates ) . to . include ( rows [ index ] . children [ 1 ] . innerText ) ;
321- rates . shift ( ) ;
290+ cy . gtlGetRows ( ) . then ( ( newRates ) => {
291+ newRates . forEach ( ( newRate ) => {
292+ expect ( originalRates ) . to . deep . include ( newRate ) ;
293+ originalRates . shift ( ) ;
322294 } ) ;
323295 } ) ;
324296 } ) ;
@@ -360,14 +332,7 @@ describe('Rates', () => {
360332
361333 cy . get ( '.btn-primary' ) . click ( ) ;
362334 cy . get ( '#gtl_div' ) . contains ( 'Cypress test compute chargeback rates' ) ;
363- cy . get ( '.clickable-row' ) . then ( ( rows ) => {
364- const nums = [ ...Array ( rows . length ) . keys ( ) ] ;
365- nums . forEach ( ( index ) => {
366- if ( rows [ index ] . children [ 1 ] . innerText === 'Cypress test compute chargeback rates' ) {
367- cy . get ( rows [ index ] ) . click ( ) ;
368- }
369- } ) ;
370- } ) . then ( ( ) => {
335+ cy . gtlClickRow ( [ { title : 'Cypress test compute chargeback rates' , number : 1 } ] ) . then ( ( ) => {
371336 cy . get ( ':nth-child(1) > .col-md-8 > .form-control-static' ) . contains ( 'Cypress test compute chargeback rates' ) ;
372337 cy . get ( ':nth-child(2) > .col-md-8 > .form-control-static' ) . contains ( 'Compute' ) ;
373338
@@ -634,11 +599,10 @@ describe('Rates', () => {
634599 } ) . then ( ( ) => {
635600 cy . get ( '#chargeback_rate_vmdb_choice' ) . click ( ) ;
636601 cy . get ( ':nth-child(3) > .bx--overflow-menu-options__btn' ) . click ( ) ;
637- cy . get ( '.clickable-row' ) . then ( ( rows ) => {
638- const nums = [ ...Array ( rows . length ) . keys ( ) ] ;
639- nums . forEach ( ( index ) => {
640- expect ( rows [ index ] . children [ 1 ] . innerText ) . to . not . eq ( 'Cypress test compute chargeback rates edit' ) ;
641- expect ( rows [ index ] . children [ 1 ] . innerText ) . to . not . eq ( 'Cypress test compute chargeback rates' ) ;
602+ cy . gtlGetRows ( ) . then ( ( rows ) => {
603+ rows . forEach ( ( row ) => {
604+ expect ( row ) . to . not . eq ( 'Cypress test compute chargeback rates edit' ) ;
605+ expect ( row ) . to . not . eq ( 'Cypress test compute chargeback rates' ) ;
642606 } ) ;
643607 } ) ;
644608 } ) ;
@@ -669,14 +633,7 @@ describe('Rates', () => {
669633 cy . get ( '#rate_detail_row_3_0 > .action-cell > .btn' ) . click ( ) ;
670634 cy . get ( '.btn-primary' ) . click ( ) ;
671635 cy . get ( '#gtl_div' ) . contains ( 'Cypress test storage chargeback rates' ) ;
672- cy . get ( '.clickable-row' ) . then ( ( rows ) => {
673- const nums = [ ...Array ( rows . length ) . keys ( ) ] ;
674- nums . forEach ( ( index ) => {
675- if ( rows [ index ] . children [ 1 ] . innerText === 'Cypress test storage chargeback rates' ) {
676- cy . get ( rows [ index ] ) . click ( ) ;
677- }
678- } ) ;
679- } ) . then ( ( ) => {
636+ cy . gtlClickRow ( [ { title : 'Cypress test storage chargeback rates' , number : 1 } ] ) . then ( ( ) => {
680637 cy . get ( ':nth-child(1) > .col-md-8 > .form-control-static' ) . contains ( 'Cypress test storage chargeback rates' ) ;
681638 cy . get ( ':nth-child(2) > .col-md-8 > .form-control-static' ) . contains ( 'Storage' ) ;
682639
@@ -809,24 +766,17 @@ describe('Rates', () => {
809766 } ) . then ( ( ) => {
810767 cy . get ( '#chargeback_rate_vmdb_choice' ) . click ( ) ;
811768 cy . get ( ':nth-child(3) > .bx--overflow-menu-options__btn' ) . click ( ) ;
812- cy . get ( '.clickable-row' ) . then ( ( rows ) => {
813- const nums = [ ...Array ( rows . length ) . keys ( ) ] ;
814- nums . forEach ( ( index ) => {
815- expect ( rows [ index ] . children [ 1 ] . innerText ) . to . not . eq ( 'Cypress test storage chargeback rates edit' ) ;
816- expect ( rows [ index ] . children [ 1 ] . innerText ) . to . not . eq ( 'Cypress test storage chargeback rates' ) ;
769+ cy . gtlGetRows ( ) . then ( ( rows ) => {
770+ rows . forEach ( ( row ) => {
771+ expect ( row ) . to . not . eq ( 'Cypress test storage chargeback rates edit' ) ;
772+ expect ( row ) . to . not . eq ( 'Cypress test storage chargeback rates' ) ;
817773 } ) ;
818774 } ) ;
819775 } ) ;
820776 } ) ;
821777
822778 it ( 'Copy a chargeback rate' , ( ) => {
823- cy . get ( '.clickable-row' ) . then ( ( rows ) => {
824- const nums = [ ...Array ( rows . length ) . keys ( ) ] ;
825- nums . forEach ( ( index ) => {
826- if ( rows [ index ] . children [ 1 ] . innerText === 'Default' && rows [ index ] . children [ 2 ] . innerText === 'Storage' ) {
827- cy . get ( rows [ index ] ) . click ( ) ;
828- }
829- } ) ;
779+ cy . gtlClickRow ( [ { title : 'Default' , number : 1 } , { title : 'Storage' , number : 2 } ] ) . then ( ( ) => {
830780 cy . get ( '#chargeback_rate_vmdb_choice' ) . click ( ) ;
831781 cy . get ( ':nth-child(2) > .bx--overflow-menu-options__btn' ) . click ( ) ;
832782 cy . get ( '.btn-primary' ) . click ( ) ;
@@ -879,10 +829,9 @@ describe('Rates', () => {
879829
880830 cy . get ( '#chargeback_rate_vmdb_choice' ) . click ( ) ;
881831 cy . get ( ':nth-child(3) > .bx--overflow-menu-options__btn' ) . click ( ) ;
882- cy . get ( '.clickable-row' ) . then ( ( rows ) => {
883- const nums = [ ...Array ( rows . length ) . keys ( ) ] ;
884- nums . forEach ( ( index ) => {
885- expect ( rows [ index ] . children [ 1 ] . innerText ) . to . not . eq ( 'copy of default' ) ;
832+ cy . gtlGetRows ( ) . then ( ( rows ) => {
833+ rows . forEach ( ( row ) => {
834+ expect ( row ) . to . not . eq ( 'copy of default' ) ;
886835 } ) ;
887836 } ) ;
888837 } ) ;
0 commit comments