@@ -10,6 +10,7 @@ import {
1010} from "../sdk" ;
1111import { mockLogger } from "./utils/mockLogger" ;
1212import { waitForWorkflowCompletion } from "./utils/waitForWorkflowCompletion" ;
13+ import { describeForOrkesV5 } from "./utils/customJestDescribe" ;
1314
1415const BASE_TIME = 1000 ;
1516describe ( "TaskManager" , ( ) => {
@@ -44,7 +45,49 @@ describe("TaskManager", () => {
4445 tasksToCleanup . length = 0 ;
4546 } ) ;
4647
47- test ( "Should run workflow with worker" , async ( ) => {
48+ // Client-side validation only; no workflow execution or updateTaskV2 — runs on v4 and v5
49+ test ( "Should not be able to startPolling if TaskManager has no workers" , async ( ) => {
50+ const client = await clientPromise ;
51+ const manager = new TaskManager ( client , [ ] , {
52+ options : { pollInterval : BASE_TIME , concurrency : 2 } ,
53+ } ) ;
54+ expect ( ( ) => manager . startPolling ( ) ) . toThrow (
55+ "No workers supplied to TaskManager"
56+ ) ;
57+ } ) ;
58+
59+ test ( "Should not be able to startPolling if duplicate workers" , async ( ) => {
60+ const client = await clientPromise ;
61+ const workerName = `jsSdkTest-worker-name-${ Date . now ( ) } ` ;
62+
63+ const workerNames : string [ ] = Array . from ( { length : 3 } )
64+ . fill ( 0 )
65+ . map ( ( ) => workerName ) ;
66+
67+ // names to actual workers
68+ const workers : ConductorWorker [ ] = workerNames . map ( ( name ) => ( {
69+ taskDefName : name ,
70+ execute : async ( ) => {
71+ return {
72+ outputData : {
73+ hello : "From your worker" ,
74+ } ,
75+ status : "COMPLETED" ,
76+ } ;
77+ } ,
78+ } ) ) ;
79+
80+ const manager = new TaskManager ( client , workers , {
81+ options : { pollInterval : BASE_TIME , concurrency : 2 } ,
82+ } ) ;
83+ expect ( ( ) => manager . startPolling ( ) ) . toThrow (
84+ `Duplicate worker taskDefName: ${ workerName } `
85+ ) ;
86+ } ) ;
87+
88+ // Workflow execution uses updateTaskV2 (v5 only)
89+ describeForOrkesV5 ( "TaskManager workflow execution" , ( ) => {
90+ test ( "Should run workflow with worker" , async ( ) => {
4891 const client = await clientPromise ;
4992 const executor = new WorkflowExecutor ( client ) ;
5093 const taskName = `jsSdkTest-taskmanager-test-${ Date . now ( ) } ` ;
@@ -324,46 +367,7 @@ describe("TaskManager", () => {
324367 expect ( manager . options . pollInterval ) . toBe ( BASE_TIME ) ;
325368 } ) ;
326369
327- test ( "Should not be able to startPolling if TaskManager has no workers" , async ( ) => {
328- const client = await clientPromise ;
329- const manager = new TaskManager ( client , [ ] , {
330- options : { pollInterval : BASE_TIME , concurrency : 2 } ,
331- } ) ;
332- expect ( ( ) => manager . startPolling ( ) ) . toThrow (
333- "No workers supplied to TaskManager"
334- ) ;
335- } ) ;
336-
337- test ( "Should not be able to startPolling if duplicate workers" , async ( ) => {
338- const client = await clientPromise ;
339- const workerName = `jsSdkTest-worker-name-${ Date . now ( ) } ` ;
340-
341- const workerNames : string [ ] = Array . from ( { length : 3 } )
342- . fill ( 0 )
343- . map ( ( ) => workerName ) ;
344-
345- // names to actual workers
346- const workers : ConductorWorker [ ] = workerNames . map ( ( name ) => ( {
347- taskDefName : name ,
348- execute : async ( ) => {
349- return {
350- outputData : {
351- hello : "From your worker" ,
352- } ,
353- status : "COMPLETED" ,
354- } ;
355- } ,
356- } ) ) ;
357-
358- const manager = new TaskManager ( client , workers , {
359- options : { pollInterval : BASE_TIME , concurrency : 2 } ,
360- } ) ;
361- expect ( ( ) => manager . startPolling ( ) ) . toThrow (
362- `Duplicate worker taskDefName: ${ workerName } `
363- ) ;
364- } ) ;
365-
366- test ( "Updates single worker properties" , async ( ) => {
370+ test ( "Updates single worker properties" , async ( ) => {
367371 const client = await clientPromise ;
368372
369373 const executor = new WorkflowExecutor ( client ) ;
@@ -465,4 +469,5 @@ describe("TaskManager", () => {
465469 `TaskWorker ${ candidateWorkerUpdate } configuration updated with concurrency of ${ updatedWorkerOptions . concurrency } and poll interval of ${ updatedWorkerOptions . pollInterval } `
466470 ) ;
467471 } ) ;
472+ } ) ;
468473} ) ;
0 commit comments