@@ -133,6 +133,71 @@ describe('workflows', () => {
133
133
] ) ;
134
134
} ) ;
135
135
136
+ test ( 'Calls expected functions with non-uuid instance id' , async ( ) => {
137
+ class BasicTestWorkflow {
138
+ constructor ( _ctx : ExecutionContext , _env : unknown ) { }
139
+
140
+ async run ( _event : Readonly < WorkflowEvent < Params > > , step : WorkflowStep ) : Promise < void > {
141
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
142
+ const files = await step . do ( 'first step' , async ( ) => {
143
+ return { files : [ 'doc_7392_rev3.pdf' , 'report_x29_final.pdf' ] } ;
144
+ } ) ;
145
+ }
146
+ }
147
+
148
+ const TestWorkflowInstrumented = instrumentWorkflowWithSentry ( getSentryOptions , BasicTestWorkflow as any ) ;
149
+ const workflow = new TestWorkflowInstrumented ( mockContext , { } ) as BasicTestWorkflow ;
150
+ const event = { payload : { } , timestamp : new Date ( ) , instanceId : 'ae0ee067' } ;
151
+ await workflow . run ( event , mockStep ) ;
152
+
153
+ expect ( mockStep . do ) . toHaveBeenCalledTimes ( 1 ) ;
154
+ expect ( mockStep . do ) . toHaveBeenCalledWith ( 'first step' , expect . any ( Function ) ) ;
155
+ expect ( mockContext . waitUntil ) . toHaveBeenCalledTimes ( 1 ) ;
156
+ expect ( mockContext . waitUntil ) . toHaveBeenCalledWith ( expect . any ( Promise ) ) ;
157
+ expect ( mockTransport . send ) . toHaveBeenCalledTimes ( 1 ) ;
158
+ expect ( mockTransport . send ) . toHaveBeenCalledWith ( [
159
+ expect . objectContaining ( {
160
+ trace : expect . objectContaining ( {
161
+ transaction : 'first step' ,
162
+ trace_id : '0d2b6d1743ce6d53af4f5ee416ad5d1b' ,
163
+ sample_rand : '0.3636987869077592' ,
164
+ } ) ,
165
+ } ) ,
166
+ [
167
+ [
168
+ {
169
+ type : 'transaction' ,
170
+ } ,
171
+ expect . objectContaining ( {
172
+ event_id : expect . any ( String ) ,
173
+ contexts : {
174
+ trace : {
175
+ parent_span_id : undefined ,
176
+ span_id : expect . any ( String ) ,
177
+ trace_id : '0d2b6d1743ce6d53af4f5ee416ad5d1b' ,
178
+ data : {
179
+ 'sentry.origin' : 'auto.faas.cloudflare.workflow' ,
180
+ 'sentry.op' : 'function.step.do' ,
181
+ 'sentry.source' : 'task' ,
182
+ 'sentry.sample_rate' : 1 ,
183
+ } ,
184
+ op : 'function.step.do' ,
185
+ status : 'ok' ,
186
+ origin : 'auto.faas.cloudflare.workflow' ,
187
+ } ,
188
+ cloud_resource : { 'cloud.provider' : 'cloudflare' } ,
189
+ runtime : { name : 'cloudflare' } ,
190
+ } ,
191
+ type : 'transaction' ,
192
+ transaction_info : { source : 'task' } ,
193
+ start_timestamp : expect . any ( Number ) ,
194
+ timestamp : expect . any ( Number ) ,
195
+ } ) ,
196
+ ] ,
197
+ ] ,
198
+ ] ) ;
199
+ } ) ;
200
+
136
201
class ErrorTestWorkflow {
137
202
count = 0 ;
138
203
constructor ( _ctx : ExecutionContext , _env : unknown ) { }
0 commit comments