fix: update test mocks to handle async getState() calls in Task constructor

- Added missing vscode.workspace.onDidChangeWorkspaceFolders mock
- Added missing vscode.Uri mock
- Added missing vscode.RelativePattern mock
- Fixed mockProvider.getState to return a Promise in Dynamic Strategy Selection tests

These changes fix the failing tests that were caused by the new async code
added to retrieve the openTabsAtEndOfList setting in the Task constructor.
This commit is contained in:
Roo Code 2025-07-21 13:05:45 +00:00
parent 31c9f70afd
commit 94e8d57721

View file

@ -116,6 +116,7 @@ vi.mock("vscode", () => {
stat: vi.fn().mockResolvedValue({ type: 1 }), // FileType.File = 1
},
onDidSaveTextDocument: vi.fn(() => mockDisposable),
onDidChangeWorkspaceFolders: vi.fn(() => mockDisposable),
getConfiguration: vi.fn(() => ({ get: (key: string, defaultValue: any) => defaultValue })),
},
env: {
@ -127,6 +128,25 @@ vi.mock("vscode", () => {
from: vi.fn(),
},
TabInputText: vi.fn(),
Uri: {
file: vi.fn((path: string) => ({
fsPath: path,
scheme: "file",
authority: "",
path,
query: "",
fragment: "",
})),
parse: vi.fn((str: string) => ({
fsPath: str,
scheme: "file",
authority: "",
path: str,
query: "",
fragment: "",
})),
},
RelativePattern: vi.fn().mockImplementation((base, pattern) => ({ base, pattern })),
}
})
@ -1313,7 +1333,7 @@ describe("Cline", () => {
context: {
globalStorageUri: { fsPath: "/test/storage" },
},
getState: vi.fn(),
getState: vi.fn().mockResolvedValue({}),
}
})