@@ -480,10 +480,10 @@ test('runReplayScriptFile retries Maestro scrollUntilVisible with scroll probes'
480480 [
481481 [ 'wait' , [ 'label="Discover" || text="Discover" || id="Discover"' , '500' ] ] ,
482482 [ 'find' , [ 'Discover' , 'wait' , '500' ] ] ,
483- [ 'scroll' , [ 'down ' ] ] ,
483+ [ 'scroll' , [ 'up ' ] ] ,
484484 [ 'wait' , [ 'label="Discover" || text="Discover" || id="Discover"' , '500' ] ] ,
485485 [ 'find' , [ 'Discover' , 'wait' , '500' ] ] ,
486- [ 'scroll' , [ 'down ' ] ] ,
486+ [ 'scroll' , [ 'up ' ] ] ,
487487 [ 'wait' , [ 'label="Discover" || text="Discover" || id="Discover"' , '200' ] ] ,
488488 ] ,
489489 ) ;
@@ -728,6 +728,61 @@ test('runReplayScriptFile skips Maestro runFlow.when.visible commands when absen
728728 ) ;
729729} ) ;
730730
731+ test ( 'runReplayScriptFile skips Maestro runFlow.when.visible commands on false predicate' , async ( ) => {
732+ const calls : CapturedInvocation [ ] = [ ] ;
733+ const { response } = await runReplayFixture ( {
734+ label : 'maestro-run-flow-when-visible-false-skip' ,
735+ script : [
736+ 'appId: demo.app' ,
737+ '---' ,
738+ '- runFlow:' ,
739+ ' when:' ,
740+ ' visible: Continue' ,
741+ ' commands:' ,
742+ ' - tapOn: Continue' ,
743+ '' ,
744+ ] . join ( '\n' ) ,
745+ flags : { replayBackend : 'maestro' } ,
746+ invoke : async ( req ) => {
747+ calls . push ( { command : req . command , positionals : req . positionals , flags : req . flags } ) ;
748+ return { ok : true , data : { pass : false } } ;
749+ } ,
750+ } ) ;
751+
752+ assert . equal ( response . ok , true ) ;
753+ assert . deepEqual (
754+ calls . map ( ( call ) => [ call . command , call . positionals ] ) ,
755+ [ [ 'is' , [ 'visible' , 'label="Continue" || text="Continue" || id="Continue"' ] ] ] ,
756+ ) ;
757+ } ) ;
758+
759+ test ( 'runReplayScriptFile propagates Maestro runFlow.when runtime errors' , async ( ) => {
760+ const { response } = await runReplayFixture ( {
761+ label : 'maestro-run-flow-when-visible-runtime-error' ,
762+ script : [
763+ 'appId: demo.app' ,
764+ '---' ,
765+ '- runFlow:' ,
766+ ' when:' ,
767+ ' visible: Continue' ,
768+ ' commands:' ,
769+ ' - tapOn: Continue' ,
770+ '' ,
771+ ] . join ( '\n' ) ,
772+ flags : { replayBackend : 'maestro' } ,
773+ invoke : async ( ) => ( {
774+ ok : false ,
775+ error : { code : 'UNKNOWN' , message : 'fetch failed' } ,
776+ } ) ,
777+ } ) ;
778+
779+ assert . equal ( response . ok , false ) ;
780+ if ( ! response . ok ) {
781+ assert . equal ( response . error . code , 'UNKNOWN' ) ;
782+ assert . match ( response . error . message , / f e t c h f a i l e d / ) ;
783+ }
784+ } ) ;
785+
731786test ( 'runReplayScriptFile runs Maestro runFlow.when.visible commands when present' , async ( ) => {
732787 const calls : CapturedInvocation [ ] = [ ] ;
733788 const { response } = await runReplayFixture ( {
@@ -766,6 +821,42 @@ test('runReplayScriptFile runs Maestro runFlow.when.visible commands when presen
766821 ) ;
767822} ) ;
768823
824+ test ( 'runReplayScriptFile runs nested Maestro runtime commands inside runFlow.when' , async ( ) => {
825+ const calls : CapturedInvocation [ ] = [ ] ;
826+ const { response } = await runReplayFixture ( {
827+ label : 'maestro-run-flow-when-nested-runtime' ,
828+ script : [
829+ 'appId: demo.app' ,
830+ '---' ,
831+ '- runFlow:' ,
832+ ' when:' ,
833+ ' visible: Feed' ,
834+ ' commands:' ,
835+ ' - scrollUntilVisible:' ,
836+ ' element: Done' ,
837+ ' direction: DOWN' ,
838+ ' timeout: 500' ,
839+ '' ,
840+ ] . join ( '\n' ) ,
841+ flags : { replayBackend : 'maestro' } ,
842+ invoke : async ( req ) => {
843+ calls . push ( { command : req . command , positionals : req . positionals , flags : req . flags } ) ;
844+ if ( req . command === 'is' ) return { ok : true , data : { pass : true } } ;
845+ if ( req . command === 'wait' ) return { ok : true , data : { found : true } } ;
846+ return { ok : true , data : { } } ;
847+ } ,
848+ } ) ;
849+
850+ assert . equal ( response . ok , true ) ;
851+ assert . deepEqual (
852+ calls . map ( ( call ) => [ call . command , call . positionals ] ) ,
853+ [
854+ [ 'is' , [ 'visible' , 'label="Feed" || text="Feed" || id="Feed"' ] ] ,
855+ [ 'wait' , [ 'label="Done" || text="Done" || id="Done"' , '500' ] ] ,
856+ ] ,
857+ ) ;
858+ } ) ;
859+
769860test ( 'runReplayScriptFile reads shell env from request (client-collected), not daemon process.env' , async ( ) => {
770861 // Ensure the daemon's own process.env does NOT contain AD_VAR_APP.
771862 assert . equal ( process . env . AD_VAR_APP , undefined ) ;
0 commit comments