@@ -112,27 +112,27 @@ it('does not fall back to 5179; prints when no project JSON present', async () =
112112 }
113113} ) ;
114114
115- it ( 'walks up directories to find project-local discovery file' , async ( ) => {
115+ it ( 'walks up directories to find discovery file and forwards ' , async ( ) => {
116116 const REAL_FETCH = globalThis . fetch as any ;
117- globalThis . fetch = vi . fn ( async ( ) => ( { ok : true } as any ) ) as any ;
117+ const calls : string [ ] = [ ] ;
118+ globalThis . fetch = vi . fn ( async ( url : any ) => {
119+ const u = String ( url ) ; calls . push ( u ) ;
120+ if ( u . endsWith ( '/health' ) ) return { ok : true } as any ;
121+ return { ok : true } as any ;
122+ } ) as any ;
118123 const oldCwd = process . cwd ( ) ;
119124 const base = mkdtempSync ( join ( tmpdir ( ) , 'be-next-walk-' ) ) ;
120125 const sub = join ( base , 'a' , 'b' ) ;
121126 mkdirSync ( sub , { recursive : true } ) ;
122127 try {
123- writeFileSync ( join ( base , '.browser-echo-mcp.json' ) , JSON . stringify ( { url : 'http://127.0.0.1:59998' , routeLogs : '/__client-logs' , timestamp : Date . now ( ) } ) ) ;
128+ writeFileSync ( join ( base , '.browser-echo-mcp.json' ) , JSON . stringify ( { url : 'http://127.0.0.1:59998' , route : '/__client-logs' , timestamp : Date . now ( ) } ) ) ;
124129 process . chdir ( sub ) ;
125130 vi . resetModules ( ) ;
126131 const mod = await import ( '../src/route' ) ;
127- const i = vi . spyOn ( console , 'log' ) . mockImplementation ( ( ) => { } ) ;
128- const w = vi . spyOn ( console , 'warn' ) . mockImplementation ( ( ) => { } ) ;
129- const e = vi . spyOn ( console , 'error' ) . mockImplementation ( ( ) => { } ) ;
130132 const req : any = { json : async ( ) => ( { sessionId : 'walkbeef' , entries : [ { level : 'error' , text : 'z' } ] } ) } ;
131133 const res : any = await mod . POST ( req ) ;
132134 expect ( ( res as any ) . status ) . toBe ( 204 ) ;
133- // With the new model, only project root is considered; printing may still happen here
134- expect ( i . mock . calls . length + w . mock . calls . length + e . mock . calls . length ) . toBeGreaterThan ( 0 ) ;
135- i . mockRestore ( ) ; w . mockRestore ( ) ; e . mockRestore ( ) ;
135+ expect ( calls . some ( ( u ) => u === 'http://127.0.0.1:59998/__client-logs' ) ) . toBe ( true ) ;
136136 } finally {
137137 process . chdir ( oldCwd ) ;
138138 try { rmSync ( base , { recursive : true , force : true } ) ; } catch { }
0 commit comments