Skip to content

Commit 26941dc

Browse files
author
aheizi
committed
switch the toasts to English
fix test
1 parent f776069 commit 26941dc

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

src/services/mcp/McpHub.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff 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

src/services/mcp/__tests__/McpHub.test.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,27 @@ import { StdioConfigSchema } from "../McpHub"
77
const fs = require("fs/promises")
88
const { 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+
}))
1131
jest.mock("fs/promises")
1232
jest.mock("../../../core/webview/ClineProvider")
1333

0 commit comments

Comments
 (0)