@@ -3,8 +3,10 @@ import { v4 as uuid4 } from 'uuid';
3
3
import { WorkflowFailedError } from '@temporalio/client' ;
4
4
import { TestWorkflowEnvironment , workflowInterceptorModules } from '@temporalio/testing' ;
5
5
import { Connection } from '@temporalio/testing/lib/connection' ;
6
+ import { bundleWorkflowCode , WorkflowBundleWithSourceMap } from '@temporalio/worker' ;
6
7
import {
7
8
assertFromWorkflow ,
9
+ asyncChildStarter ,
8
10
raceActivityAndTimer ,
9
11
sleep ,
10
12
unblockSignal ,
@@ -14,13 +16,18 @@ import { Worker } from './helpers';
14
16
15
17
interface Context {
16
18
testEnv : TestWorkflowEnvironment ;
19
+ bundle : WorkflowBundleWithSourceMap ;
17
20
}
18
21
19
22
const test = anyTest as TestFn < Context > ;
20
23
21
24
test . before ( async ( t ) => {
22
25
t . context = {
23
26
testEnv : await TestWorkflowEnvironment . createTimeSkipping ( ) ,
27
+ bundle : await bundleWorkflowCode ( {
28
+ workflowsPath : require . resolve ( './workflows/testenv-test-workflows' ) ,
29
+ workflowInterceptorModules,
30
+ } ) ,
24
31
} ;
25
32
} ) ;
26
33
@@ -33,7 +40,7 @@ test.serial('TestEnvironment sets up test server and is able to run a Workflow w
33
40
const worker = await Worker . create ( {
34
41
connection : nativeConnection ,
35
42
taskQueue : 'test' ,
36
- workflowsPath : require . resolve ( './workflows/testenv-test-workflows' ) ,
43
+ workflowBundle : t . context . bundle ,
37
44
} ) ;
38
45
await worker . runUntil (
39
46
client . workflow . execute ( sleep , {
@@ -51,7 +58,7 @@ test.serial('TestEnvironment can toggle between normal and skipped time', async
51
58
const worker = await Worker . create ( {
52
59
connection : nativeConnection ,
53
60
taskQueue : 'test' ,
54
- workflowsPath : require . resolve ( './workflows/testenv-test-workflows' ) ,
61
+ workflowBundle : t . context . bundle ,
55
62
} ) ;
56
63
57
64
await worker . runUntil ( async ( ) => {
@@ -87,7 +94,7 @@ test.serial('TestEnvironment sleep can be used to delay activity completion', as
87
94
await sleep ( duration ) ;
88
95
} ,
89
96
} ,
90
- workflowsPath : require . resolve ( './workflows/testenv-test-workflows' ) ,
97
+ workflowBundle : t . context . bundle ,
91
98
} ) ;
92
99
93
100
const run = async ( expectedWinner : 'timer' | 'activity' ) => {
@@ -123,7 +130,7 @@ test.serial('TestEnvironment sleep can be used to delay sending a signal', async
123
130
const worker = await Worker . create ( {
124
131
connection : nativeConnection ,
125
132
taskQueue : 'test' ,
126
- workflowsPath : require . resolve ( './workflows/testenv-test-workflows' ) ,
133
+ workflowBundle : t . context . bundle ,
127
134
} ) ;
128
135
129
136
await worker . runUntil ( async ( ) => {
@@ -144,10 +151,7 @@ test.serial('Workflow code can run assertions', async (t) => {
144
151
const worker = await Worker . create ( {
145
152
connection : nativeConnection ,
146
153
taskQueue : 'test' ,
147
- workflowsPath : require . resolve ( './workflows/testenv-test-workflows' ) ,
148
- interceptors : {
149
- workflowModules : workflowInterceptorModules ,
150
- } ,
154
+ workflowBundle : t . context . bundle ,
151
155
} ) ;
152
156
153
157
const err : WorkflowFailedError | undefined = await t . throwsAsync (
@@ -162,3 +166,25 @@ test.serial('Workflow code can run assertions', async (t) => {
162
166
) ;
163
167
t . is ( err ?. cause ?. message , 'Expected values to be strictly equal:\n\n6 !== 7\n' ) ;
164
168
} ) ;
169
+
170
+ test . serial ( 'ABNADONED child timer can be fast-forwarded' , async ( t ) => {
171
+ const { client, nativeConnection } = t . context . testEnv ;
172
+
173
+ const worker = await Worker . create ( {
174
+ connection : nativeConnection ,
175
+ taskQueue : 'test' ,
176
+ workflowBundle : t . context . bundle ,
177
+ } ) ;
178
+
179
+ const childWorkflowId = uuid4 ( ) ;
180
+ await worker . runUntil ( async ( ) => {
181
+ await client . workflow . execute ( asyncChildStarter , {
182
+ workflowId : uuid4 ( ) ,
183
+ taskQueue : 'test' ,
184
+ args : [ childWorkflowId ] ,
185
+ } ) ;
186
+ await client . workflow . getHandle ( childWorkflowId ) . result ( ) ;
187
+ } ) ;
188
+
189
+ t . pass ( ) ;
190
+ } ) ;
0 commit comments