@@ -66,7 +66,11 @@ function specShouldShow (specFileName: string, runDotsClasses: string[], latestR
66
66
}
67
67
68
68
function simulateRunData ( ) {
69
- cy . remoteGraphQLIntercept ( async ( obj ) => {
69
+ cy . remoteGraphQLInterceptBatched ( async ( obj ) => {
70
+ if ( obj . field !== 'cloudSpecByPath' ) {
71
+ return obj . result
72
+ }
73
+
70
74
const fakeRuns = ( statuses : string [ ] , idPrefix : string ) => {
71
75
return statuses . map ( ( s , idx ) => {
72
76
return {
@@ -107,34 +111,30 @@ function simulateRunData () {
107
111
} )
108
112
}
109
113
110
- if ( obj . result . data && 'cloudSpecByPath' in obj . result . data ) {
111
- // simulate network latency to allow for caching to register
112
- await new Promise ( ( r ) => setTimeout ( r , 20 ) )
113
-
114
- const statuses = obj . variables . specPath ?. includes ( 'accounts_list.spec.js' ) ?
115
- [ 'PASSED' , 'FAILED' , 'CANCELLED' , 'ERRORED' ] :
116
- obj . variables . specPath ?. includes ( 'app.spec.js' ) ?
117
- [ ] :
118
- [ 'RUNNING' , 'PASSED' ]
119
-
120
- const runs = fakeRuns ( statuses , obj . variables . specPath )
121
- const averageDuration = obj . variables . specPath ?. includes ( 'accounts_list.spec.js' ) ?
122
- 12000 : // 0:12
123
- 123000 // 2:03
124
-
125
- obj . result . data . cloudSpecByPath = {
126
- __typename : 'CloudProjectSpec' ,
127
- retrievedAt : new Date ( ) . toISOString ( ) ,
128
- id : `id${ obj . variables . specPath } ` ,
129
- specRuns : {
130
- __typename : 'CloudSpecRunConnection' ,
131
- nodes : runs ,
132
- } ,
133
- averageDuration,
134
- }
114
+ // simulate network latency to allow for caching to register
115
+ await new Promise ( ( r ) => setTimeout ( r , 20 ) )
116
+
117
+ const statuses = obj . variables . specPath ?. includes ( 'accounts_list.spec.js' ) ?
118
+ [ 'PASSED' , 'FAILED' , 'CANCELLED' , 'ERRORED' ] :
119
+ obj . variables . specPath ?. includes ( 'app.spec.js' ) ?
120
+ [ ] :
121
+ [ 'RUNNING' , 'PASSED' ]
122
+
123
+ const runs = fakeRuns ( statuses , obj . variables . specPath )
124
+ const averageDuration = obj . variables . specPath ?. includes ( 'accounts_list.spec.js' ) ?
125
+ 12000 : // 0:12
126
+ 123000 // 2:03
127
+
128
+ return {
129
+ __typename : 'CloudProjectSpec' ,
130
+ retrievedAt : new Date ( ) . toISOString ( ) ,
131
+ id : `id${ obj . variables . specPath } ` ,
132
+ specRuns : {
133
+ __typename : 'CloudSpecRunConnection' ,
134
+ nodes : runs ,
135
+ } ,
136
+ averageDuration,
135
137
}
136
-
137
- return obj . result
138
138
} )
139
139
}
140
140
@@ -163,21 +163,12 @@ describe('App/Cloud Integration - Latest runs and Average duration', { viewportW
163
163
it ( 'shows placeholders for all visible specs' , { defaultCommandTimeout : 6000 } , ( ) => {
164
164
cy . loginUser ( )
165
165
166
- cy . remoteGraphQLIntercept ( async ( obj ) => {
167
- if ( obj . result . data && 'cloudSpecByPath' in obj . result . data ) {
168
- obj . result . data . cloudSpecByPath = {
169
- __typename : 'CloudProjectSpecNotFound' ,
170
- retrievedAt : new Date ( ) . toISOString ( ) ,
171
- id : `id${ obj . variables . specPath } ` ,
172
- specRuns : {
173
- __typename : 'CloudSpecRunConnection' ,
174
- nodes : [ ] ,
175
- } ,
176
- averageDuration : null ,
177
- }
166
+ cy . remoteGraphQLInterceptBatched ( async ( obj ) => {
167
+ return {
168
+ __typename : 'CloudProjectSpecNotFound' ,
169
+ retrievedAt : new Date ( ) . toISOString ( ) ,
170
+ message : 'Spec Not Found' ,
178
171
}
179
-
180
- return obj . result
181
172
} )
182
173
183
174
cy . visitApp ( )
@@ -350,6 +341,7 @@ describe('App/Cloud Integration - Latest runs and Average duration', { viewportW
350
341
cy . get ( '.v-popper__popper--shown' ) . should ( 'not.exist' )
351
342
cy . get ( dotSelector ( 'app.spec.js' , 'latest' ) ) . trigger ( 'mouseleave' )
352
343
344
+ cy . get ( '.spec-list-container' ) . scrollTo ( 'top' )
353
345
// oldest 2 status dots will use placeholder
354
346
specShouldShow ( 'accounts_new.spec.js' , [ 'gray-300' , 'gray-300' , 'jade-400' ] , 'RUNNING' )
355
347
cy . get ( dotSelector ( 'accounts_new.spec.js' , 'latest' ) ) . trigger ( 'mouseenter' )
@@ -436,6 +428,30 @@ describe('App/Cloud Integration - Latest runs and Average duration', { viewportW
436
428
cy . loginUser ( )
437
429
438
430
cy . remoteGraphQLIntercept ( async ( obj , testState ) => {
431
+ const pollingCounter = testState . pollingCounter ?? 0
432
+
433
+ if ( obj . result . data && 'cloudLatestRunUpdateSpecData' in obj . result . data ) {
434
+ const mostRecentUpdate = pollingCounter > 1 ? new Date ( ) . toISOString ( ) : new Date ( '2022-06-10' ) . toISOString ( )
435
+ // initial polling interval is set to every second to avoid long wait times
436
+ const pollingInterval = pollingCounter > 1 ? 30 : 1
437
+
438
+ obj . result . data . cloudLatestRunUpdateSpecData = {
439
+ __typename : 'CloudLatestRunUpdateSpecData' ,
440
+ mostRecentUpdate,
441
+ pollingInterval,
442
+ }
443
+
444
+ testState . pollingCounter = pollingCounter + 1
445
+ }
446
+
447
+ return obj . result
448
+ } )
449
+
450
+ cy . remoteGraphQLInterceptBatched ( async ( obj , testState ) => {
451
+ if ( obj . field !== 'cloudSpecByPath' ) {
452
+ return obj . result
453
+ }
454
+
439
455
const fakeRuns = ( statuses : string [ ] , idPrefix : string ) => {
440
456
return statuses . map ( ( s , idx ) => {
441
457
return {
@@ -478,39 +494,23 @@ describe('App/Cloud Integration - Latest runs and Average duration', { viewportW
478
494
479
495
const pollingCounter = testState . pollingCounter ?? 0
480
496
481
- if ( obj . result . data && 'cloudSpecByPath' in obj . result . data ) {
482
- // simulate network latency to allow for caching to register
483
- await new Promise ( ( r ) => setTimeout ( r , 20 ) )
484
-
485
- const statuses = pollingCounter < 2 ? [ 'PASSED' , 'FAILED' , 'CANCELLED' , 'ERRORED' ] : [ 'FAILED' , 'PASSED' , 'FAILED' , 'CANCELLED' , 'ERRORED' ]
486
- const runs = fakeRuns ( statuses , obj . variables . specPath )
487
- const averageDuration = pollingCounter < 2 ? 12000 : 13000
488
-
489
- obj . result . data . cloudSpecByPath = {
490
- __typename : 'CloudProjectSpec' ,
491
- retrievedAt : new Date ( ) . toISOString ( ) ,
492
- id : `id${ obj . variables . specPath } ` ,
493
- specRuns : {
494
- __typename : 'CloudSpecRunConnection' ,
495
- nodes : runs ,
496
- } ,
497
- averageDuration,
498
- }
499
- } else if ( obj . result . data && 'cloudLatestRunUpdateSpecData' in obj . result . data ) {
500
- const mostRecentUpdate = pollingCounter > 1 ? new Date ( ) . toISOString ( ) : new Date ( '2022-06-10' ) . toISOString ( )
501
- // initial polling interval is set to every second to avoid long wait times
502
- const pollingInterval = pollingCounter > 1 ? 30 : 1
497
+ // simulate network latency to allow for caching to register
498
+ await new Promise ( ( r ) => setTimeout ( r , 20 ) )
503
499
504
- obj . result . data . cloudLatestRunUpdateSpecData = {
505
- __typename : 'CloudLatestRunUpdateSpecData' ,
506
- mostRecentUpdate,
507
- pollingInterval,
508
- }
500
+ const statuses = pollingCounter < 2 ? [ 'PASSED' , 'FAILED' , 'CANCELLED' , 'ERRORED' ] : [ 'FAILED' , 'PASSED' , 'FAILED' , 'CANCELLED' , 'ERRORED' ]
501
+ const runs = fakeRuns ( statuses , obj . variables . specPath )
502
+ const averageDuration = pollingCounter < 2 ? 12000 : 13000
509
503
510
- testState . pollingCounter = pollingCounter + 1
504
+ return {
505
+ __typename : 'CloudProjectSpec' ,
506
+ retrievedAt : new Date ( ) . toISOString ( ) ,
507
+ id : `id${ obj . variables . specPath } ` ,
508
+ specRuns : {
509
+ __typename : 'CloudSpecRunConnection' ,
510
+ nodes : runs ,
511
+ } ,
512
+ averageDuration,
511
513
}
512
-
513
- return obj . result
514
514
} )
515
515
516
516
cy . visitApp ( )
@@ -542,6 +542,30 @@ describe('App/Cloud Integration - Latest runs and Average duration', { viewportW
542
542
cy . loginUser ( )
543
543
544
544
cy . remoteGraphQLIntercept ( async ( obj , testState ) => {
545
+ const pollingCounter = testState . pollingCounter ?? 0
546
+
547
+ if ( obj . result . data && 'cloudLatestRunUpdateSpecData' in obj . result . data ) {
548
+ const mostRecentUpdate = new Date ( '2022-06-10' ) . toISOString ( )
549
+ // initial polling interval is set to every second to avoid long wait times
550
+ const pollingInterval = pollingCounter > 1 ? 30 : 1
551
+
552
+ obj . result . data . cloudLatestRunUpdateSpecData = {
553
+ __typename : 'CloudLatestRunUpdateSpecData' ,
554
+ mostRecentUpdate,
555
+ pollingInterval,
556
+ }
557
+
558
+ testState . pollingCounter = pollingCounter + 1
559
+ }
560
+
561
+ return obj . result
562
+ } )
563
+
564
+ cy . remoteGraphQLInterceptBatched ( async ( obj , testState ) => {
565
+ if ( obj . field !== 'cloudSpecByPath' ) {
566
+ return obj . result
567
+ }
568
+
545
569
const fakeRuns = ( statuses : string [ ] , idPrefix : string ) => {
546
570
return statuses . map ( ( s , idx ) => {
547
571
return {
@@ -584,39 +608,23 @@ describe('App/Cloud Integration - Latest runs and Average duration', { viewportW
584
608
585
609
const pollingCounter = testState . pollingCounter ?? 0
586
610
587
- if ( obj . result . data && 'cloudSpecByPath' in obj . result . data ) {
588
- // simulate network latency to allow for caching to register
589
- await new Promise ( ( r ) => setTimeout ( r , 20 ) )
590
-
591
- const statuses = pollingCounter < 2 ? [ 'PASSED' , 'FAILED' , 'CANCELLED' , 'ERRORED' ] : [ 'FAILED' , 'PASSED' , 'FAILED' , 'CANCELLED' , 'ERRORED' ]
592
- const runs = fakeRuns ( statuses , obj . variables . specPath )
593
- const averageDuration = pollingCounter < 2 ? 12000 : 13000
594
-
595
- obj . result . data . cloudSpecByPath = {
596
- __typename : 'CloudProjectSpec' ,
597
- retrievedAt : new Date ( ) . toISOString ( ) ,
598
- id : `id${ obj . variables . specPath } ` ,
599
- specRuns : {
600
- __typename : 'CloudSpecRunConnection' ,
601
- nodes : runs ,
602
- } ,
603
- averageDuration,
604
- }
605
- } else if ( obj . result . data && 'cloudLatestRunUpdateSpecData' in obj . result . data ) {
606
- const mostRecentUpdate = new Date ( '2022-06-10' ) . toISOString ( )
607
- // initial polling interval is set to every second to avoid long wait times
608
- const pollingInterval = pollingCounter > 1 ? 30 : 1
611
+ // simulate network latency to allow for caching to register
612
+ await new Promise ( ( r ) => setTimeout ( r , 20 ) )
609
613
610
- obj . result . data . cloudLatestRunUpdateSpecData = {
611
- __typename : 'CloudLatestRunUpdateSpecData' ,
612
- mostRecentUpdate,
613
- pollingInterval,
614
- }
614
+ const statuses = pollingCounter < 2 ? [ 'PASSED' , 'FAILED' , 'CANCELLED' , 'ERRORED' ] : [ 'FAILED' , 'PASSED' , 'FAILED' , 'CANCELLED' , 'ERRORED' ]
615
+ const runs = fakeRuns ( statuses , obj . variables . specPath )
616
+ const averageDuration = pollingCounter < 2 ? 12000 : 13000
615
617
616
- testState . pollingCounter = pollingCounter + 1
618
+ return {
619
+ __typename : 'CloudProjectSpec' ,
620
+ retrievedAt : new Date ( ) . toISOString ( ) ,
621
+ id : `id${ obj . variables . specPath } ` ,
622
+ specRuns : {
623
+ __typename : 'CloudSpecRunConnection' ,
624
+ nodes : runs ,
625
+ } ,
626
+ averageDuration,
617
627
}
618
-
619
- return obj . result
620
628
} )
621
629
622
630
cy . visitApp ( )
0 commit comments