@@ -2937,6 +2937,69 @@ flows:
29372937 path . join ( projectDir , 'web' , 'flows' , 'test.yaml' ) ,
29382938 ) ;
29392939 } ) ;
2940+
2941+ it ( 'should include config.yml (alternative extension) in discovered files when it exists' , async ( ) => {
2942+ const configContent = `
2943+ flows:
2944+ - "app/flows/**"
2945+ ` ;
2946+ const projectDir = path . resolve ( path . sep , 'project' ) ;
2947+ // First call (config.yaml) fails, second call (config.yml) succeeds
2948+ fs . promises . readFile = jest . fn ( )
2949+ . mockRejectedValueOnce ( new Error ( 'ENOENT: no such file' ) )
2950+ . mockResolvedValueOnce ( configContent ) ;
2951+ fs . promises . readdir = jest . fn ( ) . mockResolvedValue ( [ ] ) ;
2952+ fs . promises . access = jest . fn ( ) . mockResolvedValue ( undefined ) ;
2953+ ( glob as jest . Mock ) . mockResolvedValue ( [
2954+ path . join ( projectDir , 'app' , 'flows' , 'login.yaml' ) ,
2955+ ] ) ;
2956+
2957+ const files = await maestro [ 'discoverFlows' ] ( projectDir ) ;
2958+
2959+ expect ( files ) . toContain ( path . join ( projectDir , 'config.yml' ) ) ;
2960+ expect ( files ) . not . toContain ( path . join ( projectDir , 'config.yaml' ) ) ;
2961+ expect ( files ) . toContain (
2962+ path . join ( projectDir , 'app' , 'flows' , 'login.yaml' ) ,
2963+ ) ;
2964+ } ) ;
2965+
2966+ it ( 'should prefer config.yaml over config.yml when both exist' , async ( ) => {
2967+ const configContent = `
2968+ flows:
2969+ - "flows/**"
2970+ ` ;
2971+ const projectDir = path . resolve ( path . sep , 'project' ) ;
2972+ // First call (config.yaml) succeeds
2973+ fs . promises . readFile = jest . fn ( ) . mockResolvedValue ( configContent ) ;
2974+ fs . promises . readdir = jest . fn ( ) . mockResolvedValue ( [ ] ) ;
2975+ fs . promises . access = jest . fn ( ) . mockResolvedValue ( undefined ) ;
2976+ ( glob as jest . Mock ) . mockResolvedValue ( [
2977+ path . join ( projectDir , 'flows' , 'test.yaml' ) ,
2978+ ] ) ;
2979+
2980+ const files = await maestro [ 'discoverFlows' ] ( projectDir ) ;
2981+
2982+ // Should only include config.yaml, not config.yml
2983+ expect ( files ) . toContain ( path . join ( projectDir , 'config.yaml' ) ) ;
2984+ expect ( files ) . not . toContain ( path . join ( projectDir , 'config.yml' ) ) ;
2985+ } ) ;
2986+
2987+ it ( 'should exclude config.yml from flow files when no config exists' , async ( ) => {
2988+ const projectDir = path . resolve ( path . sep , 'project' ) ;
2989+ // Both config.yaml and config.yml fail
2990+ fs . promises . readFile = jest . fn ( )
2991+ . mockRejectedValue ( new Error ( 'ENOENT: no such file' ) ) ;
2992+ fs . promises . readdir = jest . fn ( ) . mockResolvedValue ( [
2993+ { name : 'flow1.yaml' , isFile : ( ) => true } ,
2994+ { name : 'config.yml' , isFile : ( ) => true } , // Should be excluded as a config file
2995+ ] ) ;
2996+ fs . promises . access = jest . fn ( ) . mockResolvedValue ( undefined ) ;
2997+
2998+ const files = await maestro [ 'discoverFlows' ] ( projectDir ) ;
2999+
3000+ expect ( files ) . toContain ( path . join ( projectDir , 'flow1.yaml' ) ) ;
3001+ expect ( files ) . not . toContain ( path . join ( projectDir , 'config.yml' ) ) ;
3002+ } ) ;
29403003 } ) ;
29413004
29423005 describe ( 'Flow Status Display' , ( ) => {
0 commit comments