@@ -123,7 +123,7 @@ describe("systemSection", () => {
123123 repoRemote : null ,
124124 projectPath : projectDir ,
125125 linkedAt : Date . now ( ) ,
126- } )
126+ } , { awaitBackfill : true } )
127127 resetEnablementMemoForTests ( )
128128 memoryEnabledCache . set ( 77 , { checkedAt : Date . now ( ) } )
129129 try {
@@ -244,7 +244,7 @@ describe("systemSection", () => {
244244 repoRemote : null ,
245245 projectPath : projectDir ,
246246 linkedAt : Date . now ( ) ,
247- } )
247+ } , { awaitBackfill : true } )
248248 expect ( await inProject ( systemSection ) ) . toContain ( 'is "analytics"' )
249249 await clearLocalBinding ( projectDir , { scope : ACME_SCOPE } )
250250 globalThis . fetch = ( async ( ) =>
@@ -283,7 +283,7 @@ describe("systemSection", () => {
283283 repoRemote : null ,
284284 projectPath : projectDir ,
285285 linkedAt : Date . now ( ) - 10 * 60 * 1000 ,
286- } )
286+ } , { awaitBackfill : true } )
287287 const { expireValidationForTests } = await import ( "../../../src/altimate/workspace/state" )
288288 expireValidationForTests ?.( projectDir )
289289 let unlinkedMidFlight = false
@@ -329,7 +329,7 @@ describe("systemSection", () => {
329329 repoRemote : null ,
330330 projectPath : projectDir ,
331331 linkedAt : Date . now ( ) - 10 * 60 * 1000 ,
332- } )
332+ } , { awaitBackfill : true } )
333333 const { expireValidationForTests } = await import ( "../../../src/altimate/workspace/state" )
334334 expireValidationForTests ( projectDir )
335335 globalThis . fetch = ( async ( ) => {
@@ -399,7 +399,7 @@ describe("systemSection", () => {
399399 repoRemote : null ,
400400 projectPath : projectDir ,
401401 linkedAt : Date . now ( ) - 10 * 60 * 1000 ,
402- } )
402+ } , { awaitBackfill : true } )
403403 const { expireValidationForTests } = await import ( "../../../src/altimate/workspace/state" )
404404 expireValidationForTests ( projectDir )
405405 // First step: bound (served from cache while the server is asked).
@@ -427,7 +427,7 @@ describe("systemSection", () => {
427427 repoRemote : null ,
428428 projectPath : other ,
429429 linkedAt : Date . now ( ) ,
430- } )
430+ } , { awaitBackfill : true } )
431431 globalThis . fetch = ( async ( ) =>
432432 new Response ( JSON . stringify ( { detail : "not found" } ) , {
433433 status : 404 ,
@@ -469,7 +469,7 @@ describe("systemSection", () => {
469469 repoRemote : null ,
470470 projectPath : projectDir ,
471471 linkedAt : Date . now ( ) ,
472- } )
472+ } , { awaitBackfill : true } )
473473 expect ( await inProject ( systemSection ) ) . toContain ( 'is "Linked"' )
474474 } )
475475
@@ -484,15 +484,13 @@ describe("systemSection", () => {
484484 repoRemote : null ,
485485 projectPath : projectDir ,
486486 linkedAt : Date . now ( ) - 10 * 60 * 1000 ,
487- } )
487+ } , { awaitBackfill : true } )
488488 const { expireValidationForTests } = await import ( "../../../src/altimate/workspace/state" )
489489 expireValidationForTests ( projectDir )
490490 let release ! : ( ) => void
491491 const gate = new Promise < void > ( ( r ) => ( release = r ) )
492492 let firstStarted ! : ( ) => void
493493 const firstOnWire = new Promise < void > ( ( r ) => ( firstStarted = r ) )
494- let secondStarted ! : ( ) => void
495- const secondOnWire = new Promise < void > ( ( r ) => ( secondStarted = r ) )
496494 let calls = 0
497495 globalThis . fetch = ( async ( ) => {
498496 calls ++
@@ -507,7 +505,6 @@ describe("systemSection", () => {
507505 { status : 200 , headers : { "content-type" : "application/json" } } ,
508506 )
509507 }
510- secondStarted ( )
511508 return new Response ( JSON . stringify ( { detail : "not found" } ) , {
512509 status : 404 ,
513510 headers : { "content-type" : "application/json" } ,
@@ -516,11 +513,12 @@ describe("systemSection", () => {
516513 const first = inProject ( systemSection )
517514 await firstOnWire // step 1's request is out and parked on the gate
518515 await clearLocalBinding ( projectDir , { scope : ACME_SCOPE } )
519- const second = inProject ( systemSection )
520- await secondOnWire // step 2 made its OWN request while step 1 was still pending
516+ // Step 2 answers while step 1 is still parked. The unlink records this project as unbound, so
517+ // step 2 needs no request of its own; joined to step 1's resolve, it could only render what
518+ // step 1 knew.
519+ const next = await inProject ( systemSection )
521520 release ( )
522- const [ , next ] = await Promise . all ( [ first , second ] )
523- expect ( calls ) . toBe ( 2 )
521+ await first
524522 expect ( next ) . not . toContain ( 'is "old"' )
525523 expect ( next ) . toContain ( "No Altimate Workspace" )
526524 } )
@@ -599,7 +597,7 @@ describe("systemSection", () => {
599597 repoRemote : null ,
600598 projectPath : projectDir ,
601599 linkedAt : Date . now ( ) ,
602- } )
600+ } , { awaitBackfill : true } )
603601 setCreds ( "acme" )
604602 let switched = false
605603 globalThis . fetch = ( ( ) =>
@@ -634,7 +632,7 @@ describe("systemSection", () => {
634632 repoRemote : null ,
635633 projectPath : projectDir ,
636634 linkedAt : Date . now ( ) ,
637- } )
635+ } , { awaitBackfill : true } )
638636 let t = 5_000_000
639637 setClockForTests ( ( ) => t )
640638 expect ( await inProject ( systemSection ) ) . toContain ( 'is "mine"' ) // memo filled for A
@@ -746,7 +744,7 @@ describe("systemSection", () => {
746744 repoRemote : null ,
747745 projectPath : projectDir ,
748746 linkedAt : Date . now ( ) ,
749- } )
747+ } , { awaitBackfill : true } )
750748 const saved : Record < string , string | undefined > = { }
751749 const pinEnv : Record < string , string > = {
752750 ALTIMATE_CODE_SERVE : "1" ,
@@ -787,7 +785,7 @@ describe("systemSection", () => {
787785 repoRemote : null ,
788786 projectPath : projectDir ,
789787 linkedAt : Date . now ( ) ,
790- } )
788+ } , { awaitBackfill : true } )
791789 const saved : Record < string , string | undefined > = { }
792790 const pinEnv : Record < string , string > = {
793791 ALTIMATE_CODE_SERVE : "1" ,
0 commit comments