Skip to content

Commit df781ab

Browse files
committed
fix: resolve unit test failures in PR #5889
- Fix VSCode mock onDidChangeWorkspaceFolders to accept callback parameter - Update MCP test mocks to properly test auto-omit functionality - Update test snapshots to reflect new MCP content omission behavior - All core functionality tests now passing
1 parent 9d5be80 commit df781ab

File tree

6 files changed

+10
-72
lines changed

6 files changed

+10
-72
lines changed

src/__mocks__/vscode.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const mockRelativePattern = class {
4646
export const workspace = {
4747
workspaceFolders: [],
4848
getWorkspaceFolder: () => null,
49-
onDidChangeWorkspaceFolders: () => mockDisposable,
49+
onDidChangeWorkspaceFolders: (callback) => mockDisposable,
5050
getConfiguration: () => ({
5151
get: () => null,
5252
}),

src/core/prompts/__tests__/__snapshots__/add-custom-instructions/mcp-server-creation-disabled.snap

Lines changed: 0 additions & 62 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/core/prompts/__tests__/__snapshots__/add-custom-instructions/mcp-server-creation-enabled.snap

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/core/prompts/__tests__/__snapshots__/system-prompt/with-mcp-hub-provided.snap

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/core/prompts/__tests__/add-custom-instructions.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,9 @@ const mockContext = {
168168
} as unknown as vscode.ExtensionContext
169169

170170
// Instead of extending McpHub, create a mock that implements just what we need
171-
const createMockMcpHub = (): McpHub =>
171+
const createMockMcpHub = (withServers: boolean = false): McpHub =>
172172
({
173-
getServers: () => [],
173+
getServers: () => (withServers ? [{ name: "test-server", disabled: false }] : []),
174174
getMcpServersPath: async () => "/mock/mcp/path",
175175
getMcpSettingsFilePath: async () => "/mock/settings/path",
176176
dispose: async () => {},
@@ -236,7 +236,7 @@ describe("addCustomInstructions", () => {
236236
})
237237

238238
it("should include MCP server creation info when enabled", async () => {
239-
const mockMcpHub = createMockMcpHub()
239+
const mockMcpHub = createMockMcpHub(true)
240240

241241
const prompt = await SYSTEM_PROMPT(
242242
mockContext,
@@ -262,7 +262,7 @@ describe("addCustomInstructions", () => {
262262
})
263263

264264
it("should exclude MCP server creation info when disabled", async () => {
265-
const mockMcpHub = createMockMcpHub()
265+
const mockMcpHub = createMockMcpHub(false)
266266

267267
const prompt = await SYSTEM_PROMPT(
268268
mockContext,

src/core/prompts/__tests__/system-prompt.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,9 @@ const mockContext = {
168168
} as unknown as vscode.ExtensionContext
169169

170170
// Instead of extending McpHub, create a mock that implements just what we need
171-
const createMockMcpHub = (): McpHub =>
171+
const createMockMcpHub = (withServers: boolean = false): McpHub =>
172172
({
173-
getServers: () => [],
173+
getServers: () => (withServers ? [{ name: "test-server", disabled: false }] : []),
174174
getMcpServersPath: async () => "/mock/mcp/path",
175175
getMcpSettingsFilePath: async () => "/mock/settings/path",
176176
dispose: async () => {},
@@ -250,7 +250,7 @@ describe("SYSTEM_PROMPT", () => {
250250
})
251251

252252
it("should include MCP server info when mcpHub is provided", async () => {
253-
mockMcpHub = createMockMcpHub()
253+
mockMcpHub = createMockMcpHub(true)
254254

255255
const prompt = await SYSTEM_PROMPT(
256256
mockContext,

0 commit comments

Comments
 (0)