@@ -179,6 +179,7 @@ class MyReporter {
179179 debug ( `Exception in populating test data for hook skipped test with error : ${ err } ` , true , err ) ;
180180 }
181181
182+ await this . uploadTestSteps ( ) ;
182183 await requestQueueHandler . shutdown ( ) ;
183184 } ) ;
184185 }
@@ -224,14 +225,14 @@ class MyReporter {
224225 }
225226 }
226227
227- uploadTestSteps = async ( test_run_uuid = null , hook_run_uuid = null , shouldClearCurrentSteps = true , cypressSteps = null ) => {
228+ uploadTestSteps = async ( shouldClearCurrentSteps = true , cypressSteps = null ) => {
228229 const currentTestSteps = cypressSteps ? cypressSteps : JSON . parse ( JSON . stringify ( this . currentTestSteps ) ) ;
229230 /* TODO - Send as test logs */
230231 const allStepsAsLogs = [ ] ;
231232 currentTestSteps . forEach ( step => {
232233 const currentStepAsLog = {
233- test_run_uuid,
234- hook_run_uuid,
234+ test_run_uuid : step . test_run_uuid ,
235+ hook_run_uuid : step . hook_run_uuid ,
235236 timestamp : step . started_at ,
236237 level : step . result ,
237238 message : step . text ,
@@ -240,7 +241,6 @@ class MyReporter {
240241 } ;
241242 allStepsAsLogs . push ( currentStepAsLog ) ;
242243 } ) ;
243- if ( currentTestSteps . length ) consoleHolder . log ( `\n SENDING BELOW STEPS FOR Test = ${ test_run_uuid } OR Hook = ${ hook_run_uuid } \n ${ JSON . stringify ( currentTestSteps , 0 , 3 ) } \n` ) ;
244244 await uploadEventData ( {
245245 event_type : 'LogCreated' ,
246246 logs : allStepsAsLogs
@@ -396,10 +396,8 @@ class MyReporter {
396396 } else {
397397 await uploadEventData ( uploadData ) ;
398398
399- if ( eventType == 'HookRunFinished' ) {
400- await this . uploadTestSteps ( null , testData [ 'uuid' ] ) ;
401- } else if ( eventType == 'TestRunFinished' ) {
402- await this . uploadTestSteps ( testData [ 'uuid' ] ) ;
399+ if ( eventType . match ( / F i n i s h e d / ) ) {
400+ await this . uploadTestSteps ( ) ;
403401 }
404402
405403 if ( eventType . match ( / T e s t R u n / ) ) {
@@ -408,7 +406,7 @@ class MyReporter {
408406 delete hookUploadObj . cypressSteps ;
409407 hookUploadObj [ 'hook_run' ] [ 'test_run_id' ] = test . testAnalyticsId ;
410408 await uploadEventData ( hookUploadObj ) ;
411- await this . uploadTestSteps ( null , hookUploadObj [ 'hook_run' ] [ 'uuid' ] , false , currentTestSteps ) ;
409+ await this . uploadTestSteps ( false , currentTestSteps ) ;
412410 } ) ;
413411 this . beforeHooks = [ ] ;
414412 }
@@ -544,16 +542,20 @@ class MyReporter {
544542 return ;
545543 }
546544
545+ const currentStepObj = {
546+ id : command . attributes . id ,
547+ text : 'cy.' + command . attributes . name + '(' + this . getFormattedArgs ( command . attributes . args ) + ')' ,
548+ started_at : new Date ( ) . toISOString ( ) ,
549+ finished_at : null ,
550+ duration : null ,
551+ result : 'pending' ,
552+ test_run_uuid : this . current_test ?. testAnalyticsId && ! this . runStatusMarkedHash [ this . current_test . testAnalyticsId ] ? this . current_test . testAnalyticsId : null ,
553+ hook_run_uuid : this . current_hook ?. hookAnalyticsId && ! this . runStatusMarkedHash [ this . current_hook . hookAnalyticsId ] ? this . current_hook . hookAnalyticsId : null
554+ } ;
555+ if ( currentStepObj . hook_run_uuid && currentStepObj . test_run_uuid ) delete currentStepObj . test_run_uuid ;
547556 this . currentTestSteps = [
548557 ...this . currentTestSteps ,
549- {
550- id : command . attributes . id ,
551- text : 'cy.' + command . attributes . name + '(' + this . getFormattedArgs ( command . attributes . args ) + ')' ,
552- started_at : new Date ( ) . toISOString ( ) ,
553- finished_at : null ,
554- duration : null ,
555- result : 'pending'
556- }
558+ currentStepObj
557559 ] ;
558560 } else if ( type == 'COMMAND_END' ) {
559561 let stepUpdated = false ;
@@ -571,16 +573,20 @@ class MyReporter {
571573
572574 if ( ! stepUpdated ) {
573575 /* COMMAND_END reported before COMMAND_START */
576+ const currentStepObj = {
577+ id : command . attributes . id ,
578+ text : 'cy.' + command . attributes . name + '(' + this . getFormattedArgs ( command . attributes . args ) + ')' ,
579+ started_at : new Date ( ) . toISOString ( ) ,
580+ finished_at : new Date ( ) . toISOString ( ) ,
581+ duration : 0 ,
582+ result : command . state ,
583+ test_run_uuid : this . current_test ?. testAnalyticsId && ! this . runStatusMarkedHash [ this . current_test . testAnalyticsId ] ? this . current_test . testAnalyticsId : null ,
584+ hook_run_uuid : this . current_hook ?. hookAnalyticsId && ! this . runStatusMarkedHash [ this . current_hook . hookAnalyticsId ] ? this . current_hook . hookAnalyticsId : null
585+ } ;
586+ if ( currentStepObj . hook_run_uuid && currentStepObj . test_run_uuid ) delete currentStepObj . test_run_uuid ;
574587 this . currentTestSteps = [
575588 ...this . currentTestSteps ,
576- {
577- id : command . attributes . id ,
578- text : 'cy.' + command . attributes . name + '(' + this . getFormattedArgs ( command . attributes . args ) + ')' ,
579- started_at : new Date ( ) . toISOString ( ) ,
580- finished_at : new Date ( ) . toISOString ( ) ,
581- duration : 0 ,
582- result : command . state
583- }
589+ currentStepObj
584590 ] ;
585591 }
586592 } else if ( type == 'COMMAND_RETRY' ) {
0 commit comments