@@ -57,6 +57,8 @@ export type ErrorDescription = {
57
57
prompt ?: trace . AfterActionTraceEventAttachment & { traceUrl : string } ;
58
58
} ;
59
59
60
+ export type Attachment = trace . AfterActionTraceEventAttachment & { traceUrl : string } ;
61
+
60
62
export class MultiTraceModel {
61
63
readonly startTime : number ;
62
64
readonly endTime : number ;
@@ -68,6 +70,8 @@ export class MultiTraceModel {
68
70
readonly options : trace . BrowserContextEventOptions ;
69
71
readonly pages : PageEntry [ ] ;
70
72
readonly actions : ActionTraceEventInContext [ ] ;
73
+ readonly attachments : Attachment [ ] ;
74
+ readonly visibleAttachments : Attachment [ ] ;
71
75
readonly events : ( trace . EventTraceEvent | trace . ConsoleMessageTraceEvent ) [ ] ;
72
76
readonly stdio : trace . StdioTraceEvent [ ] ;
73
77
readonly errors : trace . ErrorTraceEvent [ ] ;
@@ -103,6 +107,8 @@ export class MultiTraceModel {
103
107
this . hasSource = contexts . some ( c => c . hasSource ) ;
104
108
this . hasStepData = contexts . some ( context => context . origin === 'testRunner' ) ;
105
109
this . resources = [ ...contexts . map ( c => c . resources ) ] . flat ( ) ;
110
+ this . attachments = this . actions . flatMap ( action => action . attachments ?. map ( attachment => ( { ...attachment , traceUrl : action . context . traceUrl } ) ) ?? [ ] ) ;
111
+ this . visibleAttachments = this . attachments . filter ( attachment => ! attachment . name . startsWith ( '_' ) ) ;
106
112
107
113
this . events . sort ( ( a1 , a2 ) => a1 . time - a2 . time ) ;
108
114
this . resources . sort ( ( a1 , a2 ) => a1 . _monotonicTime ! - a2 . _monotonicTime ! ) ;
@@ -130,18 +136,10 @@ export class MultiTraceModel {
130
136
}
131
137
132
138
private _errorDescriptorsFromTestRunner ( ) : ErrorDescription [ ] {
133
- const errorPrompts : Record < string , trace . AfterActionTraceEventAttachment & { traceUrl : string } > = { } ;
134
- for ( const action of this . actions ) {
135
- for ( const attachment of action . attachments ?? [ ] ) {
136
- if ( attachment . name . startsWith ( '_prompt-' ) )
137
- errorPrompts [ attachment . name ] = { ...attachment , traceUrl : action . context . traceUrl } ;
138
- }
139
- }
140
-
141
139
return this . errors . filter ( e => ! ! e . message ) . map ( ( error , i ) => ( {
142
140
stack : error . stack ,
143
141
message : error . message ,
144
- prompt : errorPrompts [ `_prompt-${ i } ` ] ,
142
+ prompt : this . attachments . find ( a => a . name === `_prompt-${ i } ` ) ,
145
143
} ) ) ;
146
144
}
147
145
}
0 commit comments