@@ -51,6 +51,7 @@ vi.mock("react-i18next", () => ({
5151 "chat:task.sharingDisabledByOrganization" : "Sharing disabled by organization" ,
5252 "chat:task.openApiHistory" : "Open API History" ,
5353 "chat:task.openUiHistory" : "Open UI History" ,
54+ "chat:task.viewDiff" : "View all changes since task started" ,
5455 "cloud:cloudBenefitsTitle" : "Connect to Roo Code Cloud" ,
5556 "cloud:cloudBenefitHistory" : "Access your task history from anywhere" ,
5657 "cloud:cloudBenefitSharing" : "Share tasks with your team" ,
@@ -525,4 +526,75 @@ describe("TaskActions", () => {
525526 } )
526527 } )
527528 } )
529+
530+ describe ( "View Diff Button" , ( ) => {
531+ it ( "renders view diff button when checkpoints are enabled and checkpoint exists" , ( ) => {
532+ mockUseExtensionState . mockReturnValue ( {
533+ sharingEnabled : true ,
534+ cloudIsAuthenticated : true ,
535+ cloudUserInfo : { organizationName : "Test Organization" } ,
536+ enableCheckpoints : true ,
537+ clineMessages : [ { say : "checkpoint_saved" , text : "abc123" , ts : 1000 } ] ,
538+ } as any )
539+
540+ render ( < TaskActions item = { mockItem } buttonsDisabled = { false } /> )
541+
542+ const viewDiffButton = screen . getByLabelText ( "View all changes since task started" )
543+ expect ( viewDiffButton ) . toBeInTheDocument ( )
544+ } )
545+
546+ it ( "does not render view diff button when checkpoints are disabled" , ( ) => {
547+ mockUseExtensionState . mockReturnValue ( {
548+ sharingEnabled : true ,
549+ cloudIsAuthenticated : true ,
550+ cloudUserInfo : { organizationName : "Test Organization" } ,
551+ enableCheckpoints : false ,
552+ clineMessages : [ { say : "checkpoint_saved" , text : "abc123" , ts : 1000 } ] ,
553+ } as any )
554+
555+ render ( < TaskActions item = { mockItem } buttonsDisabled = { false } /> )
556+
557+ const viewDiffButton = screen . queryByLabelText ( "View all changes since task started" )
558+ expect ( viewDiffButton ) . toBeNull ( )
559+ } )
560+
561+ it ( "does not render view diff button when no checkpoints exist" , ( ) => {
562+ mockUseExtensionState . mockReturnValue ( {
563+ sharingEnabled : true ,
564+ cloudIsAuthenticated : true ,
565+ cloudUserInfo : { organizationName : "Test Organization" } ,
566+ enableCheckpoints : true ,
567+ clineMessages : [ ] ,
568+ } as any )
569+
570+ render ( < TaskActions item = { mockItem } buttonsDisabled = { false } /> )
571+
572+ const viewDiffButton = screen . queryByLabelText ( "View all changes since task started" )
573+ expect ( viewDiffButton ) . toBeNull ( )
574+ } )
575+
576+ it ( "sends checkpointDiff message with full mode when view diff button is clicked" , ( ) => {
577+ mockUseExtensionState . mockReturnValue ( {
578+ sharingEnabled : true ,
579+ cloudIsAuthenticated : true ,
580+ cloudUserInfo : { organizationName : "Test Organization" } ,
581+ enableCheckpoints : true ,
582+ clineMessages : [
583+ { say : "checkpoint_saved" , text : "first-hash" , ts : 1000 } ,
584+ { say : "text" , text : "some message" , ts : 2000 } ,
585+ { say : "checkpoint_saved" , text : "last-hash" , ts : 3000 } ,
586+ ] ,
587+ } as any )
588+
589+ render ( < TaskActions item = { mockItem } buttonsDisabled = { false } /> )
590+
591+ const viewDiffButton = screen . getByLabelText ( "View all changes since task started" )
592+ fireEvent . click ( viewDiffButton )
593+
594+ expect ( mockPostMessage ) . toHaveBeenCalledWith ( {
595+ type : "checkpointDiff" ,
596+ payload : { commitHash : "last-hash" , mode : "full" } ,
597+ } )
598+ } )
599+ } )
528600} )
0 commit comments