Skip to content

Commit c4ca658

Browse files
committed
test(task): check the saved payload in finalizePartialToolAsk test
1 parent cf9206a commit c4ca658

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5931,7 +5931,15 @@ describe("Cline", () => {
59315931
.mockImplementation(async (message) => {
59325932
updateSnapshot = { ...message }
59335933
})
5934-
const saveSpy = vi.spyOn(getTaskTestAccess(Task.prototype), "saveClineMessages").mockResolvedValue(true)
5934+
// Capture the message as it is when the save runs: this is the payload that
5935+
// reaches disk, so the flags must already be set before the save.
5936+
let savedSnapshot: Record<string, unknown> | undefined
5937+
const saveSpy = vi
5938+
.spyOn(getTaskTestAccess(Task.prototype), "saveClineMessages")
5939+
.mockImplementation(async () => {
5940+
savedSnapshot = structuredClone(task.clineMessages[0])
5941+
return true
5942+
})
59355943

59365944
const task = new Task({
59375945
provider: mockProvider,
@@ -5965,7 +5973,10 @@ describe("Cline", () => {
59655973
// The ask is resolved by the system, not the user: stamp isAnswered so ChatView
59665974
// does not keep Save/Reject armed for a write that already failed.
59675975
expect(task.clineMessages[0].isAnswered).toBe(true)
5968-
expect(saveSpy).toHaveBeenCalled()
5976+
expect(saveSpy).toHaveBeenCalledTimes(1)
5977+
expect(savedSnapshot?.partial).toBe(false)
5978+
expect(savedSnapshot?.progressStatus).toBeUndefined()
5979+
expect(savedSnapshot?.isAnswered).toBe(true)
59695980
expect(updateSpy).toHaveBeenCalledWith(partialToolAsk)
59705981
expect(updateSnapshot?.partial).toBe(false)
59715982
expect(updateSnapshot?.progressStatus).toBeUndefined()

0 commit comments

Comments
 (0)