@@ -48,14 +48,14 @@ describe("buildMailboxMailPrompt", () => {
4848} ) ;
4949
5050describe ( "driveMailboxMail" , ( ) => {
51- test ( "idle parent with one terminal drives even while siblings run" , ( ) => {
51+ test ( "idle parent with one terminal drives even while siblings run" , async ( ) => {
5252 const records = new Map < string , FleetDryMailboxRecord > ( [
5353 [ "done" , { status : "done" , report : "ok" , description : "lane" } ] ,
5454 [ "live" , { status : "running" } ] ,
5555 ] ) ;
5656 const order : string [ ] = [ ] ;
5757 const sent : string [ ] = [ ] ;
58- const driven = driveMailboxMail ( {
58+ const driven = await driveMailboxMail ( {
5959 parentProcessing : false ,
6060 mailbox : mapMailbox ( records ) ,
6161 lanes : [ ] ,
@@ -77,12 +77,12 @@ describe("driveMailboxMail", () => {
7777 expect ( records . get ( "live" ) ?. collected ) . not . toBe ( true ) ;
7878 } ) ;
7979
80- test ( "fail path is the same terminal collect" , ( ) => {
80+ test ( "fail path is the same terminal collect" , async ( ) => {
8181 const records = new Map < string , FleetDryMailboxRecord > ( [
8282 [ "fail" , { status : "failed" , error : "boom" } ] ,
8383 ] ) ;
8484 const sent : string [ ] = [ ] ;
85- const driven = driveMailboxMail ( {
85+ const driven = await driveMailboxMail ( {
8686 parentProcessing : false ,
8787 mailbox : mapMailbox ( records ) ,
8888 lanes : [ ] ,
@@ -97,7 +97,7 @@ describe("driveMailboxMail", () => {
9797 expect ( records . get ( "fail" ) ?. collected ) . toBe ( true ) ;
9898 } ) ;
9999
100- test ( "parentProcessing or empty mailbox is a no-op" , ( ) => {
100+ test ( "parentProcessing or empty mailbox is a no-op" , async ( ) => {
101101 const records = new Map < string , FleetDryMailboxRecord > ( [
102102 [ "done" , { status : "done" , report : "ok" } ] ,
103103 ] ) ;
@@ -118,7 +118,7 @@ describe("driveMailboxMail", () => {
118118 } ) ,
119119 ) . toBe ( false ) ;
120120 expect (
121- driveMailboxMail ( {
121+ await driveMailboxMail ( {
122122 parentProcessing : false ,
123123 mailbox : mapMailbox ( new Map ( ) ) ,
124124 lanes : [ ] ,
@@ -128,7 +128,7 @@ describe("driveMailboxMail", () => {
128128 expect ( records . get ( "done" ) ?. collected ) . not . toBe ( true ) ;
129129 } ) ;
130130
131- test ( "already-collected terminals are not driven again" , ( ) => {
131+ test ( "already-collected terminals are not driven again" , async ( ) => {
132132 const sessions = createSubAgentSessionStore ( ) ;
133133 const mailbox = createFleetMailbox ( sessions ) ;
134134 const session = sessions . start ( {
@@ -141,7 +141,7 @@ describe("driveMailboxMail", () => {
141141 sessions . complete ( "coll" , "already taken" ) ;
142142 mailbox . take ( "coll" ) ;
143143 expect (
144- driveMailboxMail ( {
144+ await driveMailboxMail ( {
145145 parentProcessing : false ,
146146 mailbox,
147147 lanes : sessions . list ( ) ,
@@ -155,11 +155,11 @@ describe("driveMailboxMail", () => {
155155 ) . toBe ( false ) ;
156156 } ) ;
157157
158- test ( "send failure leaves reports waitable" , ( ) => {
158+ test ( "send failure leaves reports waitable" , async ( ) => {
159159 const records = new Map < string , FleetDryMailboxRecord > ( [
160160 [ "w1" , { status : "done" , report : "ok" } ] ,
161161 ] ) ;
162- const driven = driveMailboxMail ( {
162+ const driven = await driveMailboxMail ( {
163163 parentProcessing : false ,
164164 mailbox : mapMailbox ( records ) ,
165165 lanes : [ ] ,
@@ -176,7 +176,7 @@ describe("driveMailboxMail", () => {
176176 const records = new Map < string , FleetDryMailboxRecord > ( [
177177 [ "w1" , { status : "done" , report : "ok" } ] ,
178178 ] ) ;
179- const driven = driveMailboxMail ( {
179+ const driven = await driveMailboxMail ( {
180180 parentProcessing : false ,
181181 mailbox : mapMailbox ( records ) ,
182182 lanes : [ ] ,
@@ -193,26 +193,31 @@ describe("driveMailboxMail", () => {
193193 const records = new Map < string , FleetDryMailboxRecord > ( [
194194 [ "w1" , { status : "done" , report : "ok" } ] ,
195195 ] ) ;
196- const driven = driveMailboxMail ( {
196+ let resolveSend : ( ( ok : boolean ) => void ) | undefined ;
197+ const driven = await driveMailboxMail ( {
197198 parentProcessing : false ,
198199 mailbox : mapMailbox ( records ) ,
199200 lanes : [ ] ,
200201 beginSystemContinuation : ( ) => undefined ,
201- send : ( ) => Promise . resolve ( true ) ,
202+ send : ( ) =>
203+ new Promise ( ( resolve ) => {
204+ resolveSend = resolve ;
205+ } ) ,
202206 } ) ;
203207 expect ( driven ) . toBe ( true ) ;
204208 expect ( records . get ( "w1" ) ?. collected ) . not . toBe ( true ) ;
209+ resolveSend ?.( true ) ;
205210 await Promise . resolve ( ) ;
206211 expect ( records . get ( "w1" ) ?. collected ) . toBe ( true ) ;
207212 } ) ;
208213
209- test ( "awaiting_director is not mailbox mail" , ( ) => {
214+ test ( "awaiting_director is not mailbox mail" , async ( ) => {
210215 const records = new Map < string , FleetDryMailboxRecord > ( [
211216 [ "ask" , { status : "awaiting_director" } ] ,
212217 [ "live" , { status : "running" } ] ,
213218 ] ) ;
214219 expect (
215- driveMailboxMail ( {
220+ await driveMailboxMail ( {
216221 parentProcessing : false ,
217222 mailbox : mapMailbox ( records ) ,
218223 lanes : [ ] ,
0 commit comments