@@ -11,6 +11,7 @@ describe("TaskManager", () => {
1111 const clientPromise = orkesConductorClient ( { useEnvVars : true , refreshTokenInterval : 0 } ) ;
1212
1313 jest . setTimeout ( 10000 ) ;
14+
1415 test ( "Should run workflow with worker" , async ( ) => {
1516 const client = await clientPromise ;
1617 const executor = new WorkflowExecutor ( client ) ;
@@ -47,9 +48,12 @@ describe("TaskManager", () => {
4748 input : { } ,
4849 version : 1 ,
4950 } ) ;
50- const workflowStatus = await TestUtil . waitForWorkflowCompletion ( executor , executionId , BASE_TIME * 2 ) ;
51- await manager . stopPolling ( ) ;
51+
52+ const workflowStatus = await TestUtil . waitForWorkflowCompletion ( executor , executionId , BASE_TIME * 4 ) ;
53+
5254 expect ( workflowStatus . status ) . toEqual ( "COMPLETED" ) ;
55+
56+ await manager . stopPolling ( ) ;
5357 } ) ;
5458
5559 test ( "On error it should call the errorHandler provided" , async ( ) => {
@@ -82,24 +86,18 @@ describe("TaskManager", () => {
8286 timeoutSeconds : 0 ,
8387 } ) ;
8488
85- const status = await executor . executeWorkflow (
86- {
87- name : "TaskManagerTestErrorHandlerUnique" ,
88- input : { } ,
89- version : 1 ,
90- } ,
91- "TaskManagerTestErrorHandlerUnique" ,
92- 1 ,
93- "errorHandlerTestIdentifierUnique"
94- ) ;
95-
96- await manager . stopPolling ( ) ;
89+ const status = await executor . startWorkflow ( {
90+ name : "TaskManagerTestErrorHandlerUnique" ,
91+ input : { } ,
92+ version : 1 ,
93+ correlationId : "errorHandlerTestIdentifierUnique"
94+ } ) ;
9795
98- // Wait for workflow to complete and fail
99- const workflowStatus = await TestUtil . waitForWorkflowCompletion ( executor , status . workflowId ! , BASE_TIME * 4 ) ;
96+ const workflowStatus = await TestUtil . waitForWorkflowCompletion ( executor , status , BASE_TIME * 4 ) ;
10097
10198 expect ( workflowStatus . status ) . toEqual ( "FAILED" ) ;
10299 expect ( mockErrorHandler ) . toHaveBeenCalled ( ) ;
100+ await manager . stopPolling ( ) ;
103101 } ) ;
104102
105103 test ( "If no error handler provided. it should just update the task" , async ( ) => {
@@ -129,22 +127,16 @@ describe("TaskManager", () => {
129127 timeoutSeconds : 0 ,
130128 } ) ;
131129
132- const { workflowId : executionId } = await executor . executeWorkflow (
133- {
134- name : "TaskManagerTestE" ,
135- input : { } ,
136- version : 1 ,
137- } ,
138- "TaskManagerTestE" ,
139- 1 ,
140- "noErrorHandlerProvidedIdentifier"
141- ) ;
142-
143- await manager . stopPolling ( ) ;
130+ const executionId = await executor . startWorkflow ( {
131+ name : "TaskManagerTestE" ,
132+ input : { } ,
133+ version : 1 ,
134+ correlationId : "noErrorHandlerProvidedIdentifier"
135+ } ) ;
144136
145- // Wait for workflow to complete and fail
146- const workflowStatus = await TestUtil . waitForWorkflowCompletion ( executor , executionId ! , BASE_TIME * 2 ) ;
137+ const workflowStatus = await TestUtil . waitForWorkflowCompletion ( executor , executionId ! , BASE_TIME * 4 ) ;
147138 expect ( workflowStatus . status ) . toEqual ( "FAILED" ) ;
139+ await manager . stopPolling ( ) ;
148140 } ) ;
149141
150142 test ( "multi worker example" , async ( ) => {
@@ -195,22 +187,19 @@ describe("TaskManager", () => {
195187 timeoutSeconds : 0 ,
196188 } ) ;
197189
198- //Start workf
199- const { workflowId : executionId } = await executor . executeWorkflow (
200- {
201- name : workflowName ,
202- version : 1 ,
203- } ,
204- workflowName ,
205- 1 ,
206- "identifierTaskManMulti"
207- ) ;
190+ //Start workflow
191+ const executionId = await executor . startWorkflow ( {
192+ name : workflowName ,
193+ version : 1 ,
194+ correlationId : "identifierTaskManMulti"
195+ } ) ;
196+
208197 expect ( executionId ) . toBeDefined ( ) ;
209198
210199 // decrease speed again
211200 manager . updatePollingOptions ( { pollInterval : BASE_TIME , concurrency : 1 } ) ;
212201
213- const workflowStatus = await TestUtil . waitForWorkflowCompletion ( executor , executionId ! , BASE_TIME * 5 ) ;
202+ const workflowStatus = await TestUtil . waitForWorkflowCompletion ( executor , executionId , BASE_TIME * 4 ) ;
214203
215204 expect ( workflowStatus . status ) . toEqual ( "COMPLETED" ) ;
216205 await manager . stopPolling ( ) ;
@@ -323,22 +312,18 @@ describe("TaskManager", () => {
323312 timeoutSeconds : 0 ,
324313 } ) ;
325314
326- //Start workf
327- const { workflowId : executionId } = await executor . executeWorkflow (
328- {
329- name : workflowName ,
330- version : 1 ,
331- } ,
332- workflowName ,
333- 1 ,
334- "identifierTaskManMulti"
335- ) ;
315+ //Start workflow
316+ const executionId = await executor . startWorkflow ( {
317+ name : workflowName ,
318+ version : 1 ,
319+ correlationId : "identifierTaskManMulti"
320+ } ) ;
336321 expect ( executionId ) . toBeDefined ( ) ;
337322
338323 // decrease speed again
339324 manager . updatePollingOptions ( { pollInterval : BASE_TIME , concurrency : 1 } ) ;
340325
341- const workflowStatus = await executor . getWorkflow ( executionId ! , true ) ;
326+ const workflowStatus = await TestUtil . waitForWorkflowCompletion ( executor , executionId , BASE_TIME * 4 ) ;
342327
343328 expect ( workflowStatus . status ) . toEqual ( "COMPLETED" ) ;
344329 await manager . stopPolling ( ) ;
0 commit comments