Skip to content

Commit b7e3202

Browse files
committed
fix: mock applyDiffTool module and ensure legacy tool resolves successfully in tests
1 parent 5eb1ebe commit b7e3202

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/core/tools/__tests__/applyDiffTool.experiment.spec.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
import { describe, it, expect, vi, beforeEach } from "vitest"
22
import { applyDiffTool } from "../multiApplyDiffTool"
3-
import { applyDiffToolLegacy } from "../applyDiffTool"
4-
import { Task } from "../../task/Task"
53
import { EXPERIMENT_IDS, experiments } from "../../../shared/experiments"
64

7-
vi.mock("../applyDiffToolLegacy")
5+
// Mock the applyDiffTool module
6+
vi.mock("../applyDiffTool", () => ({
7+
applyDiffToolLegacy: vi.fn(),
8+
}))
9+
10+
// Import after mocking to get the mocked version
11+
import { applyDiffToolLegacy } from "../applyDiffTool"
812

913
describe("applyDiffTool experiment routing", () => {
1014
let mockCline: any
@@ -34,6 +38,9 @@ describe("applyDiffTool experiment routing", () => {
3438
diffViewProvider: {
3539
reset: vi.fn(),
3640
},
41+
api: {
42+
getModel: vi.fn().mockReturnValue({ id: "test-model" }),
43+
},
3744
} as any
3845

3946
mockBlock = {
@@ -57,6 +64,9 @@ describe("applyDiffTool experiment routing", () => {
5764
},
5865
})
5966

67+
// Mock the legacy tool to resolve successfully
68+
;(applyDiffToolLegacy as any).mockResolvedValue(undefined)
69+
6070
await applyDiffTool(
6171
mockCline,
6272
mockBlock,
@@ -79,6 +89,9 @@ describe("applyDiffTool experiment routing", () => {
7989
it("should use legacy tool when experiments are not defined", async () => {
8090
mockProvider.getState.mockResolvedValue({})
8191

92+
// Mock the legacy tool to resolve successfully
93+
;(applyDiffToolLegacy as any).mockResolvedValue(undefined)
94+
8295
await applyDiffTool(
8396
mockCline,
8497
mockBlock,

0 commit comments

Comments
 (0)