@@ -124,13 +124,106 @@ describe('setup command', () => {
124124 } ;
125125
126126 expect ( parsed . enabledWorkflows ?. length ) . toBeGreaterThan ( 0 ) ;
127+ expect ( parsed . enabledWorkflows ) . not . toContain ( 'doctor' ) ;
127128 expect ( parsed . debug ) . toBe ( false ) ;
128129 expect ( parsed . sentryDisabled ) . toBe ( false ) ;
129130 expect ( parsed . sessionDefaults ?. workspacePath ) . toBe ( 'App.xcworkspace' ) ;
130131 expect ( parsed . sessionDefaults ?. scheme ) . toBe ( 'App' ) ;
131132 expect ( parsed . sessionDefaults ?. simulatorId ) . toBe ( 'SIM-1' ) ;
132133 } ) ;
133134
135+ it ( 'shows debug-gated workflows when existing config enables debug' , async ( ) => {
136+ let storedConfig = 'schemaVersion: 1\ndebug: true\n' ;
137+ let offeredWorkflowIds : string [ ] = [ ] ;
138+
139+ const fs = createMockFileSystemExecutor ( {
140+ existsSync : ( targetPath ) => targetPath === configPath && storedConfig . length > 0 ,
141+ stat : async ( ) => ( { isDirectory : ( ) => true , mtimeMs : 0 } ) ,
142+ readdir : async ( targetPath ) => {
143+ if ( targetPath === cwd ) {
144+ return [
145+ {
146+ name : 'App.xcworkspace' ,
147+ isDirectory : ( ) => true ,
148+ isSymbolicLink : ( ) => false ,
149+ } ,
150+ ] ;
151+ }
152+
153+ return [ ] ;
154+ } ,
155+ readFile : async ( targetPath ) => {
156+ if ( targetPath !== configPath ) {
157+ throw new Error ( `Unexpected read path: ${ targetPath } ` ) ;
158+ }
159+ return storedConfig ;
160+ } ,
161+ writeFile : async ( targetPath , content ) => {
162+ if ( targetPath !== configPath ) {
163+ throw new Error ( `Unexpected write path: ${ targetPath } ` ) ;
164+ }
165+ storedConfig = content ;
166+ } ,
167+ } ) ;
168+
169+ const executor : CommandExecutor = async ( command ) => {
170+ if ( command . includes ( '--json' ) ) {
171+ return createMockCommandResponse ( {
172+ success : true ,
173+ output : JSON . stringify ( {
174+ devices : {
175+ 'iOS 17.0' : [
176+ {
177+ name : 'iPhone 15' ,
178+ udid : 'SIM-1' ,
179+ state : 'Shutdown' ,
180+ isAvailable : true ,
181+ } ,
182+ ] ,
183+ } ,
184+ } ) ,
185+ } ) ;
186+ }
187+
188+ if ( command [ 0 ] === 'xcrun' ) {
189+ return createMockCommandResponse ( {
190+ success : true ,
191+ output : `== Devices ==\n-- iOS 17.0 --\n iPhone 15 (SIM-1) (Shutdown)` ,
192+ } ) ;
193+ }
194+
195+ return createMockCommandResponse ( {
196+ success : true ,
197+ output : `Information about workspace "App":\n Schemes:\n App` ,
198+ } ) ;
199+ } ;
200+
201+ const prompter : Prompter = {
202+ selectOne : async < T > ( opts : { options : Array < { value : T } > } ) => opts . options [ 0 ] . value ,
203+ selectMany : async < T > ( opts : { options : Array < { value : T } > } ) => {
204+ offeredWorkflowIds = opts . options . map ( ( option ) => String ( option . value ) ) ;
205+ return opts . options . map ( ( option ) => option . value ) ;
206+ } ,
207+ confirm : async ( opts : { defaultValue : boolean } ) => opts . defaultValue ,
208+ } ;
209+
210+ await runSetupWizard ( {
211+ cwd,
212+ fs,
213+ executor,
214+ prompter,
215+ quietOutput : true ,
216+ } ) ;
217+
218+ const parsed = parseYaml ( storedConfig ) as {
219+ debug ?: boolean ;
220+ enabledWorkflows ?: string [ ] ;
221+ } ;
222+
223+ expect ( parsed . debug ) . toBe ( true ) ;
224+ expect ( offeredWorkflowIds ) . toContain ( 'doctor' ) ;
225+ } ) ;
226+
134227 it ( 'fails fast when Xcode command line tools are unavailable' , async ( ) => {
135228 const failingExecutor : CommandExecutor = async ( command ) => {
136229 if ( command [ 0 ] === 'xcodebuild' ) {
0 commit comments