@@ -54,7 +54,7 @@ describe("reconcileMaintenancePhaseTransition", () => {
5454 // phase id must be bumped so the first deferral binds to the current
5555 // window rather than a hypothetical phase-0.
5656 const state = await makeState ( ) ;
57- const t = reconcileMaintenancePhaseTransition ( state , AT_UTC_03_30 ) ;
57+ const t = await reconcileMaintenancePhaseTransition ( state , AT_UTC_03_30 ) ;
5858 expect ( t . previous ) . toBeUndefined ( ) ;
5959 expect ( t . current ) . toBe ( "maintenance" ) ;
6060 expect ( t . phaseBegan ) . toBe ( true ) ;
@@ -64,7 +64,7 @@ describe("reconcileMaintenancePhaseTransition", () => {
6464
6565 it ( "first call records the current phase without bumping if maintenance is not active" , async ( ) => {
6666 const state = await makeState ( ) ;
67- const t = reconcileMaintenancePhaseTransition ( state , AT_UTC_05_00 ) ;
67+ const t = await reconcileMaintenancePhaseTransition ( state , AT_UTC_05_00 ) ;
6868 expect ( t . previous ) . toBeUndefined ( ) ;
6969 expect ( t . current ) . toBe ( "normal" ) ;
7070 expect ( t . phaseBegan ) . toBe ( false ) ;
@@ -74,8 +74,8 @@ describe("reconcileMaintenancePhaseTransition", () => {
7474
7575 it ( "no-op when the phase does not change" , async ( ) => {
7676 const state = await makeState ( ) ;
77- reconcileMaintenancePhaseTransition ( state , AT_UTC_03_30 ) ; // sets to maintenance
78- const t = reconcileMaintenancePhaseTransition ( state , AT_UTC_03_30 + 1_000 ) ;
77+ await reconcileMaintenancePhaseTransition ( state , AT_UTC_03_30 ) ; // sets to maintenance
78+ const t = await reconcileMaintenancePhaseTransition ( state , AT_UTC_03_30 + 1_000 ) ;
7979 expect ( t . previous ) . toBe ( "maintenance" ) ;
8080 expect ( t . current ) . toBe ( "maintenance" ) ;
8181 expect ( t . phaseBegan ) . toBe ( false ) ;
@@ -84,9 +84,9 @@ describe("reconcileMaintenancePhaseTransition", () => {
8484
8585 it ( "bumps the phase id on normal -> maintenance transition" , async ( ) => {
8686 const state = await makeState ( ) ;
87- reconcileMaintenancePhaseTransition ( state , AT_UTC_01_30 ) ; // normal
87+ await reconcileMaintenancePhaseTransition ( state , AT_UTC_01_30 ) ; // normal
8888 expect ( state . lastMaintenancePhase ) . toBe ( "normal" ) ;
89- const t = reconcileMaintenancePhaseTransition ( state , AT_UTC_03_30 ) ; // -> maintenance
89+ const t = await reconcileMaintenancePhaseTransition ( state , AT_UTC_03_30 ) ; // -> maintenance
9090 expect ( t . previous ) . toBe ( "normal" ) ;
9191 expect ( t . current ) . toBe ( "maintenance" ) ;
9292 expect ( t . phaseBegan ) . toBe ( true ) ;
@@ -95,12 +95,12 @@ describe("reconcileMaintenancePhaseTransition", () => {
9595
9696 it ( "drains the backlog on maintenance -> normal transition" , async ( ) => {
9797 const state = await makeState ( ) ;
98- reconcileMaintenancePhaseTransition ( state , AT_UTC_03_30 ) ; // -> maintenance
98+ await reconcileMaintenancePhaseTransition ( state , AT_UTC_03_30 ) ; // -> maintenance
9999 recordMaintenanceDeferral ( { jobId : "job-A" , agentId : "main" , nowMs : AT_UTC_03_30 } ) ;
100100 recordMaintenanceDeferral ( { jobId : "job-B" , agentId : "main" , nowMs : AT_UTC_03_30 + 1_000 } ) ;
101101 expect ( getMaintenanceDeferralCount ( ) ) . toBe ( 2 ) ;
102102
103- const t = reconcileMaintenancePhaseTransition ( state , AT_UTC_05_00 ) ; // -> normal
103+ const t = await reconcileMaintenancePhaseTransition ( state , AT_UTC_05_00 ) ; // -> normal
104104 expect ( t . previous ) . toBe ( "maintenance" ) ;
105105 expect ( t . current ) . toBe ( "normal" ) ;
106106 expect ( t . phaseBegan ) . toBe ( false ) ;
@@ -114,7 +114,9 @@ describe("reconcileMaintenancePhaseTransition", () => {
114114 enabled : false ,
115115 window : { start : "02:00" , end : "04:00" , timezone : "UTC" } ,
116116 } ) ;
117- expect ( ( ) => reconcileMaintenancePhaseTransition ( state , AT_UTC_03_30 ) ) . not . toThrow ( ) ;
117+ expect (
118+ async ( ) => await reconcileMaintenancePhaseTransition ( state , AT_UTC_03_30 ) ,
119+ ) . not . toThrow ( ) ;
118120 expect ( state . lastMaintenancePhase ) . toBe ( "normal" ) ;
119121 } ) ;
120122
@@ -128,23 +130,23 @@ describe("reconcileMaintenancePhaseTransition", () => {
128130
129131 // First tick: outside the window, so phase is normal -> nothing happens.
130132 // previous is undefined, current is normal: no transition (no bump, no drain).
131- const t1 = reconcileMaintenancePhaseTransition ( state , AT_UTC_05_00 ) ;
133+ const t1 = await reconcileMaintenancePhaseTransition ( state , AT_UTC_05_00 ) ;
132134 expect ( t1 . drainedCount ) . toBe ( 0 ) ;
133135 // The stale entry is still there because the prior phase was undefined;
134136 // we only drain on an actual maintenance -> normal transition.
135137 expect ( getMaintenanceDeferralCount ( ) ) . toBe ( 1 ) ;
136138
137139 // Next tick: same normal, no-op.
138- const t2 = reconcileMaintenancePhaseTransition ( state , AT_UTC_05_00 + 1_000 ) ;
140+ const t2 = await reconcileMaintenancePhaseTransition ( state , AT_UTC_05_00 + 1_000 ) ;
139141 expect ( t2 . drainedCount ) . toBe ( 0 ) ;
140142 } ) ;
141143
142144 it ( "logs the transition details for diagnostics" , async ( ) => {
143145 const state = await makeState ( ) ;
144146 // no logger assertions here; just confirm the call returns the structured
145147 // details that the scheduler's log lines use.
146- reconcileMaintenancePhaseTransition ( state , AT_UTC_01_30 ) ;
147- const t = reconcileMaintenancePhaseTransition ( state , AT_UTC_03_30 ) ;
148+ await reconcileMaintenancePhaseTransition ( state , AT_UTC_01_30 ) ;
149+ const t = await reconcileMaintenancePhaseTransition ( state , AT_UTC_03_30 ) ;
148150 expect ( t ) . toMatchObject ( {
149151 previous : "normal" ,
150152 current : "maintenance" ,
0 commit comments