@@ -8,29 +8,66 @@ import { render } from '../../test-utils/render.js';
88import { CopyModeWarning } from './CopyModeWarning.js' ;
99import { describe , it , expect , vi , beforeEach } from 'vitest' ;
1010import { useUIState , type UIState } from '../contexts/UIStateContext.js' ;
11+ import { useConfig } from '../contexts/ConfigContext.js' ;
12+ import type { Config } from '@google/gemini-cli-core' ;
1113
1214vi . mock ( '../contexts/UIStateContext.js' ) ;
15+ vi . mock ( '../contexts/ConfigContext.js' ) ;
1316
1417describe ( 'CopyModeWarning' , ( ) => {
1518 const mockUseUIState = vi . mocked ( useUIState ) ;
19+ const mockUseConfig = vi . mocked ( useConfig ) ;
1620
1721 beforeEach ( ( ) => {
1822 vi . clearAllMocks ( ) ;
23+ mockUseConfig . mockReturnValue ( {
24+ getUseAlternateBuffer : ( ) => false ,
25+ } as unknown as Config ) ;
1926 } ) ;
2027
21- it ( 'renders nothing when copy mode is disabled' , async ( ) => {
28+ it ( 'renders nothing when copy mode is disabled and not in alternate buffer ' , async ( ) => {
2229 mockUseUIState . mockReturnValue ( {
2330 copyModeEnabled : false ,
31+ mouseMode : true ,
2432 } as unknown as UIState ) ;
2533 const { lastFrame, unmount } = await render ( < CopyModeWarning /> ) ;
2634 expect ( lastFrame ( { allowEmpty : true } ) ) . toBe ( '' ) ;
2735 unmount ( ) ;
2836 } ) ;
2937
38+ it ( 'renders nothing when copy mode is disabled and mouse mode is disabled but not in alternate buffer' , async ( ) => {
39+ mockUseUIState . mockReturnValue ( {
40+ copyModeEnabled : false ,
41+ mouseMode : false ,
42+ } as unknown as UIState ) ;
43+ mockUseConfig . mockReturnValue ( {
44+ getUseAlternateBuffer : ( ) => false ,
45+ } as unknown as Config ) ;
46+ const { lastFrame, unmount } = await render ( < CopyModeWarning /> ) ;
47+ expect ( lastFrame ( { allowEmpty : true } ) ) . toBe ( '' ) ;
48+ unmount ( ) ;
49+ } ) ;
50+
3051 it ( 'renders warning when copy mode is enabled' , async ( ) => {
3152 mockUseUIState . mockReturnValue ( {
3253 copyModeEnabled : true ,
54+ mouseMode : true ,
55+ } as unknown as UIState ) ;
56+ const { lastFrame, unmount } = await render ( < CopyModeWarning /> ) ;
57+ expect ( lastFrame ( ) ) . toContain ( 'In Copy Mode' ) ;
58+ expect ( lastFrame ( ) ) . toContain ( 'Use Page Up/Down to scroll' ) ;
59+ expect ( lastFrame ( ) ) . toContain ( 'Press Ctrl+S or any other key to exit' ) ;
60+ unmount ( ) ;
61+ } ) ;
62+
63+ it ( 'renders warning when in alternate buffer and mouse mode is disabled' , async ( ) => {
64+ mockUseUIState . mockReturnValue ( {
65+ copyModeEnabled : false ,
66+ mouseMode : false ,
3367 } as unknown as UIState ) ;
68+ mockUseConfig . mockReturnValue ( {
69+ getUseAlternateBuffer : ( ) => true ,
70+ } as unknown as Config ) ;
3471 const { lastFrame, unmount } = await render ( < CopyModeWarning /> ) ;
3572 expect ( lastFrame ( ) ) . toContain ( 'In Copy Mode' ) ;
3673 expect ( lastFrame ( ) ) . toContain ( 'Use Page Up/Down to scroll' ) ;
0 commit comments