@@ -711,27 +711,34 @@ describe('WhatsApp Scheduler', () => {
711711 ) ;
712712 } ) ;
713713
714- // TODO: Fix flaky test - saveStorage may fail silently in test environment
715- it . skip ( 'should update schedule lastRun and nextRun after execution' , async ( ) => {
716- // Create a schedule using the public API
717- const id = scheduleIntervalDigest ( 30 ) ;
714+ it ( 'should update schedule lastRun and nextRun after execution' , async ( ) => {
715+ // Create a schedule with includeInactive: true so it always runs
716+ // (mocked getFrameDigestData may return empty data)
717+ const id = scheduleDigest ( {
718+ type : 'interval' ,
719+ intervalMinutes : 30 ,
720+ includeInactive : true , // Always send, even with no activity
721+ quietHoursRespect : false ,
722+ } ) ;
718723 const scheduleBefore = getSchedule ( id ) ;
719724 expect ( scheduleBefore ) . toBeDefined ( ) ;
720725 expect ( scheduleBefore ?. lastRun ) . toBeUndefined ( ) ; // No lastRun initially
721726
722727 // Run the schedule directly (bypassing the due check)
723728 const result = await runScheduledDigest ( id ) ;
724729
725- // Verify execution
730+ // Verify execution succeeded
726731 expect ( result . success ) . toBe ( true ) ;
727732
728- // Verify schedule was updated
729- const scheduleAfter = getSchedule ( id ) ;
730- expect ( scheduleAfter ?. lastRun ) . toBeDefined ( ) ;
731- expect ( scheduleAfter ?. nextRun ) . toBeDefined ( ) ;
732- // The nextRun should now be different (further in future since we just ran)
733- // And lastRun should be set
734- expect ( scheduleAfter ! . lastRun ) . not . toBeUndefined ( ) ;
733+ // Verify schedule was updated by reading the file directly
734+ // (avoids potential caching issues with getSchedule)
735+ const fileData = JSON . parse ( readFileSync ( SCHEDULE_PATH , 'utf8' ) ) ;
736+ const scheduleAfter = fileData . schedules . find (
737+ ( s : { id : string } ) => s . id === id
738+ ) ;
739+ expect ( scheduleAfter ) . toBeDefined ( ) ;
740+ expect ( scheduleAfter . lastRun ) . toBeDefined ( ) ;
741+ expect ( scheduleAfter . nextRun ) . toBeDefined ( ) ;
735742 } ) ;
736743
737744 it ( 'should handle multiple schedules with mixed due states' , async ( ) => {
0 commit comments