Skip to content

Commit 425c619

Browse files
committed
test(task): cover multi-tool continuation
1 parent 8390727 commit 425c619

1 file changed

Lines changed: 16 additions & 11 deletions

File tree

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

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,7 @@ describe("Cline", () => {
774774
const readFileHandleSpy = vi
775775
.spyOn(readFileTool, "handle")
776776
.mockImplementation(async (_task, block, callbacks) => {
777-
if (!block.partial) callbacks.pushToolResult("File: README.md\nfinished")
777+
if (!block.partial) callbacks.pushToolResult(`File: ${block.params.path}\nfinished`)
778778
})
779779
const say = task.say.bind(task)
780780
const saySpy = vi.spyOn(task, "say").mockImplementation(async (...args) => {
@@ -799,8 +799,10 @@ describe("Cline", () => {
799799
.spyOn(task, "attemptApiRequest")
800800
.mockImplementationOnce(() =>
801801
asyncStreamFrom<ApiStreamChunk>([
802-
{ type: "tool_call_partial", index: 0, id: "call_read", name: "read_file" },
802+
{ type: "tool_call_partial", index: 0, id: "call_read_first", name: "read_file" },
803803
{ type: "tool_call_partial", index: 0, arguments: '{"path":"README.md"}' },
804+
{ type: "tool_call_partial", index: 1, id: "call_read_second", name: "read_file" },
805+
{ type: "tool_call_partial", index: 1, arguments: '{"path":"package.json"}' },
804806
{ type: "text", text: "present this after the tool" },
805807
]),
806808
)
@@ -821,15 +823,18 @@ describe("Cline", () => {
821823
await task.recursivelyMakeClineRequests([{ type: "text", text: "read a file, then continue" }])
822824

823825
expect(attemptApiRequestSpy).toHaveBeenCalledTimes(2)
824-
expect(continuationUserContent).toEqual(
825-
expect.arrayContaining([
826-
expect.objectContaining({
827-
type: "tool_result",
828-
tool_use_id: "call_read",
829-
content: "File: README.md\nfinished",
830-
}),
831-
]),
832-
)
826+
expect(continuationUserContent?.filter((block) => block.type === "tool_result")).toEqual([
827+
expect.objectContaining({
828+
type: "tool_result",
829+
tool_use_id: "call_read_first",
830+
content: "File: README.md\nfinished",
831+
}),
832+
expect.objectContaining({
833+
type: "tool_result",
834+
tool_use_id: "call_read_second",
835+
content: "File: package.json\nfinished",
836+
}),
837+
])
833838
expect(task.userMessageContentReady).toBe(false)
834839
expect(task.presentAssistantMessageLocked).toBe(false)
835840
expect(sawCompleteToolTurn).toBe(true)

0 commit comments

Comments
 (0)