@@ -51,6 +51,12 @@ vi.mock("vscode", () => ({
5151 } ,
5252} ) )
5353
54+ // Normalize paths across platforms for test lookups
55+ const normalizePathForTest = ( p : string ) =>
56+ String ( p )
57+ . replace ( / ^ [ A - Z a - z ] : / i, "" )
58+ . replace ( / \\ / g, "/" )
59+
5460describe ( "Hierarchical project MCP configuration resolution" , ( ) => {
5561 const fileMap : Record < string , string > = { }
5662 const workspaceRoot = "/home/user/mono-repo/packages/frontend"
@@ -63,18 +69,18 @@ describe("Hierarchical project MCP configuration resolution", () => {
6369 vi . clearAllMocks ( )
6470 process . env . NODE_ENV = "test"
6571
66- // Prepare hierarchical files
67- fileMap [ repoLevel ] = JSON . stringify ( {
72+ // Prepare hierarchical files (store using normalized keys)
73+ fileMap [ normalizePathForTest ( repoLevel ) ] = JSON . stringify ( {
6874 mcpServers : {
6975 alpha : { type : "stdio" , command : "node" , args : [ "repo.js" ] , disabled : true } ,
7076 } ,
7177 } )
72- fileMap [ packagesLevel ] = JSON . stringify ( {
78+ fileMap [ normalizePathForTest ( packagesLevel ) ] = JSON . stringify ( {
7379 mcpServers : {
7480 beta : { type : "stdio" , command : "node" , args : [ "pkg.js" ] , disabled : true } ,
7581 } ,
7682 } )
77- fileMap [ appLevel ] = JSON . stringify ( {
83+ fileMap [ normalizePathForTest ( appLevel ) ] = JSON . stringify ( {
7884 mcpServers : {
7985 // Override alpha at most specific level
8086 alpha : { type : "stdio" , command : "node" , args : [ "app.js" ] , disabled : true } ,
@@ -83,14 +89,14 @@ describe("Hierarchical project MCP configuration resolution", () => {
8389
8490 // Configure fs.promises mocks
8591 ; ( fs as any ) . access . mockImplementation ( async ( p : any ) => {
86- const key = String ( p )
92+ const key = normalizePathForTest ( String ( p ) )
8793 if ( fileMap [ key ] ) return
8894 const err : any = new Error ( "ENOENT" )
8995 err . code = "ENOENT"
9096 throw err
9197 } )
9298 ; ( fs as any ) . readFile . mockImplementation ( async ( p : any , _enc ?: any ) => {
93- const key = String ( p )
99+ const key = normalizePathForTest ( String ( p ) )
94100 if ( fileMap [ key ] ) return fileMap [ key ]
95101 // default empty config to avoid syntax errors
96102 return "{}"
0 commit comments