mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-10-08 03:07:53 +00:00
fix: update tests to match new allowEmpty parameter in overwriteApiConversationHistory
This commit is contained in:
parent
5f68516936
commit
3caf3e9557
2 changed files with 23 additions and 17 deletions
|
|
@ -1239,11 +1239,10 @@ describe("ClineProvider", () => {
|
|||
])
|
||||
|
||||
// Verify only API messages before the deleted message were kept
|
||||
expect(mockCline.overwriteApiConversationHistory).toHaveBeenCalledWith([
|
||||
mockApiHistory[0],
|
||||
mockApiHistory[1],
|
||||
mockApiHistory[2],
|
||||
])
|
||||
expect(mockCline.overwriteApiConversationHistory).toHaveBeenCalledWith(
|
||||
[mockApiHistory[0], mockApiHistory[1], mockApiHistory[2]],
|
||||
true,
|
||||
)
|
||||
|
||||
// createTaskWithHistoryItem is only called when restoring checkpoints or aborting tasks
|
||||
expect((provider as any).createTaskWithHistoryItem).not.toHaveBeenCalled()
|
||||
|
|
@ -1339,7 +1338,7 @@ describe("ClineProvider", () => {
|
|||
expect(mockCline.overwriteClineMessages).toHaveBeenCalledWith([])
|
||||
|
||||
// Verify correct API messages were kept
|
||||
expect(mockCline.overwriteApiConversationHistory).toHaveBeenCalledWith([])
|
||||
expect(mockCline.overwriteApiConversationHistory).toHaveBeenCalledWith([], true)
|
||||
|
||||
// The new flow calls webviewMessageHandler recursively with askResponse
|
||||
// We need to verify the recursive call happened by checking if the handler was called again
|
||||
|
|
@ -3049,7 +3048,7 @@ describe("ClineProvider - Comprehensive Edit/Delete Edge Cases", () => {
|
|||
|
||||
// Verify messages were edited correctly - the ORIGINAL user message and all subsequent messages are removed
|
||||
expect(mockCline.overwriteClineMessages).toHaveBeenCalledWith([mockMessages[0]])
|
||||
expect(mockCline.overwriteApiConversationHistory).toHaveBeenCalledWith([{ ts: 1000 }])
|
||||
expect(mockCline.overwriteApiConversationHistory).toHaveBeenCalledWith([{ ts: 1000 }], true)
|
||||
// Verify submitUserMessage was called with the edited content
|
||||
expect(mockCline.submitUserMessage).toHaveBeenCalledWith("Edited message with preserved images", undefined)
|
||||
})
|
||||
|
|
@ -3675,7 +3674,10 @@ describe("ClineProvider - Comprehensive Edit/Delete Edge Cases", () => {
|
|||
|
||||
// Should handle large payloads without issues - keeps messages before the deleted one
|
||||
expect(mockCline.overwriteClineMessages).toHaveBeenCalledWith([mockMessages[0], mockMessages[1]])
|
||||
expect(mockCline.overwriteApiConversationHistory).toHaveBeenCalledWith([{ ts: 1000 }, { ts: 2000 }])
|
||||
expect(mockCline.overwriteApiConversationHistory).toHaveBeenCalledWith(
|
||||
[{ ts: 1000 }, { ts: 2000 }],
|
||||
true,
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ describe("webviewMessageHandler delete functionality", () => {
|
|||
|
||||
// When message is not found in API history (index is -1),
|
||||
// API history should be truncated from the first API message at/after the deleted timestamp (fallback)
|
||||
expect(getCurrentTaskMock.overwriteApiConversationHistory).toHaveBeenCalledWith([])
|
||||
expect(getCurrentTaskMock.overwriteApiConversationHistory).toHaveBeenCalledWith([], true)
|
||||
})
|
||||
|
||||
it("should handle deletion when exact apiConversationHistoryIndex is found", async () => {
|
||||
|
|
@ -142,9 +142,10 @@ describe("webviewMessageHandler delete functionality", () => {
|
|||
{ ts: 900, say: "user", text: "Previous message" },
|
||||
])
|
||||
|
||||
expect(getCurrentTaskMock.overwriteApiConversationHistory).toHaveBeenCalledWith([
|
||||
{ ts: 900, role: "user", content: { type: "text", text: "Previous message" } },
|
||||
])
|
||||
expect(getCurrentTaskMock.overwriteApiConversationHistory).toHaveBeenCalledWith(
|
||||
[{ ts: 900, role: "user", content: { type: "text", text: "Previous message" } }],
|
||||
true,
|
||||
)
|
||||
})
|
||||
|
||||
it("should handle deletion when message not found in clineMessages", async () => {
|
||||
|
|
@ -204,7 +205,7 @@ describe("webviewMessageHandler delete functionality", () => {
|
|||
expect(getCurrentTaskMock.overwriteClineMessages).toHaveBeenCalledWith([])
|
||||
|
||||
// API history should be truncated from first message at/after deleted timestamp (fallback)
|
||||
expect(getCurrentTaskMock.overwriteApiConversationHistory).toHaveBeenCalledWith([])
|
||||
expect(getCurrentTaskMock.overwriteApiConversationHistory).toHaveBeenCalledWith([], true)
|
||||
})
|
||||
|
||||
it("should preserve messages before the deleted one", async () => {
|
||||
|
|
@ -236,10 +237,13 @@ describe("webviewMessageHandler delete functionality", () => {
|
|||
])
|
||||
|
||||
// API history should be truncated at the exact index
|
||||
expect(getCurrentTaskMock.overwriteApiConversationHistory).toHaveBeenCalledWith([
|
||||
{ ts: 1000, role: "user", content: { type: "text", text: "First message" } },
|
||||
{ ts: 1500, role: "assistant", content: { type: "text", text: "First response" } },
|
||||
])
|
||||
expect(getCurrentTaskMock.overwriteApiConversationHistory).toHaveBeenCalledWith(
|
||||
[
|
||||
{ ts: 1000, role: "user", content: { type: "text", text: "First message" } },
|
||||
{ ts: 1500, role: "assistant", content: { type: "text", text: "First response" } },
|
||||
],
|
||||
true,
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue