@@ -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 )
0 commit comments