Skip to content

Commit fcd1ec7

Browse files
committed
fix: edit tests
1 parent 52bf0a8 commit fcd1ec7

File tree

2 files changed

+8
-35
lines changed

2 files changed

+8
-35
lines changed

gui/src/pages/gui/chat-tests/EditToolScenarios.test.tsx

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
import { BuiltInToolNames } from "core/tools/builtIn";
2+
import { generateToolCallButtonTestId } from "../../../components/mainInput/Lump/LumpToolbar/PendingToolCallToolbar";
23
import {
34
addAndSelectMockLlm,
45
triggerConfigUpdate,
56
} from "../../../util/test/config";
67
import { renderWithProviders } from "../../../util/test/render";
78
import { Chat } from "../Chat";
8-
import { generateToolCallButtonTestId } from "../../../components/mainInput/Lump/LumpToolbar/PendingToolCallToolbar";
99

1010
import { waitFor } from "@testing-library/dom";
1111
import { act } from "@testing-library/react";
1212
import { ChatMessage } from "core";
13-
import {
14-
setToolPolicy,
15-
toggleToolSetting,
16-
} from "../../../redux/slices/uiSlice";
13+
import { setToolPolicy } from "../../../redux/slices/uiSlice";
1714
import {
1815
getElementByTestId,
1916
getElementByText,
@@ -63,6 +60,7 @@ test(
6360

6461
ideMessenger.responses["getWorkspaceDirs"] = [EDIT_WORKSPACE_DIR];
6562
const messengerPostSpy = vi.spyOn(ideMessenger, "post");
63+
const messengerRequestSpy = vi.spyOn(ideMessenger, "request");
6664

6765
addAndSelectMockLlm(store, ideMessenger);
6866

@@ -92,7 +90,7 @@ test(
9290

9391
// Tool call, check that applyToFile was called for edit
9492
await waitFor(() => {
95-
expect(messengerPostSpy).toHaveBeenCalledWith("applyToFile", {
93+
expect(messengerRequestSpy).toHaveBeenCalledWith("applyToFile", {
9694
streamId: expect.any(String),
9795
filepath: EDIT_FILE_URI,
9896
text: EDIT_CHANGES,
@@ -101,7 +99,7 @@ test(
10199
});
102100

103101
// Extract stream ID and initiate mock streaming
104-
const streamId = messengerPostSpy.mock.calls.find(
102+
const streamId = messengerRequestSpy.mock.calls.find(
105103
(call) => call[0] === "applyToFile",
106104
)?.[1]?.streamId;
107105
expect(streamId).toBeDefined();
@@ -172,6 +170,7 @@ test("Edit run with no policy and yolo mode", { timeout: 15000 }, async () => {
172170

173171
ideMessenger.responses["getWorkspaceDirs"] = [EDIT_WORKSPACE_DIR];
174172
const messengerPostSpy = vi.spyOn(ideMessenger, "post");
173+
const messengerRequestSpy = vi.spyOn(ideMessenger, "request");
175174

176175
addAndSelectMockLlm(store, ideMessenger);
177176

@@ -219,7 +218,7 @@ test("Edit run with no policy and yolo mode", { timeout: 15000 }, async () => {
219218
);
220219
// Tool call, check that applyToFile was called for edit
221220
await waitFor(() => {
222-
expect(messengerPostSpy).toHaveBeenCalledWith("applyToFile", {
221+
expect(messengerRequestSpy).toHaveBeenCalledWith("applyToFile", {
223222
streamId: expect.any(String),
224223
filepath: EDIT_FILE_URI,
225224
text: EDIT_CHANGES,
@@ -228,7 +227,7 @@ test("Edit run with no policy and yolo mode", { timeout: 15000 }, async () => {
228227
});
229228

230229
// Extract stream ID and initiate mock streaming
231-
const streamId = messengerPostSpy.mock.calls.find(
230+
const streamId = messengerRequestSpy.mock.calls.find(
232231
(call) => call[0] === "applyToFile",
233232
)?.[1]?.streamId;
234233
expect(streamId).toBeDefined();

gui/src/util/clientTools/searchReplaceImpl.test.ts

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -581,32 +581,6 @@ keep this too`;
581581
),
582582
).rejects.toThrow("Failed to apply search and replace: File read error");
583583
});
584-
585-
it("should handle applyToFile errors", async () => {
586-
mockResolveRelativePathInDir.mockResolvedValue("/resolved/path/test.txt");
587-
mockParseAllSearchReplaceBlocks.mockReturnValue([
588-
{
589-
isComplete: true,
590-
searchContent: "content",
591-
replaceContent: "replacement",
592-
},
593-
]);
594-
mockIdeMessenger.ide.readFile.mockResolvedValue("content");
595-
mockFindSearchMatch.mockReturnValue({
596-
startIndex: 0,
597-
endIndex: 7,
598-
strategyName: "exactMatch",
599-
});
600-
mockIdeMessenger.request.mockRejectedValue(new Error("Apply failed"));
601-
602-
await expect(
603-
searchReplaceToolImpl(
604-
{ filepath: "test.txt", diffs: ["mock diff content"] },
605-
"tool-call-id",
606-
mockExtras,
607-
),
608-
).rejects.toThrow("Failed to apply search and replace: Apply failed");
609-
});
610584
});
611585

612586
describe("edge cases", () => {

0 commit comments

Comments
 (0)