@@ -190,12 +190,45 @@ test('resolveTargetDevice uses injected device inventory without local discovery
190190} ) ;
191191
192192test ( 'resolveTargetDevice treats empty injected inventory as authoritative' , async ( ) => {
193- const err = await withDeviceInventoryProvider (
194- async ( ) => [ ] ,
195- async ( ) => await resolveTargetDevice ( { platform : 'ios' } ) ,
196- ) . catch ( ( error ) => error ) ;
193+ await expectDeviceNotFound ( ( ) =>
194+ withDeviceInventoryProvider (
195+ async ( ) => [ ] ,
196+ async ( ) => await resolveTargetDevice ( { platform : 'ios' } ) ,
197+ ) ,
198+ ) ;
199+
200+ assert . equal ( mockListAppleDevices . mock . calls . length , 0 ) ;
201+ } ) ;
202+
203+ test ( 'resolveTargetDevice fast-paths explicit macOS without Apple mobile discovery' , async ( ) => {
204+ const result = await resolveTargetDevice ( { platform : 'macos' } ) ;
205+
206+ assert . equal ( result . platform , 'macos' ) ;
207+ assert . equal ( result . id , 'host-macos-local' ) ;
208+ assert . equal ( mockListAppleDevices . mock . calls . length , 0 ) ;
209+ } ) ;
210+
211+ test ( 'resolveTargetDevice fast-paths Apple desktop target without simulator-set discovery' , async ( ) => {
212+ const result = await resolveTargetDevice ( {
213+ platform : 'apple' ,
214+ target : 'desktop' ,
215+ iosSimulatorDeviceSet : '/tmp/simulators' ,
216+ } ) ;
217+
218+ assert . equal ( result . platform , 'macos' ) ;
219+ assert . equal ( result . target , 'desktop' ) ;
220+ assert . equal ( mockListAppleDevices . mock . calls . length , 0 ) ;
221+ } ) ;
222+
223+ test ( 'resolveTargetDevice fast-path preserves macOS selector validation' , async ( ) => {
224+ await expectDeviceNotFound ( ( ) => resolveTargetDevice ( { platform : 'macos' , udid : 'other-mac' } ) ) ;
197225
198- assert . ok ( err instanceof AppError ) ;
199- assert . equal ( err . code , 'DEVICE_NOT_FOUND' ) ;
200226 assert . equal ( mockListAppleDevices . mock . calls . length , 0 ) ;
201227} ) ;
228+
229+ async function expectDeviceNotFound ( action : ( ) => Promise < unknown > ) : Promise < void > {
230+ const err = await action ( ) . catch ( ( error ) => error ) ;
231+
232+ assert . ok ( err instanceof AppError ) ;
233+ assert . equal ( err . code , 'DEVICE_NOT_FOUND' ) ;
234+ }
0 commit comments