@@ -331,6 +331,55 @@ describe("recent Message sync", () => {
331331 ) . toHaveLength ( 200 ) ;
332332 } ) ;
333333
334+ it ( "yields while persisting fewer than one hundred reconciliation messages" , async ( ) => {
335+ const persistence = createHybridPersistence ( ) ;
336+ const account : ConfiguredMailAccount = {
337+ id : "personal" ,
338+ emailAddress : "me@example.com" ,
339+ appPassword : "personal-app-password" ,
340+ } ;
341+ const mailDatabase = persistence . mailDatabaseFor ( "personal" ) ;
342+ mailDatabase . saveMailbox ( { id : "inbox" , name : "Inbox" , unreadCount : 99 } ) ;
343+ let syncFinished = false ;
344+ let timerRanBeforeSyncFinished = false ;
345+ const client : MessageSyncClient = {
346+ async listRecentMessages ( ) {
347+ return Array . from ( { length : 99 } , ( _ , index ) => ( {
348+ id : `message-${ index } ` ,
349+ stableIdentity : `gmail:personal:message-${ index } ` ,
350+ subject : "Medium sync Message" ,
351+ receivedAt : "2026-05-23T10:00:00.000Z" ,
352+ unread : true ,
353+ readableBody : "<p>Hello</p>" ,
354+ attachments : [ ] ,
355+ mailboxIds : [ "inbox" ] ,
356+ } ) ) ;
357+ } ,
358+ } ;
359+
360+ const syncPromise = syncRecentReconciliation ( {
361+ accounts : [ account ] ,
362+ persistence,
363+ client,
364+ now : new Date ( "2026-05-24T12:00:00.000Z" ) ,
365+ windowDays : 7 ,
366+ } ) . finally ( ( ) => {
367+ syncFinished = true ;
368+ } ) ;
369+ await new Promise < void > ( ( resolve ) =>
370+ setTimeout ( ( ) => {
371+ timerRanBeforeSyncFinished = ! syncFinished ;
372+ resolve ( ) ;
373+ } , 0 ) ,
374+ ) ;
375+ await syncPromise ;
376+
377+ expect ( timerRanBeforeSyncFinished ) . toBe ( true ) ;
378+ expect (
379+ mailDatabase . listMessagesForMailbox ( "personal" , "inbox" , { limit : 99 } ) . messages ,
380+ ) . toHaveLength ( 99 ) ;
381+ } ) ;
382+
334383 it ( "uses saved Mailbox checkpoints for incremental Message sync" , async ( ) => {
335384 const persistence = createHybridPersistence ( ) ;
336385 const account : ConfiguredMailAccount = {
0 commit comments