@@ -17,7 +17,7 @@ function makeQueue(): WorkQueue<OrchestrationMessage> {
1717
1818function makeStore ( overrides : Partial < ExecutionStore > = { } ) : ExecutionStore {
1919 return {
20- createExecution : vi . fn ( ) . mockResolvedValue ( { id : 'exec-id-1' } ) ,
20+ createExecution : vi . fn ( ) ,
2121 loadExecution : vi . fn ( ) ,
2222 transitionStatus : vi . fn ( ) . mockResolvedValue ( true ) ,
2323 finishExecution : vi . fn ( ) . mockResolvedValue ( true ) ,
@@ -26,7 +26,7 @@ function makeStore(overrides: Partial<ExecutionStore> = {}): ExecutionStore {
2626}
2727
2828describe ( 'StartExecutionService' , ( ) => {
29- it ( 'admits, persists a queued execution, publishes execution:enqueued, returns id ' , async ( ) => {
29+ it ( 'admits, persists a queued execution under the caller-minted id , publishes execution:enqueued' , async ( ) => {
3030 const admittance : AdmittanceService = {
3131 evaluate : vi . fn ( ) . mockResolvedValue ( { accept : true } ) ,
3232 } ;
@@ -38,11 +38,13 @@ describe('StartExecutionService', () => {
3838 workflowId : 'wf-1' ,
3939 graph : sampleGraph ,
4040 triggerOutputs : [ [ { json : { hello : 'world' } } ] ] ,
41+ executionId : 'exec-id-1' ,
4142 } ) ;
4243
4344 expect ( result . executionId ) . toBe ( 'exec-id-1' ) ;
4445 expect ( admittance . evaluate ) . toHaveBeenCalledWith ( { workflowId : 'wf-1' } ) ;
4546 expect ( store . createExecution ) . toHaveBeenCalledWith ( {
47+ id : 'exec-id-1' ,
4648 workflowId : 'wf-1' ,
4749 status : 'queued' ,
4850 mode : 'production' ,
@@ -63,7 +65,7 @@ describe('StartExecutionService', () => {
6365 const queue = makeQueue ( ) ;
6466 const service = new StartExecutionService ( admittance , store , queue ) ;
6567
66- await service . start ( { workflowId : 'wf-1' , graph : sampleGraph } ) ;
68+ await service . start ( { workflowId : 'wf-1' , graph : sampleGraph , executionId : 'exec-id-1' } ) ;
6769
6870 expect ( store . createExecution ) . toHaveBeenCalledWith (
6971 expect . objectContaining ( { mode : 'production' , triggerOutputs : null } ) ,
@@ -77,7 +79,7 @@ describe('StartExecutionService', () => {
7779 const validateGraph = vi . fn ( ) ;
7880 const service = new StartExecutionService ( admittance , makeStore ( ) , makeQueue ( ) , validateGraph ) ;
7981
80- await service . start ( { workflowId : 'wf-1' , graph : sampleGraph } ) ;
82+ await service . start ( { workflowId : 'wf-1' , graph : sampleGraph , executionId : 'exec-id-1' } ) ;
8183
8284 expect ( validateGraph ) . toHaveBeenCalledExactlyOnceWith ( sampleGraph ) ;
8385 } ) ;
@@ -94,7 +96,9 @@ describe('StartExecutionService', () => {
9496 } ) ;
9597 const service = new StartExecutionService ( admittance , store , queue , validateGraph ) ;
9698
97- await expect ( service . start ( { workflowId : 'wf-1' , graph : sampleGraph } ) ) . rejects . toBe ( rejection ) ;
99+ await expect (
100+ service . start ( { workflowId : 'wf-1' , graph : sampleGraph , executionId : 'exec-id-1' } ) ,
101+ ) . rejects . toBe ( rejection ) ;
98102
99103 expect ( store . createExecution ) . not . toHaveBeenCalled ( ) ;
100104 expect ( queue . publish ) . not . toHaveBeenCalled ( ) ;
@@ -108,9 +112,9 @@ describe('StartExecutionService', () => {
108112 const queue = makeQueue ( ) ;
109113 const service = new StartExecutionService ( admittance , store , queue ) ;
110114
111- await expect ( service . start ( { workflowId : 'wf-1' , graph : sampleGraph } ) ) . rejects . toBeInstanceOf (
112- AdmittanceRejectedError ,
113- ) ;
115+ await expect (
116+ service . start ( { workflowId : 'wf-1' , graph : sampleGraph , executionId : 'exec-id-1' } ) ,
117+ ) . rejects . toBeInstanceOf ( AdmittanceRejectedError ) ;
114118
115119 expect ( store . createExecution ) . not . toHaveBeenCalled ( ) ;
116120 expect ( queue . publish ) . not . toHaveBeenCalled ( ) ;
0 commit comments