@@ -69,21 +69,31 @@ export async function readReport(reportFolder: string): Promise<{
6969 const filenameToPath = new Map ( attachmentFiles . map ( file => [ path . basename ( file ) , file ] ) ) ;
7070 const attachmentIdToPath = new Map < FlakinessReport . AttachmentId , FileAttachment > ( ) ;
7171 const missingAttachments = new Map < FlakinessReport . AttachmentId , FlakinessReport . Attachment > ( ) ;
72+ const visitAttachment = ( attachment : FlakinessReport . Attachment ) => {
73+ const attachmentPath = filenameToPath . get ( attachment . id ) ;
74+ if ( ! attachmentPath ) {
75+ missingAttachments . set ( attachment . id , attachment ) ;
76+ } else {
77+ attachmentIdToPath . set ( attachment . id , {
78+ contentType : attachment . contentType ,
79+ id : attachment . id ,
80+ path : attachmentPath ,
81+ type : 'file' ,
82+ } ) ;
83+ }
84+ } ;
85+ const visitStep = ( step : FlakinessReport . TestStep ) => {
86+ for ( const attachment of step . attachments ?? [ ] )
87+ visitAttachment ( attachment ) ;
88+ for ( const childStep of step . steps ?? [ ] )
89+ visitStep ( childStep ) ;
90+ } ;
7291 visitTests ( report , ( test ) => {
7392 for ( const attempt of test . attempts ) {
74- for ( const attachment of attempt . attachments ?? [ ] ) {
75- const attachmentPath = filenameToPath . get ( attachment . id ) ;
76- if ( ! attachmentPath ) {
77- missingAttachments . set ( attachment . id , attachment ) ;
78- } else {
79- attachmentIdToPath . set ( attachment . id , {
80- contentType : attachment . contentType ,
81- id : attachment . id ,
82- path : attachmentPath ,
83- type : 'file' ,
84- } ) ;
85- }
86- }
93+ for ( const attachment of attempt . attachments ?? [ ] )
94+ visitAttachment ( attachment ) ;
95+ for ( const step of attempt . steps ?? [ ] )
96+ visitStep ( step ) ;
8797 }
8898 } ) ;
8999 return {
0 commit comments