File tree Expand file tree Collapse file tree 2 files changed +28
-4
lines changed
Expand file tree Collapse file tree 2 files changed +28
-4
lines changed Original file line number Diff line number Diff line change @@ -67,7 +67,11 @@ export class McpHub {
6767 this . initializeMcpServers ( )
6868 }
6969
70- private setupWorkspaceFoldersWatcher ( ) : void {
70+ public setupWorkspaceFoldersWatcher ( ) : void {
71+ // Skip if test environment is detected
72+ if ( process . env . NODE_ENV === "test" || process . env . JEST_WORKER_ID !== undefined ) {
73+ return
74+ }
7175 this . disposables . push (
7276 vscode . workspace . onDidChangeWorkspaceFolders ( async ( ) => {
7377 await this . updateProjectMcpServers ( )
@@ -230,15 +234,15 @@ export class McpHub {
230234 // Validate configuration structure
231235 const result = McpSettingsSchema . safeParse ( config )
232236 if ( ! result . success ) {
233- vscode . window . showErrorMessage ( "项目 MCP 配置格式无效 " )
237+ vscode . window . showErrorMessage ( "Invalid project MCP configuration format " )
234238 return
235239 }
236240
237241 // Update server connections
238242 await this . updateServerConnections ( result . data . mcpServers || { } , "project" )
239243 } catch ( error ) {
240244 console . error ( "Failed to initialize project MCP servers:" , error )
241- vscode . window . showErrorMessage ( `初始化项目 MCP 服务器失败 : ${ error } ` )
245+ vscode . window . showErrorMessage ( `Failed to initialize project MCP server : ${ error } ` )
242246 }
243247 }
244248
Original file line number Diff line number Diff line change @@ -7,7 +7,27 @@ import { StdioConfigSchema } from "../McpHub"
77const fs = require ( "fs/promises" )
88const { McpHub } = require ( "../McpHub" )
99
10- jest . mock ( "vscode" )
10+ jest . mock ( "vscode" , ( ) => ( {
11+ workspace : {
12+ createFileSystemWatcher : jest . fn ( ) . mockReturnValue ( {
13+ onDidChange : jest . fn ( ) ,
14+ onDidCreate : jest . fn ( ) ,
15+ onDidDelete : jest . fn ( ) ,
16+ dispose : jest . fn ( ) ,
17+ } ) ,
18+ onDidSaveTextDocument : jest . fn ( ) ,
19+ onDidChangeWorkspaceFolders : jest . fn ( ) ,
20+ workspaceFolders : [ ] ,
21+ } ,
22+ window : {
23+ showErrorMessage : jest . fn ( ) ,
24+ showInformationMessage : jest . fn ( ) ,
25+ showWarningMessage : jest . fn ( ) ,
26+ } ,
27+ Disposable : {
28+ from : jest . fn ( ) ,
29+ } ,
30+ } ) )
1131jest . mock ( "fs/promises" )
1232jest . mock ( "../../../core/webview/ClineProvider" )
1333
You can’t perform that action at this time.
0 commit comments