@@ -468,9 +468,10 @@ describe('updateAttributionMap — incremental update', () => {
468468
469469describe ( 'buildAttributionMap — chunked processing' , ( ) => {
470470 it ( 'processes large history in chunks via requestIdleCallback' , async ( ) => {
471- // Create 120 history entries, each inserting one character
471+ // Create CHUNK_SIZE+20 history entries to force more than one chunk.
472+ const N = CHUNK_SIZE + 20 ;
472473 const entries : MockHistoryEntry [ ] = [ ] ;
473- for ( let i = 0 ; i < 120 ; i ++ ) {
474+ for ( let i = 0 ; i < N ; i ++ ) {
474475 entries . push ( {
475476 heads : [ `h${ i } ` ] ,
476477 actor : `actor${ i % 2 } ` ,
@@ -485,11 +486,9 @@ describe('buildAttributionMap — chunked processing', () => {
485486 const result = await buildAttributionMap ( handle as any , 'text' ) ;
486487
487488 expect ( result ) . not . toBeNull ( ) ;
488- expect ( result ! . entries ) . toHaveLength ( 120 ) ;
489- // requestIdleCallback should have been called for chunking
490- // 120 entries / CHUNK_SIZE chunks, plus potentially the initial call
489+ expect ( result ! . entries ) . toHaveLength ( N ) ;
491490 expect ( mockRequestIdleCallback . mock . calls . length ) . toBeGreaterThanOrEqual (
492- Math . ceil ( 120 / CHUNK_SIZE )
491+ Math . ceil ( N / CHUNK_SIZE ) ,
493492 ) ;
494493 } ) ;
495494
@@ -507,15 +506,14 @@ describe('buildAttributionMap — chunked processing', () => {
507506 mockDiff . mockImplementation ( createMockDiff ( entries ) ) ;
508507
509508 const controller = new AbortController ( ) ;
510- controller . abort ( ) ; // Abort before calling
509+ controller . abort ( ) ;
511510
512511 const result = await buildAttributionMap ( handle as any , 'text' , controller . signal ) ;
513512
514513 expect ( result ) . toBeNull ( ) ;
515514 } ) ;
516515
517516 it ( 'returns null when signal is aborted between chunks' , async ( ) => {
518- // Create enough entries to span multiple chunks
519517 const entries : MockHistoryEntry [ ] = [ ] ;
520518 for ( let i = 0 ; i < CHUNK_SIZE + 10 ; i ++ ) {
521519 entries . push ( {
@@ -531,12 +529,10 @@ describe('buildAttributionMap — chunked processing', () => {
531529
532530 const controller = new AbortController ( ) ;
533531
534- // Abort after the first chunk's requestIdleCallback fires
535532 let callCount = 0 ;
536533 mockRequestIdleCallback . mockImplementation ( ( cb : IdleRequestCallback ) => {
537534 callCount ++ ;
538535 if ( callCount === 1 ) {
539- // Let first chunk complete, then abort
540536 cb ( { didTimeout : false , timeRemaining : ( ) => 50 } as IdleDeadline ) ;
541537 controller . abort ( ) ;
542538 } else {
0 commit comments