@@ -43,7 +43,7 @@ afterEach(() => {
4343test ( 'a read spends the family default, not the caller window' , async ( ) => {
4444 mockRunner . mockResolvedValue ( { title : 'Camera Access' } ) ;
4545
46- await readAppleAlert ( IOS_SIMULATOR , runnerOptions , { timeoutMs : 37 } ) ;
46+ await readAppleAlert ( IOS_SIMULATOR , runnerOptions , { timeoutMs : 37 } , process . env ) ;
4747
4848 assert . equal ( mockRunner . mock . calls . length , 1 ) ;
4949 assert . deepEqual ( mockRunner . mock . calls [ 0 ] ?. [ 1 ] , {
@@ -62,7 +62,12 @@ test('a wait polls until one attempt answers, and the first attempt gets the who
6262 return { title : 'Camera Access' } ;
6363 } ) ;
6464
65- const result = await awaitAppleAlert ( IOS_SIMULATOR , runnerOptions , { timeoutMs : 5_000 } ) ;
65+ const result = await awaitAppleAlert (
66+ IOS_SIMULATOR ,
67+ runnerOptions ,
68+ { timeoutMs : 5_000 } ,
69+ process . env ,
70+ ) ;
6671
6772 assert . deepEqual ( result , { title : 'Camera Access' } ) ;
6873 assert . equal ( calls , 2 ) ;
@@ -76,7 +81,12 @@ test('a wait that never sees an alert reports the timeout rather than the last a
7681 vi . useFakeTimers ( ) ;
7782 mockRunner . mockRejectedValue ( runnerAbsence ( ) ) ;
7883
79- const outcome = awaitAppleAlert ( IOS_SIMULATOR , runnerOptions , { timeoutMs : 900 } ) . then (
84+ const outcome = awaitAppleAlert (
85+ IOS_SIMULATOR ,
86+ runnerOptions ,
87+ { timeoutMs : 900 } ,
88+ process . env ,
89+ ) . then (
8090 ( ) => undefined ,
8191 ( error : unknown ) => error ,
8292 ) ;
@@ -93,7 +103,13 @@ test('an accept retries only while the backend says the alert is not there yet',
93103 throw new AppError ( 'COMMAND_FAILED' , 'runner crashed' ) ;
94104 } ) ;
95105
96- const outcome = actOnAppleAlert ( IOS_SIMULATOR , runnerOptions , 'accept' ) . then (
106+ const outcome = actOnAppleAlert (
107+ IOS_SIMULATOR ,
108+ runnerOptions ,
109+ 'accept' ,
110+ undefined ,
111+ process . env ,
112+ ) . then (
97113 ( ) => undefined ,
98114 ( error : unknown ) => error ,
99115 ) ;
@@ -107,7 +123,13 @@ test('an exhausted accept carries the scoped-snapshot fallback the agent needs n
107123 vi . useFakeTimers ( ) ;
108124 mockRunner . mockRejectedValue ( runnerAbsence ( ) ) ;
109125
110- const outcome = actOnAppleAlert ( IOS_SIMULATOR , runnerOptions , 'accept' ) . then (
126+ const outcome = actOnAppleAlert (
127+ IOS_SIMULATOR ,
128+ runnerOptions ,
129+ 'accept' ,
130+ undefined ,
131+ process . env ,
132+ ) . then (
111133 ( ) => undefined ,
112134 ( error : unknown ) => error ,
113135 ) ;
@@ -130,7 +152,12 @@ test('a wait propagates a non-absence failure instead of spending it as poll bud
130152 throw new AppError ( 'COMMAND_FAILED' , 'runner transport closed: alert not found' ) ;
131153 } ) ;
132154
133- const outcome = awaitAppleAlert ( IOS_SIMULATOR , runnerOptions , { timeoutMs : 5_000 } ) . then (
155+ const outcome = awaitAppleAlert (
156+ IOS_SIMULATOR ,
157+ runnerOptions ,
158+ { timeoutMs : 5_000 } ,
159+ process . env ,
160+ ) . then (
134161 ( ) => undefined ,
135162 ( error : unknown ) => error ,
136163 ) ;
@@ -148,7 +175,13 @@ test('an action does not retry a failure that only reads like an absence', async
148175 throw new AppError ( 'COMMAND_FAILED' , 'no alert service on this runner' ) ;
149176 } ) ;
150177
151- const outcome = actOnAppleAlert ( IOS_SIMULATOR , runnerOptions , 'dismiss' ) . then (
178+ const outcome = actOnAppleAlert (
179+ IOS_SIMULATOR ,
180+ runnerOptions ,
181+ 'dismiss' ,
182+ undefined ,
183+ process . env ,
184+ ) . then (
152185 ( ) => undefined ,
153186 ( error : unknown ) => error ,
154187 ) ;
@@ -168,7 +201,13 @@ test('the macOS helper states absence as a typed reason, and the family retries
168201 throw helperAbsence ( ) ;
169202 } ) ;
170203
171- const outcome = actOnAppleAlert ( MACOS_DEVICE , runnerOptions , 'accept' ) . then (
204+ const outcome = actOnAppleAlert (
205+ MACOS_DEVICE ,
206+ runnerOptions ,
207+ 'accept' ,
208+ undefined ,
209+ process . env ,
210+ ) . then (
172211 ( ) => undefined ,
173212 ( error : unknown ) => error ,
174213 ) ;
@@ -183,24 +222,37 @@ test('the macOS helper states absence as a typed reason, and the family retries
183222test ( 'the macOS host reads through its helper, and a frontmost-app session names no bundle' , async ( ) => {
184223 mockHelper . mockResolvedValue ( { title : 'Allow access' } ) ;
185224
186- await readAppleAlert ( MACOS_DEVICE , runnerOptions , {
187- surface : 'frontmost-app' ,
188- appBundleId : 'com.example.app' ,
189- } ) ;
225+ await readAppleAlert (
226+ MACOS_DEVICE ,
227+ runnerOptions ,
228+ {
229+ surface : 'frontmost-app' ,
230+ appBundleId : 'com.example.app' ,
231+ } ,
232+ process . env ,
233+ ) ;
190234
191235 assert . equal ( mockRunner . mock . calls . length , 0 ) ;
192- assert . deepEqual ( mockHelper . mock . calls [ 0 ] , [ 'get' , { surface : 'frontmost-app' } ] ) ;
236+ assert . deepEqual ( mockHelper . mock . calls [ 0 ] , [
237+ 'get' ,
238+ { surface : 'frontmost-app' , env : process . env } ,
239+ ] ) ;
193240} ) ;
194241
195242// The narrowing is the macOS helper's alone. A non-macOS Apple leaf keeps the session bundle
196243// whatever the surface says, exactly as the retired route passed it to the XCTest runner.
197244test ( 'the XCTest runner keeps the session bundle even on a frontmost-app surface' , async ( ) => {
198245 mockRunner . mockResolvedValue ( { title : 'Camera Access' } ) ;
199246
200- await readAppleAlert ( IOS_SIMULATOR , runnerOptions , {
201- surface : 'frontmost-app' ,
202- appBundleId : 'com.example.app' ,
203- } ) ;
247+ await readAppleAlert (
248+ IOS_SIMULATOR ,
249+ runnerOptions ,
250+ {
251+ surface : 'frontmost-app' ,
252+ appBundleId : 'com.example.app' ,
253+ } ,
254+ process . env ,
255+ ) ;
204256
205257 assert . deepEqual ( mockRunner . mock . calls [ 0 ] ?. [ 1 ] , {
206258 command : 'alert' ,
@@ -213,13 +265,19 @@ test('the XCTest runner keeps the session bundle even on a frontmost-app surface
213265test ( 'a macOS app session forwards the bundle its surface is scoped to' , async ( ) => {
214266 mockHelper . mockResolvedValue ( { action : 'dismiss' } ) ;
215267
216- await actOnAppleAlert ( MACOS_DEVICE , runnerOptions , 'dismiss' , {
217- surface : 'app' ,
218- appBundleId : 'com.example.app' ,
219- } ) ;
268+ await actOnAppleAlert (
269+ MACOS_DEVICE ,
270+ runnerOptions ,
271+ 'dismiss' ,
272+ {
273+ surface : 'app' ,
274+ appBundleId : 'com.example.app' ,
275+ } ,
276+ process . env ,
277+ ) ;
220278
221279 assert . deepEqual ( mockHelper . mock . calls [ 0 ] , [
222280 'dismiss' ,
223- { bundleId : 'com.example.app' , surface : 'app' } ,
281+ { bundleId : 'com.example.app' , surface : 'app' , env : process . env } ,
224282 ] ) ;
225283} ) ;
0 commit comments