@@ -10,14 +10,19 @@ import { CancelReason } from '@temporalio/worker/lib/activity';
10
10
import * as workflow from '@temporalio/workflow' ;
11
11
import { defineQuery , defineSignal , setHandler } from '@temporalio/workflow' ;
12
12
import { SdkFlags } from '@temporalio/workflow/lib/flags' ;
13
- import { ActivityCancellationType , ApplicationFailure , JsonPayloadConverter , WorkflowExecutionAlreadyStartedError } from '@temporalio/common' ;
13
+ import {
14
+ ActivityCancellationType ,
15
+ ApplicationFailure ,
16
+ JsonPayloadConverter ,
17
+ WorkflowExecutionAlreadyStartedError ,
18
+ } from '@temporalio/common' ;
19
+ import { temporal } from '@temporalio/proto' ;
14
20
import { signalSchedulingWorkflow } from './activities/helpers' ;
15
21
import { activityStartedSignal } from './workflows/definitions' ;
16
22
import * as workflows from './workflows' ;
17
23
import { Context , helpers , makeTestFunction } from './helpers-integration' ;
18
24
import { overrideSdkInternalFlag } from './mock-internal-flags' ;
19
25
import { asSdkLoggerSink , loadHistory , RUN_TIME_SKIPPING_TESTS } from './helpers' ;
20
- import { temporal } from '@temporalio/proto' ;
21
26
22
27
const test = makeTestFunction ( {
23
28
workflowsPath : __filename ,
@@ -1307,38 +1312,38 @@ test('Count workflow executions', async (t) => {
1307
1312
1308
1313
export async function userMetadataWorkflow ( ) : Promise < string > {
1309
1314
let done = false ;
1310
- const signalDef = defineSignal ( 'done' )
1311
- setHandler ( signalDef , ( ) => { done = true } )
1312
-
1315
+ const signalDef = defineSignal ( 'done' ) ;
1316
+ setHandler ( signalDef , ( ) => {
1317
+ done = true ;
1318
+ } ) ;
1319
+
1313
1320
// That workflow should call an activity (with summary)
1314
- const { activityWithSummary } = workflow
1315
- . proxyActivities ( { scheduleToCloseTimeout : '10s' } )
1316
- . withSummaries ( {
1317
- activityWithSummary : 'activity summary'
1318
- } )
1319
- await activityWithSummary ( )
1321
+ const { activityWithSummary } = workflow . proxyActivities ( { scheduleToCloseTimeout : '10s' } ) . withSummaries ( {
1322
+ activityWithSummary : 'activity summary' ,
1323
+ } ) ;
1324
+ await activityWithSummary ( ) ;
1320
1325
// Should have a timer (with summary)
1321
- await workflow . sleep ( 5 , " timer summary" )
1326
+ await workflow . sleep ( 5 , ' timer summary' ) ;
1322
1327
// Set current details
1323
1328
workflow . setCurrentDetails ( 'current wf details' ) ;
1324
1329
// Unblock on var -> query current details (or return)
1325
1330
await workflow . condition ( ( ) => done ) ;
1326
1331
return workflow . getCurrentDetails ( ) ;
1327
1332
}
1328
1333
1329
- test ( 'User metadata' , async ( t ) => {
1334
+ test ( 'User metadata on workflow, timer, activity ' , async ( t ) => {
1330
1335
const { createWorker, startWorkflow } = helpers ( t ) ;
1331
1336
const worker = await createWorker ( {
1332
1337
activities : {
1333
- async activityWithSummary ( ) { }
1334
- }
1338
+ async activityWithSummary ( ) { } ,
1339
+ } ,
1335
1340
} ) ;
1336
1341
1337
1342
await worker . runUntil ( async ( ) => {
1338
1343
// Start a workflow with static details
1339
1344
const handle = await startWorkflow ( userMetadataWorkflow , {
1340
- staticSummary : " wf static summary" ,
1341
- staticDetails : " wf static details"
1345
+ staticSummary : ' wf static summary' ,
1346
+ staticDetails : ' wf static details' ,
1342
1347
} ) ;
1343
1348
// Describe workflow -> static summary, static details
1344
1349
const desc = await handle . describe ( ) ;
@@ -1350,15 +1355,13 @@ test('User metadata', async (t) => {
1350
1355
t . true ( res === 'current wf details' ) ;
1351
1356
1352
1357
// Get history events for timer and activity summaries.
1353
- const resp = await t . context . env . client . workflowService . getWorkflowExecutionHistory (
1354
- {
1355
- namespace : t . context . env . client . options . namespace ,
1356
- execution : {
1357
- workflowId : handle . workflowId ,
1358
- runId : handle . firstExecutionRunId
1359
- } ,
1360
- }
1361
- ) ;
1358
+ const resp = await t . context . env . client . workflowService . getWorkflowExecutionHistory ( {
1359
+ namespace : t . context . env . client . options . namespace ,
1360
+ execution : {
1361
+ workflowId : handle . workflowId ,
1362
+ runId : handle . firstExecutionRunId ,
1363
+ } ,
1364
+ } ) ;
1362
1365
const jsonConverter = new JsonPayloadConverter ( ) ;
1363
1366
for ( const event of resp . history ?. events ?? [ ] ) {
1364
1367
if ( event . eventType === temporal . api . enums . v1 . EventType . EVENT_TYPE_WORKFLOW_EXECUTION_STARTED ) {
@@ -1372,10 +1375,10 @@ test('User metadata', async (t) => {
1372
1375
}
1373
1376
1374
1377
// Run metadata query -> get current details
1375
- const wfMetadata = await handle . query ( '__temporal_workflow_metadata' ) as temporal . api . sdk . v1 . IWorkflowMetadata ;
1378
+ const wfMetadata = ( await handle . query ( '__temporal_workflow_metadata' ) ) as temporal . api . sdk . v1 . IWorkflowMetadata ;
1376
1379
t . deepEqual ( wfMetadata . definition ?. signalDefinitions ?. length , 1 ) ;
1377
1380
t . deepEqual ( wfMetadata . definition ?. signalDefinitions ?. [ 0 ] . name , 'done' ) ;
1378
1381
t . deepEqual ( wfMetadata . definition ?. queryDefinitions ?. length , 3 ) ; // default queries
1379
1382
t . deepEqual ( wfMetadata . currentDetails , 'current wf details' ) ;
1380
1383
} ) ;
1381
- } ) ;
1384
+ } ) ;
0 commit comments