@@ -336,6 +336,68 @@ test('snapshot rejects @ref scope without existing session snapshot', async () =
336336 }
337337} ) ;
338338
339+ test ( 'snapshot on iOS rejects sessions without a tracked app' , async ( ) => {
340+ const sessionStore = makeSessionStore ( ) ;
341+ const sessionName = 'ios-sim-no-app' ;
342+ sessionStore . set ( sessionName , makeSession ( sessionName , iosSimulatorDevice ) ) ;
343+
344+ const response = await handleSnapshotCommands ( {
345+ req : {
346+ token : 't' ,
347+ session : sessionName ,
348+ command : 'snapshot' ,
349+ positionals : [ ] ,
350+ flags : { } ,
351+ } ,
352+ sessionName,
353+ logPath : '/tmp/daemon.log' ,
354+ sessionStore,
355+ } ) ;
356+
357+ expect ( response ?. ok ) . toBe ( false ) ;
358+ if ( response ?. ok === false ) {
359+ expect ( response . error . code ) . toBe ( 'SESSION_NOT_FOUND' ) ;
360+ expect ( response . error . message ) . toMatch ( / i O S s n a p s h o t r e q u i r e s a n a c t i v e a p p s e s s i o n / i) ;
361+ }
362+ expect ( mockDispatch ) . not . toHaveBeenCalled ( ) ;
363+ } ) ;
364+
365+ test ( 'snapshot on iOS runs when the session tracks an app' , async ( ) => {
366+ const sessionStore = makeSessionStore ( ) ;
367+ const sessionName = 'ios-sim-app' ;
368+ sessionStore . set ( sessionName , {
369+ ...makeSession ( sessionName , iosSimulatorDevice ) ,
370+ appBundleId : 'org.reactnavigation.playground' ,
371+ } ) ;
372+ mockDispatch . mockResolvedValue ( {
373+ nodes : [ { index : 0 , depth : 0 , type : 'Button' , label : 'Home' } ] ,
374+ truncated : false ,
375+ backend : 'ios' ,
376+ } ) ;
377+
378+ const response = await handleSnapshotCommands ( {
379+ req : {
380+ token : 't' ,
381+ session : sessionName ,
382+ command : 'snapshot' ,
383+ positionals : [ ] ,
384+ flags : { } ,
385+ } ,
386+ sessionName,
387+ logPath : '/tmp/daemon.log' ,
388+ sessionStore,
389+ } ) ;
390+
391+ expect ( response ?. ok ) . toBe ( true ) ;
392+ expect ( mockDispatch ) . toHaveBeenCalledWith (
393+ iosSimulatorDevice ,
394+ 'snapshot' ,
395+ [ ] ,
396+ undefined ,
397+ expect . objectContaining ( { appBundleId : 'org.reactnavigation.playground' } ) ,
398+ ) ;
399+ } ) ;
400+
339401test ( 'snapshot surfaces filtered-to-zero Android guidance for interactive snapshots' , async ( ) => {
340402 const sessionStore = makeSessionStore ( ) ;
341403 const sessionName = 'android-empty-interactive' ;
0 commit comments