@@ -16,6 +16,7 @@ import {
1616 collectLegacyWhatsAppCrontabHealthWarning ,
1717 maybeRepairLegacyCronStore ,
1818 noteLegacyWhatsAppCrontabHealthCheck ,
19+ repairLegacyCronStoreWithoutPrompt ,
1920} from "./index.js" ;
2021
2122type TerminalNote = ( message : string , title ?: string ) => void ;
@@ -1058,3 +1059,32 @@ describe("legacy WhatsApp crontab health check", () => {
10581059 expect ( noteMock ) . not . toHaveBeenCalled ( ) ;
10591060 } ) ;
10601061} ) ;
1062+
1063+ describe ( "repairLegacyCronStoreWithoutPrompt" , ( ) => {
1064+ it ( "migrates legacy JSON cron store to SQLite and returns a change summary" , async ( ) => {
1065+ const storePath = await makeTempStorePath ( ) ;
1066+ await writeCronStore ( storePath , [ createLegacyCronJob ( ) ] ) ;
1067+
1068+ const result = await repairLegacyCronStoreWithoutPrompt ( {
1069+ cfg : createCronConfig ( storePath ) ,
1070+ } ) ;
1071+
1072+ expect ( result . changes ) . toHaveLength ( 1 ) ;
1073+ expect ( result . changes [ 0 ] ) . toContain ( "Cron store migrated to SQLite" ) ;
1074+ expect ( result . warnings ) . toHaveLength ( 0 ) ;
1075+ const jobs = await readPersistedJobs ( storePath ) ;
1076+ expect ( jobs ) . toHaveLength ( 1 ) ;
1077+ } ) ;
1078+
1079+ it ( "returns empty result when no legacy store exists" , async ( ) => {
1080+ const storePath = await makeTempStorePath ( ) ;
1081+ await writeCurrentCronStore ( storePath , [ createCurrentCronJob ( ) ] ) ;
1082+
1083+ const result = await repairLegacyCronStoreWithoutPrompt ( {
1084+ cfg : createCronConfig ( storePath ) ,
1085+ } ) ;
1086+
1087+ expect ( result . changes ) . toHaveLength ( 0 ) ;
1088+ expect ( result . warnings ) . toHaveLength ( 0 ) ;
1089+ } ) ;
1090+ } ) ;
0 commit comments