Skip to content

Commit 94e8d57

Browse files
committed
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.
1 parent 31c9f70 commit 94e8d57

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/core/task/__tests__/Task.spec.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ vi.mock("vscode", () => {
116116
stat: vi.fn().mockResolvedValue({ type: 1 }), // FileType.File = 1
117117
},
118118
onDidSaveTextDocument: vi.fn(() => mockDisposable),
119+
onDidChangeWorkspaceFolders: vi.fn(() => mockDisposable),
119120
getConfiguration: vi.fn(() => ({ get: (key: string, defaultValue: any) => defaultValue })),
120121
},
121122
env: {
@@ -127,6 +128,25 @@ vi.mock("vscode", () => {
127128
from: vi.fn(),
128129
},
129130
TabInputText: vi.fn(),
131+
Uri: {
132+
file: vi.fn((path: string) => ({
133+
fsPath: path,
134+
scheme: "file",
135+
authority: "",
136+
path,
137+
query: "",
138+
fragment: "",
139+
})),
140+
parse: vi.fn((str: string) => ({
141+
fsPath: str,
142+
scheme: "file",
143+
authority: "",
144+
path: str,
145+
query: "",
146+
fragment: "",
147+
})),
148+
},
149+
RelativePattern: vi.fn().mockImplementation((base, pattern) => ({ base, pattern })),
130150
}
131151
})
132152

@@ -1313,7 +1333,7 @@ describe("Cline", () => {
13131333
context: {
13141334
globalStorageUri: { fsPath: "/test/storage" },
13151335
},
1316-
getState: vi.fn(),
1336+
getState: vi.fn().mockResolvedValue({}),
13171337
}
13181338
})
13191339

0 commit comments

Comments
 (0)