Skip to content

Commit c792662

Browse files
committed
fix: user message unit test
1 parent a1f4a30 commit c792662

File tree

3 files changed

+18
-21
lines changed

3 files changed

+18
-21
lines changed

src/core/checkpoints/__tests__/checkpoint.test.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,8 @@ describe("Checkpoint functionality", () => {
299299
})
300300

301301
expect(mockCheckpointService.getDiff).toHaveBeenCalledWith({
302-
from: undefined,
303-
to: "commit2",
302+
from: "commit2",
303+
to: undefined,
304304
})
305305
expect(vscode.commands.executeCommand).toHaveBeenCalledWith(
306306
"vscode.changes",
@@ -309,19 +309,18 @@ describe("Checkpoint functionality", () => {
309309
)
310310
})
311311

312-
it("should show diff for checkpoint mode with previous commit", async () => {
312+
it("should show diff for checkpoint mode with next commit", async () => {
313313
const mockChanges = [
314314
{
315315
paths: { absolute: "/test/file.ts", relative: "file.ts" },
316316
content: { before: "old content", after: "new content" },
317317
},
318318
]
319319
mockCheckpointService.getDiff.mockResolvedValue(mockChanges)
320-
320+
mockCheckpointService.getCheckpoints = vi.fn(() => ["commit1", "commit2"])
321321
await checkpointDiff(mockTask, {
322322
ts: 4,
323-
previousCommitHash: "commit1",
324-
commitHash: "commit2",
323+
commitHash: "commit1",
325324
mode: "checkpoint",
326325
})
327326

@@ -331,28 +330,29 @@ describe("Checkpoint functionality", () => {
331330
})
332331
expect(vscode.commands.executeCommand).toHaveBeenCalledWith(
333332
"vscode.changes",
334-
"Changes since previous checkpoint",
333+
"Changes compare with next checkpoint",
335334
expect.any(Array),
336335
)
337336
})
338337

339-
it("should find previous checkpoint automatically in checkpoint mode", async () => {
338+
it("should find next checkpoint automatically in checkpoint mode", async () => {
340339
const mockChanges = [
341340
{
342341
paths: { absolute: "/test/file.ts", relative: "file.ts" },
343342
content: { before: "old content", after: "new content" },
344343
},
345344
]
346345
mockCheckpointService.getDiff.mockResolvedValue(mockChanges)
346+
mockCheckpointService.getCheckpoints = vi.fn(() => ["commit1", "commit2"])
347347

348348
await checkpointDiff(mockTask, {
349349
ts: 4,
350-
commitHash: "commit2",
350+
commitHash: "commit1",
351351
mode: "checkpoint",
352352
})
353353

354354
expect(mockCheckpointService.getDiff).toHaveBeenCalledWith({
355-
from: "commit1", // Should find the previous checkpoint
355+
from: "commit1", // Should find the next checkpoint
356356
to: "commit2",
357357
})
358358
})
@@ -385,21 +385,21 @@ describe("Checkpoint functionality", () => {
385385
})
386386

387387
describe("getCheckpointService", () => {
388-
it("should return existing service if available", () => {
389-
const service = getCheckpointService(mockTask)
388+
it("should return existing service if available", async () => {
389+
const service = await getCheckpointService(mockTask)
390390
expect(service).toBe(mockCheckpointService)
391391
})
392392

393-
it("should return undefined if checkpoints are disabled", () => {
393+
it("should return undefined if checkpoints are disabled", async () => {
394394
mockTask.enableCheckpoints = false
395-
const service = getCheckpointService(mockTask)
395+
const service = await getCheckpointService(mockTask)
396396
expect(service).toBeUndefined()
397397
})
398398

399-
it("should return undefined if service is still initializing", () => {
399+
it("should return undefined if service is still initializing", async () => {
400400
mockTask.checkpointService = undefined
401401
mockTask.checkpointServiceInitializing = true
402-
const service = getCheckpointService(mockTask)
402+
const service = await getCheckpointService(mockTask)
403403
expect(service).toBeUndefined()
404404
})
405405

@@ -425,7 +425,7 @@ describe("Checkpoint functionality", () => {
425425
mockTask.checkpointService = undefined
426426
mockTask.checkpointServiceInitializing = false
427427

428-
const service = getCheckpointService(mockTask)
428+
const service = await getCheckpointService(mockTask)
429429

430430
expect(service).toBeUndefined()
431431
expect(mockTask.enableCheckpoints).toBe(false)

src/core/checkpoints/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ export async function checkpointDiff(task: Task, { ts, previousCommitHash, commi
292292

293293
await vscode.commands.executeCommand(
294294
"vscode.changes",
295-
mode === "full" ? "Changes since task started" : "Changes since previous checkpoint",
295+
mode === "full" ? "Changes since task started" : "Changes compare with next checkpoint",
296296
changes.map((change) => [
297297
vscode.Uri.file(change.paths.absolute),
298298
vscode.Uri.parse(`${DIFF_VIEW_URI_SCHEME}:${change.paths.relative}`).with({

src/core/webview/__tests__/ClineProvider.spec.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,8 +1242,6 @@ describe("ClineProvider", () => {
12421242
mockApiHistory[2],
12431243
])
12441244

1245-
// Verify createTaskWithHistoryItem was called
1246-
expect((provider as any).createTaskWithHistoryItem).toHaveBeenCalledWith({ id: "test-task-id" })
12471245
// createTaskWithHistoryItem is only called when restoring checkpoints or aborting tasks
12481246
expect((provider as any).createTaskWithHistoryItem).not.toHaveBeenCalled()
12491247
})
@@ -3723,7 +3721,6 @@ describe("ClineProvider - Comprehensive Edit/Delete Edge Cases", () => {
37233721

37243722
// Verify successful operation completed
37253723
expect(mockCline.overwriteClineMessages).toHaveBeenCalled()
3726-
expect(provider.createTaskWithHistoryItem).toHaveBeenCalled()
37273724
// createTaskWithHistoryItem is only called when restoring checkpoints or aborting tasks
37283725
expect(vscode.window.showErrorMessage).not.toHaveBeenCalled()
37293726
})

0 commit comments

Comments
 (0)