Skip to content

Commit 0efff1d

Browse files
committed
refactor: mock missing properties required by codebase indexing manager
1 parent b5b0603 commit 0efff1d

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

src/core/prompts/__tests__/system.test.ts

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,28 @@ jest.mock("vscode", () => ({
8585
env: {
8686
language: "en",
8787
},
88+
workspace: {
89+
workspaceFolders: [
90+
{
91+
uri: {
92+
fsPath: "/test/path",
93+
},
94+
},
95+
],
96+
getWorkspaceFolder: jest.fn().mockReturnValue({
97+
uri: {
98+
fsPath: "/test/path",
99+
},
100+
}),
101+
},
102+
window: {
103+
activeTextEditor: undefined,
104+
},
105+
EventEmitter: jest.fn().mockImplementation(() => ({
106+
event: jest.fn(),
107+
fire: jest.fn(),
108+
dispose: jest.fn(),
109+
})),
88110
}))
89111

90112
jest.mock("../../../utils/shell", () => ({
@@ -343,6 +365,29 @@ describe("SYSTEM_PROMPT", () => {
343365
// Mock vscode.env.language
344366
const vscode = jest.requireMock("vscode")
345367
vscode.env = { language: "es" }
368+
// Ensure workspace mock is maintained
369+
vscode.workspace = {
370+
workspaceFolders: [
371+
{
372+
uri: {
373+
fsPath: "/test/path",
374+
},
375+
},
376+
],
377+
getWorkspaceFolder: jest.fn().mockReturnValue({
378+
uri: {
379+
fsPath: "/test/path",
380+
},
381+
}),
382+
}
383+
vscode.window = {
384+
activeTextEditor: undefined,
385+
}
386+
vscode.EventEmitter = jest.fn().mockImplementation(() => ({
387+
event: jest.fn(),
388+
fire: jest.fn(),
389+
dispose: jest.fn(),
390+
}))
346391

347392
const prompt = await SYSTEM_PROMPT(
348393
mockContext,
@@ -365,6 +410,28 @@ describe("SYSTEM_PROMPT", () => {
365410

366411
// Reset mock
367412
vscode.env = { language: "en" }
413+
vscode.workspace = {
414+
workspaceFolders: [
415+
{
416+
uri: {
417+
fsPath: "/test/path",
418+
},
419+
},
420+
],
421+
getWorkspaceFolder: jest.fn().mockReturnValue({
422+
uri: {
423+
fsPath: "/test/path",
424+
},
425+
}),
426+
}
427+
vscode.window = {
428+
activeTextEditor: undefined,
429+
}
430+
vscode.EventEmitter = jest.fn().mockImplementation(() => ({
431+
event: jest.fn(),
432+
fire: jest.fn(),
433+
dispose: jest.fn(),
434+
}))
368435
})
369436

370437
it("should include custom mode role definition at top and instructions at bottom", async () => {

0 commit comments

Comments
 (0)