11import { afterEach , beforeEach , expect , test , vi } from 'vitest' ;
2+ import { createTestHost } from '../../host-environment.fixtures.ts' ;
23import fs from 'node:fs' ;
34import path from 'node:path' ;
45import { mkdtempForTestSync } from '../../tmp-dir.fixtures.ts' ;
5- import { bindTestCommandHost } from '@agent-device/test-kit' ;
6-
7- bindTestCommandHost ( ) ;
86
97vi . mock ( '@agent-device/host-kit/command' , async ( importOriginal ) => {
108 const fs = await import ( 'node:fs' ) ;
@@ -66,12 +64,14 @@ test('overlay burns touches through a cached helper and same-directory temp outp
6664 fs . writeFileSync ( telemetryPath , '{"events":[]}' ) ;
6765
6866 await overlayRecordingTouches ( {
67+ host : createTestHost ( ) ,
6968 videoPath,
7069 telemetryPath,
7170 deadline : startRecordingOverlayBudget ( ) ,
7271 } ) ;
7372 fs . writeFileSync ( videoPath , 'second original' ) ;
7473 await overlayRecordingTouches ( {
74+ host : createTestHost ( ) ,
7575 videoPath,
7676 telemetryPath,
7777 deadline : startRecordingOverlayBudget ( ) ,
@@ -112,7 +112,12 @@ test('overlay preserves Swift helper compile hints', async () => {
112112 } ) ;
113113
114114 await expect (
115- overlayRecordingTouches ( { videoPath, telemetryPath, deadline : startRecordingOverlayBudget ( ) } ) ,
115+ overlayRecordingTouches ( {
116+ host : createTestHost ( ) ,
117+ videoPath,
118+ telemetryPath,
119+ deadline : startRecordingOverlayBudget ( ) ,
120+ } ) ,
116121 ) . rejects . toMatchObject ( {
117122 code : 'COMMAND_FAILED' ,
118123 message : 'Failed to add touch overlays to the recording' ,
@@ -129,6 +134,7 @@ test('overlay defaults to the fast medium export preset', async () => {
129134 fs . writeFileSync ( telemetryPath , '{"events":[]}' ) ;
130135
131136 await overlayRecordingTouches ( {
137+ host : createTestHost ( ) ,
132138 videoPath,
133139 telemetryPath,
134140 deadline : startRecordingOverlayBudget ( ) ,
@@ -146,6 +152,7 @@ test('overlay forwards the requested high export preset', async () => {
146152 fs . writeFileSync ( telemetryPath , '{"events":[]}' ) ;
147153
148154 await overlayRecordingTouches ( {
155+ host : createTestHost ( ) ,
149156 videoPath,
150157 telemetryPath,
151158 deadline : startRecordingOverlayBudget ( ) ,
@@ -164,6 +171,7 @@ test('overlay caps the helper frame rate at the caller fps only when one was ask
164171 fs . writeFileSync ( telemetryPath , '{"events":[]}' ) ;
165172
166173 await overlayRecordingTouches ( {
174+ host : createTestHost ( ) ,
167175 videoPath,
168176 telemetryPath,
169177 deadline : startRecordingOverlayBudget ( ) ,
@@ -172,6 +180,7 @@ test('overlay caps the helper frame rate at the caller fps only when one was ask
172180
173181 mockRunCmd . mockClear ( ) ;
174182 await overlayRecordingTouches ( {
183+ host : createTestHost ( ) ,
175184 videoPath,
176185 telemetryPath,
177186 deadline : startRecordingOverlayBudget ( ) ,
@@ -188,6 +197,7 @@ test('overlay hands the helper what is left of its budget, inside the record req
188197 fs . writeFileSync ( telemetryPath , '{"events":[]}' ) ;
189198
190199 await overlayRecordingTouches ( {
200+ host : createTestHost ( ) ,
191201 videoPath,
192202 telemetryPath,
193203 deadline : startRecordingOverlayBudget ( ) ,
@@ -215,7 +225,7 @@ test('overlay hands the helper only what the finalization left of the budget', a
215225 const deadline = startRecordingOverlayBudget ( ) ;
216226 vi . setSystemTime ( Date . now ( ) + spentMs ) ;
217227
218- await overlayRecordingTouches ( { videoPath, telemetryPath, deadline } ) ;
228+ await overlayRecordingTouches ( { host : createTestHost ( ) , videoPath, telemetryPath, deadline } ) ;
219229
220230 const helperCall = mockRunCmd . mock . calls . find ( ( [ cmd ] ) => cmd !== 'xcrun' ) ;
221231 expect ( helperCall ?. [ 2 ] ?. timeoutMs ) . toBe ( OVERLAY_BUDGET_MS - spentMs ) ;
@@ -237,7 +247,12 @@ test('overlay leaves the video as recorded when compiling the helper spent its b
237247 } ) ;
238248
239249 await expect (
240- overlayRecordingTouches ( { videoPath, telemetryPath, deadline : startRecordingOverlayBudget ( ) } ) ,
250+ overlayRecordingTouches ( {
251+ host : createTestHost ( ) ,
252+ videoPath,
253+ telemetryPath,
254+ deadline : startRecordingOverlayBudget ( ) ,
255+ } ) ,
241256 ) . rejects . toMatchObject ( {
242257 code : 'COMMAND_FAILED' ,
243258 message : 'Failed to add touch overlays to the recording' ,
@@ -254,6 +269,7 @@ test('overlay names its budget when the export ran out of it', async () => {
254269 fs . writeFileSync ( telemetryPath , '{"events":[]}' ) ;
255270
256271 await overlayRecordingTouches ( {
272+ host : createTestHost ( ) ,
257273 videoPath,
258274 telemetryPath,
259275 deadline : startRecordingOverlayBudget ( ) ,
@@ -265,7 +281,12 @@ test('overlay names its budget when the export ran out of it', async () => {
265281 } ) ;
266282
267283 await expect (
268- overlayRecordingTouches ( { videoPath, telemetryPath, deadline : startRecordingOverlayBudget ( ) } ) ,
284+ overlayRecordingTouches ( {
285+ host : createTestHost ( ) ,
286+ videoPath,
287+ telemetryPath,
288+ deadline : startRecordingOverlayBudget ( ) ,
289+ } ) ,
269290 ) . rejects . toMatchObject ( {
270291 code : 'COMMAND_FAILED' ,
271292 message : `Failed to add touch overlays to the recording: the export did not finish within its ${ OVERLAY_BUDGET_MS } ms budget; a lower --fps renders faster` ,
@@ -280,6 +301,7 @@ test('overlay keeps the plain failure when the export failed with budget to spar
280301 fs . writeFileSync ( telemetryPath , '{"events":[]}' ) ;
281302
282303 await overlayRecordingTouches ( {
304+ host : createTestHost ( ) ,
283305 videoPath,
284306 telemetryPath,
285307 deadline : startRecordingOverlayBudget ( ) ,
@@ -289,7 +311,12 @@ test('overlay keeps the plain failure when the export failed with budget to spar
289311 } ) ;
290312
291313 await expect (
292- overlayRecordingTouches ( { videoPath, telemetryPath, deadline : startRecordingOverlayBudget ( ) } ) ,
314+ overlayRecordingTouches ( {
315+ host : createTestHost ( ) ,
316+ videoPath,
317+ telemetryPath,
318+ deadline : startRecordingOverlayBudget ( ) ,
319+ } ) ,
293320 ) . rejects . toMatchObject ( {
294321 message : 'Failed to add touch overlays to the recording' ,
295322 } ) ;
@@ -307,12 +334,15 @@ test('overlay keeps the video as recorded when verifying the export spent its bu
307334 } ) ;
308335
309336 await expect (
310- overlayRecordingTouches ( { videoPath, telemetryPath, deadline } ) ,
337+ overlayRecordingTouches ( { host : createTestHost ( ) , videoPath, telemetryPath, deadline } ) ,
311338 ) . rejects . toMatchObject ( {
312339 code : 'COMMAND_FAILED' ,
313340 message : `Failed to add touch overlays to the recording: the export did not finish within its ${ OVERLAY_BUDGET_MS } ms budget; a lower --fps renders faster` ,
314341 } ) ;
315- expect ( vi . mocked ( waitForPlayableVideo ) ) . toHaveBeenCalledWith ( expect . any ( String ) , { deadline } ) ;
342+ expect ( vi . mocked ( waitForPlayableVideo ) ) . toHaveBeenCalledWith ( expect . any ( String ) , {
343+ host : expect . objectContaining ( { cwd : process . cwd ( ) } ) ,
344+ deadline,
345+ } ) ;
316346 expect ( fs . readFileSync ( videoPath , 'utf8' ) ) . toBe ( 'original' ) ;
317347 expect ( fs . readdirSync ( tmpDir ) . filter ( ( name ) => name . includes ( 'agent-device-' ) ) ) . toEqual ( [ ] ) ;
318348} ) ;
0 commit comments