@@ -654,89 +654,89 @@ describe("Durable Task Scheduler (DTS) E2E Tests", () => {
654654 // expect(state?.serializedCustomStatus).toEqual('""');
655655 // }, 31000);
656656
657- // // ==================== sendEvent Tests ====================
657+ // ==================== sendEvent Tests ====================
658658
659- // it("should send event from one orchestration to another", async () => {
660- // const receiverOrchestrator: TOrchestrator = async function* (ctx: OrchestrationContext): any {
661- // const event = yield ctx.waitForExternalEvent("greeting");
662- // return event;
663- // };
659+ it ( "should send event from one orchestration to another" , async ( ) => {
660+ const receiverOrchestrator : TOrchestrator = async function * ( ctx : OrchestrationContext ) : any {
661+ const event = yield ctx . waitForExternalEvent ( "greeting" ) ;
662+ return event ;
663+ } ;
664664
665- // const senderOrchestrator: TOrchestrator = async function* (
666- // ctx: OrchestrationContext,
667- // targetInstanceId: string,
668- // ): any {
669- // // Wait a bit to ensure receiver is running
670- // yield ctx.createTimer(1);
665+ const senderOrchestrator : TOrchestrator = async function * (
666+ ctx : OrchestrationContext ,
667+ targetInstanceId : string ,
668+ ) : any {
669+ // Wait a bit to ensure receiver is running
670+ yield ctx . createTimer ( 1 ) ;
671671
672- // // Send event to the receiver
673- // ctx.sendEvent(targetInstanceId, "greeting", { message: "Hello from sender!" });
672+ // Send event to the receiver
673+ ctx . sendEvent ( targetInstanceId , "greeting" , { message : "Hello from sender!" } ) ;
674674
675- // // Must yield after sendEvent to ensure the action is sent before orchestration completes
676- // yield ctx.createTimer(1);
675+ // Must yield after sendEvent to ensure the action is sent before orchestration completes
676+ yield ctx . createTimer ( 1 ) ;
677677
678- // return "sent";
679- // };
678+ return "sent" ;
679+ } ;
680680
681- // taskHubWorker.addOrchestrator(receiverOrchestrator);
682- // taskHubWorker.addOrchestrator(senderOrchestrator);
683- // await taskHubWorker.start();
681+ taskHubWorker . addOrchestrator ( receiverOrchestrator ) ;
682+ taskHubWorker . addOrchestrator ( senderOrchestrator ) ;
683+ await taskHubWorker . start ( ) ;
684684
685- // // Start receiver first
686- // const receiverId = await taskHubClient.scheduleNewOrchestration(receiverOrchestrator);
687- // await taskHubClient.waitForOrchestrationStart(receiverId, undefined, 10);
685+ // Start receiver first
686+ const receiverId = await taskHubClient . scheduleNewOrchestration ( receiverOrchestrator ) ;
687+ await taskHubClient . waitForOrchestrationStart ( receiverId , undefined , 10 ) ;
688688
689- // // Start sender with receiver's instance ID
690- // const senderId = await taskHubClient.scheduleNewOrchestration(senderOrchestrator, receiverId);
689+ // Start sender with receiver's instance ID
690+ const senderId = await taskHubClient . scheduleNewOrchestration ( senderOrchestrator , receiverId ) ;
691691
692- // // Wait for both to complete
693- // const [receiverState, senderState] = await Promise.all([
694- // taskHubClient.waitForOrchestrationCompletion(receiverId, undefined, 30),
695- // taskHubClient.waitForOrchestrationCompletion(senderId, undefined, 30),
696- // ]);
692+ // Wait for both to complete
693+ const [ receiverState , senderState ] = await Promise . all ( [
694+ taskHubClient . waitForOrchestrationCompletion ( receiverId , undefined , 30 ) ,
695+ taskHubClient . waitForOrchestrationCompletion ( senderId , undefined , 30 ) ,
696+ ] ) ;
697697
698- // expect(senderState).toBeDefined();
699- // expect(senderState?.runtimeStatus).toEqual(OrchestrationStatus.ORCHESTRATION_STATUS_COMPLETED);
700- // expect(senderState?.serializedOutput).toEqual(JSON.stringify("sent"));
698+ expect ( senderState ) . toBeDefined ( ) ;
699+ expect ( senderState ?. runtimeStatus ) . toEqual ( OrchestrationStatus . ORCHESTRATION_STATUS_COMPLETED ) ;
700+ expect ( senderState ?. serializedOutput ) . toEqual ( JSON . stringify ( "sent" ) ) ;
701701
702- // expect(receiverState).toBeDefined();
703- // expect(receiverState?.runtimeStatus).toEqual(OrchestrationStatus.ORCHESTRATION_STATUS_COMPLETED);
704- // expect(receiverState?.serializedOutput).toEqual(JSON.stringify({ message: "Hello from sender!" }));
705- // }, 45000);
702+ expect ( receiverState ) . toBeDefined ( ) ;
703+ expect ( receiverState ?. runtimeStatus ) . toEqual ( OrchestrationStatus . ORCHESTRATION_STATUS_COMPLETED ) ;
704+ expect ( receiverState ?. serializedOutput ) . toEqual ( JSON . stringify ( { message : "Hello from sender!" } ) ) ;
705+ } , 45000 ) ;
706706
707- // it("should send event without data", async () => {
708- // const receiverOrchestrator: TOrchestrator = async function* (ctx: OrchestrationContext): any {
709- // yield ctx.waitForExternalEvent("signal");
710- // return "received signal";
711- // };
707+ it ( "should send event without data" , async ( ) => {
708+ const receiverOrchestrator : TOrchestrator = async function * ( ctx : OrchestrationContext ) : any {
709+ yield ctx . waitForExternalEvent ( "signal" ) ;
710+ return "received signal" ;
711+ } ;
712712
713- // const senderOrchestrator: TOrchestrator = async function* (
714- // ctx: OrchestrationContext,
715- // targetInstanceId: string,
716- // ): any {
717- // yield ctx.createTimer(1);
718- // ctx.sendEvent(targetInstanceId, "signal");
719- // // Must yield after sendEvent to ensure the action is sent
720- // yield ctx.createTimer(1);
721- // return "signaled";
722- // };
713+ const senderOrchestrator : TOrchestrator = async function * (
714+ ctx : OrchestrationContext ,
715+ targetInstanceId : string ,
716+ ) : any {
717+ yield ctx . createTimer ( 1 ) ;
718+ ctx . sendEvent ( targetInstanceId , "signal" ) ;
719+ // Must yield after sendEvent to ensure the action is sent
720+ yield ctx . createTimer ( 1 ) ;
721+ return "signaled" ;
722+ } ;
723723
724- // taskHubWorker.addOrchestrator(receiverOrchestrator);
725- // taskHubWorker.addOrchestrator(senderOrchestrator);
726- // await taskHubWorker.start();
724+ taskHubWorker . addOrchestrator ( receiverOrchestrator ) ;
725+ taskHubWorker . addOrchestrator ( senderOrchestrator ) ;
726+ await taskHubWorker . start ( ) ;
727727
728- // const receiverId = await taskHubClient.scheduleNewOrchestration(receiverOrchestrator);
729- // await taskHubClient.waitForOrchestrationStart(receiverId, undefined, 10);
728+ const receiverId = await taskHubClient . scheduleNewOrchestration ( receiverOrchestrator ) ;
729+ await taskHubClient . waitForOrchestrationStart ( receiverId , undefined , 10 ) ;
730730
731- // const senderId = await taskHubClient.scheduleNewOrchestration(senderOrchestrator, receiverId);
731+ const senderId = await taskHubClient . scheduleNewOrchestration ( senderOrchestrator , receiverId ) ;
732732
733- // const [receiverState, senderState] = await Promise.all([
734- // taskHubClient.waitForOrchestrationCompletion(receiverId, undefined, 30),
735- // taskHubClient.waitForOrchestrationCompletion(senderId, undefined, 30),
736- // ]);
733+ const [ receiverState , senderState ] = await Promise . all ( [
734+ taskHubClient . waitForOrchestrationCompletion ( receiverId , undefined , 30 ) ,
735+ taskHubClient . waitForOrchestrationCompletion ( senderId , undefined , 30 ) ,
736+ ] ) ;
737737
738- // expect(senderState?.runtimeStatus).toEqual(OrchestrationStatus.ORCHESTRATION_STATUS_COMPLETED);
739- // expect(receiverState?.runtimeStatus).toEqual(OrchestrationStatus.ORCHESTRATION_STATUS_COMPLETED);
740- // expect(receiverState?.serializedOutput).toEqual(JSON.stringify("received signal"));
741- // }, 45000);
738+ expect ( senderState ?. runtimeStatus ) . toEqual ( OrchestrationStatus . ORCHESTRATION_STATUS_COMPLETED ) ;
739+ expect ( receiverState ?. runtimeStatus ) . toEqual ( OrchestrationStatus . ORCHESTRATION_STATUS_COMPLETED ) ;
740+ expect ( receiverState ?. serializedOutput ) . toEqual ( JSON . stringify ( "received signal" ) ) ;
741+ } , 45000 ) ;
742742} ) ;
0 commit comments