@@ -45,7 +45,7 @@ import {
4545  hasActivityHeartbeat , 
4646  helpers , 
4747  makeTestFunction , 
48-   setActivityPauseState , 
48+   setActivityState , 
4949}  from  './helpers-integration' ; 
5050import  {  overrideSdkInternalFlag  }  from  './mock-internal-flags' ; 
5151import  {  heartbeatCancellationDetailsActivity  }  from  './activities/heartbeat-cancellation-details' ; 
@@ -1459,7 +1459,7 @@ test('Activity pause returns expected cancellation details', async (t) => {
14591459    } ,  10000 ) ; 
14601460
14611461    // Now pause the activity 
1462-     await  setActivityPauseState ( handle ,  testActivityId ,  true ) ; 
1462+     await  setActivityState ( handle ,  testActivityId ,  'pause' ) ; 
14631463    // Get the result - should contain pause cancellation details 
14641464    const  result  =  await  handle . result ( ) ; 
14651465
@@ -1494,15 +1494,79 @@ test('Activity can be cancelled via pause and retry after unpause', async (t) =>
14941494      return  ! ! ( activityInfo  &&  ( await  hasActivityHeartbeat ( handle ,  testActivityId ,  'heartbeated' ) ) ) ; 
14951495    } ,  10000 ) ; 
14961496
1497-     await  setActivityPauseState ( handle ,  testActivityId ,  true ) ; 
1497+     await  setActivityState ( handle ,  testActivityId ,  'pause' ) ; 
14981498    await  waitUntil ( async  ( )  =>  hasActivityHeartbeat ( handle ,  testActivityId ,  'finally-complete' ) ,  10000 ) ; 
1499-     await  setActivityPauseState ( handle ,  testActivityId ,  false ) ; 
1499+     await  setActivityState ( handle ,  testActivityId ,  'unpause' ) ; 
15001500
15011501    const  result  =  await  handle . result ( ) ; 
15021502    t . true ( result  ==  null ) ; 
15031503  } ) ; 
15041504} ) ; 
15051505
1506+ test ( 'Activity reset returns expected cancellation details' ,  async  ( t )  =>  { 
1507+   const  {  createWorker,  startWorkflow }  =  helpers ( t ) ; 
1508+   const  worker  =  await  createWorker ( { 
1509+     activities : { 
1510+       heartbeatCancellationDetailsActivity, 
1511+     } , 
1512+   } ) ; 
1513+ 
1514+   await  worker . runUntil ( async  ( )  =>  { 
1515+     const  testActivityId  =  randomUUID ( ) ; 
1516+     const  handle  =  await  startWorkflow ( heartbeatPauseWorkflow ,  {  args : [ testActivityId ,  true ,  1 ]  } ) ; 
1517+ 
1518+     // Wait for it to exist and heartbeat 
1519+     await  waitUntil ( async  ( )  =>  { 
1520+       const  {  raw }  =  await  handle . describe ( ) ; 
1521+       const  activityInfo  =  raw . pendingActivities ?. find ( ( act )  =>  act . activityId  ===  testActivityId ) ; 
1522+       return  ! ! ( activityInfo  &&  ( await  hasActivityHeartbeat ( handle ,  testActivityId ,  'heartbeated' ) ) ) ; 
1523+     } ,  10000 ) ; 
1524+ 
1525+     await  setActivityState ( handle ,  testActivityId ,  'reset' ) ; 
1526+     const  result  =  await  handle . result ( ) ; 
1527+     t . deepEqual ( result ,  { 
1528+       cancelRequested : false , 
1529+       notFound : false , 
1530+       paused : false , 
1531+       timedOut : false , 
1532+       workerShutdown : false , 
1533+       reset : true , 
1534+     } ) ; 
1535+   } ) ; 
1536+ } ) ; 
1537+ 
1538+ test ( 'Activity set as both paused and reset returns expected cancellation details' ,  async  ( t )  =>  { 
1539+   const  {  createWorker,  startWorkflow }  =  helpers ( t ) ; 
1540+   const  worker  =  await  createWorker ( { 
1541+     activities : { 
1542+       heartbeatCancellationDetailsActivity, 
1543+     } , 
1544+   } ) ; 
1545+ 
1546+   await  worker . runUntil ( async  ( )  =>  { 
1547+     const  testActivityId  =  randomUUID ( ) ; 
1548+     const  handle  =  await  startWorkflow ( heartbeatPauseWorkflow ,  {  args : [ testActivityId ,  true ,  1 ]  } ) ; 
1549+ 
1550+     // Wait for it to exist and heartbeat 
1551+     await  waitUntil ( async  ( )  =>  { 
1552+       const  {  raw }  =  await  handle . describe ( ) ; 
1553+       const  activityInfo  =  raw . pendingActivities ?. find ( ( act )  =>  act . activityId  ===  testActivityId ) ; 
1554+       return  ! ! ( activityInfo  &&  ( await  hasActivityHeartbeat ( handle ,  testActivityId ,  'heartbeated' ) ) ) ; 
1555+     } ,  10000 ) ; 
1556+ 
1557+     await  setActivityState ( handle ,  testActivityId ,  'pause & reset' ) ; 
1558+     const  result  =  await  handle . result ( ) ; 
1559+     t . deepEqual ( result ,  { 
1560+       cancelRequested : false , 
1561+       notFound : false , 
1562+       paused : true , 
1563+       timedOut : false , 
1564+       workerShutdown : false , 
1565+       reset : true , 
1566+     } ) ; 
1567+   } ) ; 
1568+ } ) ; 
1569+ 
15061570const  reservedNames  =  [ TEMPORAL_RESERVED_PREFIX ,  STACK_TRACE_QUERY_NAME ,  ENHANCED_STACK_TRACE_QUERY_NAME ] ; 
15071571
15081572test ( 'Cannot register activities using reserved prefixes' ,  async  ( t )  =>  { 
0 commit comments