@@ -332,7 +332,7 @@ describe.skipIf(!RUN_API_INTEGRATION_TESTS)('GET /v1/sandboxes/:id/exec/:execId
332332 expect ( body . ended_at ) . toBeDefined ( )
333333 } )
334334
335- test ( 'returns queued exec from async execution' , async ( ) => {
335+ test ( 'returns completed exec from async execution (background fiber finishes) ' , async ( ) => {
336336 const env = createTestEnv ( )
337337 const sandboxId = await createRunningSandbox ( env )
338338
@@ -347,6 +347,9 @@ describe.skipIf(!RUN_API_INTEGRATION_TESTS)('GET /v1/sandboxes/:id/exec/:execId
347347 )
348348 const execBody = ( yield * execRes . json ) as { exec_id : string }
349349
350+ // Allow the daemon fiber to complete
351+ yield * Effect . yieldNow ( )
352+
350353 const getRes = yield * client . execute (
351354 HttpClientRequest . get (
352355 `/v1/sandboxes/${ sandboxId } /exec/${ execBody . exec_id } ` ,
@@ -359,8 +362,9 @@ describe.skipIf(!RUN_API_INTEGRATION_TESTS)('GET /v1/sandboxes/:id/exec/:execId
359362
360363 expect ( result . status ) . toBe ( 200 )
361364 const body = result . body as Record < string , unknown >
362- expect ( body . status ) . toBe ( 'queued' )
363- expect ( body . exit_code ) . toBeNull ( )
365+ // Background fiber runs the exec and transitions to done
366+ expect ( body . status ) . toBe ( 'done' )
367+ expect ( body . exit_code ) . toBe ( 0 )
364368 } )
365369
366370 test ( 'returns 404 for unknown exec' , async ( ) => {
@@ -474,13 +478,16 @@ describe.skipIf(!RUN_API_INTEGRATION_TESTS)('GET /v1/sandboxes/:id/execs — lis
474478 HttpClientRequest . bodyUnsafeJson ( { cmd : [ 'echo' , 'sync' ] } ) ,
475479 ) ,
476480 )
477- // Async exec → queued
481+ // Async exec → also completes to done (background fiber runs immediately in tests)
478482 yield * client . execute (
479483 HttpClientRequest . post ( `/v1/sandboxes/${ sandboxId } /exec` ) . pipe (
480484 HttpClientRequest . bodyUnsafeJson ( { cmd : [ 'sleep' , '10' ] , wait : false } ) ,
481485 ) ,
482486 )
483487
488+ // Allow the daemon fiber to complete
489+ yield * Effect . yieldNow ( )
490+
484491 const response = yield * client . execute (
485492 HttpClientRequest . get ( `/v1/sandboxes/${ sandboxId } /execs?status=done` ) ,
486493 )
@@ -491,8 +498,10 @@ describe.skipIf(!RUN_API_INTEGRATION_TESTS)('GET /v1/sandboxes/:id/execs — lis
491498
492499 expect ( result . status ) . toBe ( 200 )
493500 const body = result . body as { execs : Array < { status : string } > }
494- expect ( body . execs . length ) . toBe ( 1 )
501+ // Both execs complete to done (background fiber finishes immediately with in-memory services)
502+ expect ( body . execs . length ) . toBe ( 2 )
495503 expect ( body . execs [ 0 ] . status ) . toBe ( 'done' )
504+ expect ( body . execs [ 1 ] . status ) . toBe ( 'done' )
496505 } )
497506
498507 test ( 'returns 404 for unknown sandbox' , async ( ) => {
@@ -710,7 +719,7 @@ describe.skipIf(!RUN_API_INTEGRATION_TESTS)('Exec status transitions', () => {
710719 expect ( result . ended_at ) . toBeDefined ( )
711720 } )
712721
713- test ( 'async exec stays queued until processed ' , async ( ) => {
722+ test ( 'async exec transitions to done after background fiber completes ' , async ( ) => {
714723 const env = createTestEnv ( )
715724 const sandboxId = await createRunningSandbox ( env )
716725
@@ -725,6 +734,9 @@ describe.skipIf(!RUN_API_INTEGRATION_TESTS)('Exec status transitions', () => {
725734 )
726735 const execBody = ( yield * execRes . json ) as { exec_id : string }
727736
737+ // Allow the daemon fiber to complete
738+ yield * Effect . yieldNow ( )
739+
728740 const getRes = yield * client . execute (
729741 HttpClientRequest . get (
730742 `/v1/sandboxes/${ sandboxId } /exec/${ execBody . exec_id } ` ,
@@ -735,10 +747,10 @@ describe.skipIf(!RUN_API_INTEGRATION_TESTS)('Exec status transitions', () => {
735747 } ) ,
736748 )
737749
738- expect ( result . status ) . toBe ( 'queued ' )
739- expect ( result . exit_code ) . toBeNull ( )
740- expect ( result . started_at ) . toBeNull ( )
741- expect ( result . ended_at ) . toBeNull ( )
750+ expect ( result . status ) . toBe ( 'done ' )
751+ expect ( result . exit_code ) . toBe ( 0 )
752+ expect ( result . started_at ) . toBeDefined ( )
753+ expect ( result . ended_at ) . toBeDefined ( )
742754 } )
743755} )
744756
0 commit comments