switch the toasts to English

fix test
This commit is contained in:
aheizi 2025-03-15 17:33:04 +08:00
parent f77606996f
commit 26941dcaae
2 changed files with 28 additions and 4 deletions

View file

@ -67,7 +67,11 @@ export class McpHub {
this.initializeMcpServers()
}
private setupWorkspaceFoldersWatcher(): void {
public setupWorkspaceFoldersWatcher(): void {
// Skip if test environment is detected
if (process.env.NODE_ENV === "test" || process.env.JEST_WORKER_ID !== undefined) {
return
}
this.disposables.push(
vscode.workspace.onDidChangeWorkspaceFolders(async () => {
await this.updateProjectMcpServers()
@ -230,7 +234,7 @@ export class McpHub {
// Validate configuration structure
const result = McpSettingsSchema.safeParse(config)
if (!result.success) {
vscode.window.showErrorMessage("项目 MCP 配置格式无效")
vscode.window.showErrorMessage("Invalid project MCP configuration format")
return
}
@ -238,7 +242,7 @@ export class McpHub {
await this.updateServerConnections(result.data.mcpServers || {}, "project")
} catch (error) {
console.error("Failed to initialize project MCP servers:", error)
vscode.window.showErrorMessage(`初始化项目 MCP 服务器失败: ${error}`)
vscode.window.showErrorMessage(`Failed to initialize project MCP server: ${error}`)
}
}

View file

@ -7,7 +7,27 @@ import { StdioConfigSchema } from "../McpHub"
const fs = require("fs/promises")
const { McpHub } = require("../McpHub")
jest.mock("vscode")
jest.mock("vscode", () => ({
workspace: {
createFileSystemWatcher: jest.fn().mockReturnValue({
onDidChange: jest.fn(),
onDidCreate: jest.fn(),
onDidDelete: jest.fn(),
dispose: jest.fn(),
}),
onDidSaveTextDocument: jest.fn(),
onDidChangeWorkspaceFolders: jest.fn(),
workspaceFolders: [],
},
window: {
showErrorMessage: jest.fn(),
showInformationMessage: jest.fn(),
showWarningMessage: jest.fn(),
},
Disposable: {
from: jest.fn(),
},
}))
jest.mock("fs/promises")
jest.mock("../../../core/webview/ClineProvider")