@@ -27,6 +27,7 @@ describe("ScheduleEngine Integration (part 2)", () => {
2727 redis : redisOptions ,
2828 distributionWindow : { seconds : 10 } ,
2929 schedulePhaseSecret : "test-schedule-phase-secret" ,
30+ cronSpreadEnabled : false ,
3031 worker : {
3132 concurrency : 1 ,
3233 disabled : true , // Don't actually run the worker — calling triggerScheduledTask directly
@@ -79,6 +80,7 @@ describe("ScheduleEngine Integration (part 2)", () => {
7980 type : "DECLARATIVE" ,
8081 active : true ,
8182 externalId : "legacy-ext" ,
83+ windowDurationSeconds : 60 ,
8284 } ,
8385 } ) ;
8486
@@ -119,22 +121,27 @@ describe("ScheduleEngine Integration (part 2)", () => {
119121 effectiveScheduleTime : string ;
120122 } ;
121123 const nextNominalAt = new Date ( "2026-04-30T10:10:00.000Z" ) ;
122- const followingNominalAt = new Date ( "2026-04-30T10:15:00.000Z" ) ;
123- const schedulePhase = calculateSchedulePhase ( {
124- secret : "test-schedule-phase-secret" ,
125- environmentId : environment . id ,
126- deduplicationKey : taskSchedule . deduplicationKey ,
127- } ) ;
128- const { effectiveAt : nextEffectiveAt } = calculateEffectiveScheduleTime ( {
129- nominalAt : nextNominalAt ,
130- nextNominalAt : followingNominalAt ,
131- schedulePhase,
132- } ) ;
133124
134- // The next job advances from the legacy job's nominal T, not from E
135- // or the current wall clock, and newly enqueued jobs carry both times.
125+ // The next job advances from the legacy job's nominal T, not from the
126+ // current wall clock. With cron spread disabled, actual eligibility
127+ // remains nominal even though registration still calculates candidate E.
136128 expect ( new Date ( nextJobPayload . exactScheduleTime ) ) . toEqual ( nextNominalAt ) ;
137- expect ( new Date ( nextJobPayload . effectiveScheduleTime ) ) . toEqual ( nextEffectiveAt ) ;
129+ expect ( new Date ( nextJobPayload . effectiveScheduleTime ) ) . toEqual ( nextNominalAt ) ;
130+ expect ( nextJob ! . timestamp ) . toEqual (
131+ calculateDistributedExecutionTime ( nextNominalAt , 10 , scheduleInstance . id )
132+ ) ;
133+
134+ const updatedInstance = await prisma . taskScheduleInstance . findUniqueOrThrow ( {
135+ where : { id : scheduleInstance . id } ,
136+ select : { schedulePhase : true } ,
137+ } ) ;
138+ expect ( updatedInstance . schedulePhase ) . toBe (
139+ calculateSchedulePhase ( {
140+ secret : "test-schedule-phase-secret" ,
141+ environmentId : environment . id ,
142+ deduplicationKey : taskSchedule . deduplicationKey ,
143+ } )
144+ ) ;
138145 } finally {
139146 await engine . quit ( ) ;
140147 }
@@ -152,6 +159,7 @@ describe("ScheduleEngine Integration (part 2)", () => {
152159 redis : redisOptions ,
153160 distributionWindow : { seconds : 10 } ,
154161 schedulePhaseSecret,
162+ cronSpreadEnabled : true ,
155163 worker : {
156164 concurrency : 1 ,
157165 disabled : true ,
0 commit comments