diff options
| author | christine betts <[email protected]> | 2025-07-30 21:26:31 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-07-30 21:26:31 +0000 |
| commit | 7bc876654254d9a11d66135735ad10f1066ad213 (patch) | |
| tree | 3b21e328199f8631c0d865fdf041103c18bd261e /packages/cli/src/config/config.test.ts | |
| parent | c1fe6889569610878c45216556fb99424b5bcba4 (diff) | |
Introduce IDE mode installer (#4877)
Diffstat (limited to 'packages/cli/src/config/config.test.ts')
| -rw-r--r-- | packages/cli/src/config/config.test.ts | 81 |
1 files changed, 8 insertions, 73 deletions
diff --git a/packages/cli/src/config/config.test.ts b/packages/cli/src/config/config.test.ts index 7f47660d..1dd09f4b 100644 --- a/packages/cli/src/config/config.test.ts +++ b/packages/cli/src/config/config.test.ts @@ -35,11 +35,13 @@ vi.mock('@google/gemini-cli-core', async () => { ); return { ...actualServer, - IdeClient: vi.fn().mockImplementation(() => ({ - getConnectionStatus: vi.fn(), - initialize: vi.fn(), - shutdown: vi.fn(), - })), + IdeClient: { + getInstance: vi.fn().mockReturnValue({ + getConnectionStatus: vi.fn(), + initialize: vi.fn(), + shutdown: vi.fn(), + }), + }, loadEnvironment: vi.fn(), loadServerHierarchicalMemory: vi.fn( (cwd, debug, fileService, extensionPaths, _maxDirs) => @@ -922,8 +924,6 @@ describe('loadCliConfig ideMode', () => { vi.resetAllMocks(); vi.mocked(os.homedir).mockReturnValue('/mock/home/user'); process.env.GEMINI_API_KEY = 'test-api-key'; - // Explicitly delete TERM_PROGRAM and SANDBOX before each test - delete process.env.TERM_PROGRAM; delete process.env.SANDBOX; delete process.env.GEMINI_CLI_IDE_SERVER_PORT; }); @@ -942,72 +942,7 @@ describe('loadCliConfig ideMode', () => { expect(config.getIdeMode()).toBe(false); }); - it('should be false if --ide-mode is true but TERM_PROGRAM is not vscode', async () => { - process.argv = ['node', 'script.js', '--ide-mode']; - const settings: Settings = {}; - const argv = await parseArguments(); - const config = await loadCliConfig(settings, [], 'test-session', argv); - expect(config.getIdeMode()).toBe(false); - }); - - it('should be false if settings.ideMode is true but TERM_PROGRAM is not vscode', async () => { - process.argv = ['node', 'script.js']; - const argv = await parseArguments(); - const settings: Settings = { ideMode: true }; - const config = await loadCliConfig(settings, [], 'test-session', argv); - expect(config.getIdeMode()).toBe(false); - }); - - it('should be true when --ide-mode is set and TERM_PROGRAM is vscode', async () => { - process.argv = ['node', 'script.js', '--ide-mode']; - const argv = await parseArguments(); - process.env.TERM_PROGRAM = 'vscode'; - process.env.GEMINI_CLI_IDE_SERVER_PORT = '3000'; - const settings: Settings = {}; - const config = await loadCliConfig(settings, [], 'test-session', argv); - expect(config.getIdeMode()).toBe(true); - }); - - it('should be true when settings.ideMode is true and TERM_PROGRAM is vscode', async () => { - process.argv = ['node', 'script.js']; - const argv = await parseArguments(); - process.env.TERM_PROGRAM = 'vscode'; - process.env.GEMINI_CLI_IDE_SERVER_PORT = '3000'; - const settings: Settings = { ideMode: true }; - const config = await loadCliConfig(settings, [], 'test-session', argv); - expect(config.getIdeMode()).toBe(true); - }); - - it('should prioritize --ide-mode (true) over settings (false) when TERM_PROGRAM is vscode', async () => { - process.argv = ['node', 'script.js', '--ide-mode']; - const argv = await parseArguments(); - process.env.TERM_PROGRAM = 'vscode'; - process.env.GEMINI_CLI_IDE_SERVER_PORT = '3000'; - const settings: Settings = { ideMode: false }; - const config = await loadCliConfig(settings, [], 'test-session', argv); - expect(config.getIdeMode()).toBe(true); - }); - - it('should prioritize --no-ide-mode (false) over settings (true) even when TERM_PROGRAM is vscode', async () => { - process.argv = ['node', 'script.js', '--no-ide-mode']; - const argv = await parseArguments(); - process.env.TERM_PROGRAM = 'vscode'; - const settings: Settings = { ideMode: true }; - const config = await loadCliConfig(settings, [], 'test-session', argv); - expect(config.getIdeMode()).toBe(false); - }); - - it('should be false when --ide-mode is true, TERM_PROGRAM is vscode, but SANDBOX is set', async () => { - process.argv = ['node', 'script.js', '--ide-mode']; - const argv = await parseArguments(); - process.env.TERM_PROGRAM = 'vscode'; - process.env.SANDBOX = 'true'; - const settings: Settings = {}; - const config = await loadCliConfig(settings, [], 'test-session', argv); - expect(config.getIdeMode()).toBe(false); - }); - - it('should be false when settings.ideMode is true, TERM_PROGRAM is vscode, but SANDBOX is set', async () => { + it('should be false when settings.ideMode is true, but SANDBOX is set', async () => { process.argv = ['node', 'script.js']; const argv = await parseArguments(); process.env.TERM_PROGRAM = 'vscode'; |
