From 94e8d577216800e90a0710996af8f0ea6ef35b69 Mon Sep 17 00:00:00 2001 From: Roo Code Date: Mon, 21 Jul 2025 13:05:45 +0000 Subject: [PATCH] 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. --- src/core/task/__tests__/Task.spec.ts | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/core/task/__tests__/Task.spec.ts b/src/core/task/__tests__/Task.spec.ts index 9aa5a8d7a8..6b5de1436a 100644 --- a/src/core/task/__tests__/Task.spec.ts +++ b/src/core/task/__tests__/Task.spec.ts @@ -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({}), } })