@@ -679,6 +679,68 @@ sessionDefaults:
679679 expect ( parsed . sessionDefaults ?. deviceId ) . toBeUndefined ( ) ;
680680 } ) ;
681681
682+ it ( 'continues setup with no default device when both discovery commands fail' , async ( ) => {
683+ const { fs, getStoredConfig } = createSetupFs ( ) ;
684+
685+ const executor : CommandExecutor = async ( command ) => {
686+ if ( command [ 0 ] === 'xcrun' && command [ 1 ] === 'devicectl' ) {
687+ throw new Error ( 'devicectl unavailable' ) ;
688+ }
689+
690+ if ( command [ 0 ] === 'xcrun' && command [ 1 ] === 'xctrace' ) {
691+ return createMockCommandResponse ( { success : false , output : '' , error : 'xctrace failed' } ) ;
692+ }
693+
694+ if ( command . includes ( '--json' ) ) {
695+ return createMockCommandResponse ( {
696+ success : true ,
697+ output : JSON . stringify ( {
698+ devices : {
699+ 'iOS 17.0' : [
700+ {
701+ name : 'iPhone 15' ,
702+ udid : 'SIM-1' ,
703+ state : 'Shutdown' ,
704+ isAvailable : true ,
705+ } ,
706+ ] ,
707+ } ,
708+ } ) ,
709+ } ) ;
710+ }
711+
712+ return createMockCommandResponse ( {
713+ success : true ,
714+ output : `Information about workspace "App":\n Schemes:\n App` ,
715+ } ) ;
716+ } ;
717+
718+ const prompter : Prompter = {
719+ selectOne : async < T > ( opts : { options : Array < { value : T } > } ) => opts . options [ 0 ] . value ,
720+ selectMany : async < T > ( opts : { options : Array < { value : T } > } ) => {
721+ const loggingOption = opts . options . find ( ( option ) => option . value === ( 'logging' as T ) ) ;
722+ return loggingOption ? [ loggingOption . value ] : opts . options . map ( ( option ) => option . value ) ;
723+ } ,
724+ confirm : async ( opts : { defaultValue : boolean } ) => opts . defaultValue ,
725+ } ;
726+
727+ await runSetupWizard ( {
728+ cwd,
729+ fs,
730+ executor,
731+ prompter,
732+ quietOutput : true ,
733+ } ) ;
734+
735+ const parsed = parseYaml ( getStoredConfig ( ) ) as {
736+ sessionDefaults ?: Record < string , unknown > ;
737+ } ;
738+
739+ expect ( parsed . sessionDefaults ?. deviceId ) . toBeUndefined ( ) ;
740+ expect ( parsed . sessionDefaults ?. simulatorId ) . toBeUndefined ( ) ;
741+ expect ( parsed . sessionDefaults ?. simulatorName ) . toBeUndefined ( ) ;
742+ } ) ;
743+
682744 it ( 'continues setup with no default simulator when no simulators are available' , async ( ) => {
683745 const { fs, getStoredConfig } = createSetupFs ( ) ;
684746
0 commit comments