mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-07-15 20:40:35 -07:00
feat: prompt users to run /terminal-setup with yes/no (#16235)
Co-authored-by: Vedant Mahajan <Vedant.04.mahajan@gmail.com>
This commit is contained in:
@@ -5,7 +5,12 @@
|
||||
*/
|
||||
|
||||
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
||||
import { terminalSetup, VSCODE_SHIFT_ENTER_SEQUENCE } from './terminalSetup.js';
|
||||
import {
|
||||
terminalSetup,
|
||||
VSCODE_SHIFT_ENTER_SEQUENCE,
|
||||
shouldPromptForTerminalSetup,
|
||||
} from './terminalSetup.js';
|
||||
import { terminalCapabilityManager } from './terminalCapabilityManager.js';
|
||||
|
||||
// Mock dependencies
|
||||
const mocks = vi.hoisted(() => ({
|
||||
@@ -195,4 +200,51 @@ describe('terminalSetup', () => {
|
||||
expect(mocks.writeFile).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('shouldPromptForTerminalSetup', () => {
|
||||
it('should return false when kitty protocol is already enabled', async () => {
|
||||
vi.mocked(
|
||||
terminalCapabilityManager.isKittyProtocolEnabled,
|
||||
).mockReturnValue(true);
|
||||
|
||||
const result = await shouldPromptForTerminalSetup();
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
|
||||
it('should return false when both Shift+Enter and Ctrl+Enter bindings already exist', async () => {
|
||||
vi.mocked(
|
||||
terminalCapabilityManager.isKittyProtocolEnabled,
|
||||
).mockReturnValue(false);
|
||||
process.env['TERM_PROGRAM'] = 'vscode';
|
||||
|
||||
const existingBindings = [
|
||||
{
|
||||
key: 'shift+enter',
|
||||
command: 'workbench.action.terminal.sendSequence',
|
||||
args: { text: VSCODE_SHIFT_ENTER_SEQUENCE },
|
||||
},
|
||||
{
|
||||
key: 'ctrl+enter',
|
||||
command: 'workbench.action.terminal.sendSequence',
|
||||
args: { text: VSCODE_SHIFT_ENTER_SEQUENCE },
|
||||
},
|
||||
];
|
||||
mocks.readFile.mockResolvedValue(JSON.stringify(existingBindings));
|
||||
|
||||
const result = await shouldPromptForTerminalSetup();
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
|
||||
it('should return true when keybindings file does not exist', async () => {
|
||||
vi.mocked(
|
||||
terminalCapabilityManager.isKittyProtocolEnabled,
|
||||
).mockReturnValue(false);
|
||||
process.env['TERM_PROGRAM'] = 'vscode';
|
||||
|
||||
mocks.readFile.mockRejectedValue(new Error('ENOENT'));
|
||||
|
||||
const result = await shouldPromptForTerminalSetup();
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user