summaryrefslogtreecommitdiff
path: root/packages/cli/src/ui/commands/mcpCommand.test.ts
diff options
context:
space:
mode:
authorMo Moadeli <[email protected]>2025-08-04 17:20:49 -0400
committerGitHub <[email protected]>2025-08-04 21:20:49 +0000
commite7b468e122a29341a6e2e2ca67366e6d62014a6d (patch)
treeded9f3730d8d66219a0e6a88711e3211b54ae26e /packages/cli/src/ui/commands/mcpCommand.test.ts
parentdca040908affc6277884514b4c726365359fd10b (diff)
feat(cli): Prevent redundant opening of browser tabs when zero MCP servers are configured (#5367)
Co-authored-by: Allen Hutchison <[email protected]>
Diffstat (limited to 'packages/cli/src/ui/commands/mcpCommand.test.ts')
-rw-r--r--packages/cli/src/ui/commands/mcpCommand.test.ts26
1 files changed, 3 insertions, 23 deletions
diff --git a/packages/cli/src/ui/commands/mcpCommand.test.ts b/packages/cli/src/ui/commands/mcpCommand.test.ts
index afa71ba5..2a6401b3 100644
--- a/packages/cli/src/ui/commands/mcpCommand.test.ts
+++ b/packages/cli/src/ui/commands/mcpCommand.test.ts
@@ -14,15 +14,10 @@ import {
getMCPDiscoveryState,
DiscoveredMCPTool,
} from '@google/gemini-cli-core';
-import open from 'open';
+
import { MessageActionReturn } from './types.js';
import { Type, CallableTool } from '@google/genai';
-// Mock external dependencies
-vi.mock('open', () => ({
- default: vi.fn(),
-}));
-
vi.mock('@google/gemini-cli-core', async (importOriginal) => {
const actual =
await importOriginal<typeof import('@google/gemini-cli-core')>();
@@ -144,30 +139,15 @@ describe('mcpCommand', () => {
mockConfig.getMcpServers = vi.fn().mockReturnValue({});
});
- it('should display a message with a URL when no MCP servers are configured in a sandbox', async () => {
- process.env.SANDBOX = 'sandbox';
-
- const result = await mcpCommand.action!(mockContext, '');
-
- expect(result).toEqual({
- type: 'message',
- messageType: 'info',
- content:
- 'No MCP servers configured. Please open the following URL in your browser to view documentation:\nhttps://goo.gle/gemini-cli-docs-mcp',
- });
- expect(open).not.toHaveBeenCalled();
- });
-
- it('should display a message and open a URL when no MCP servers are configured outside a sandbox', async () => {
+ it('should display a message with a URL when no MCP servers are configured', async () => {
const result = await mcpCommand.action!(mockContext, '');
expect(result).toEqual({
type: 'message',
messageType: 'info',
content:
- 'No MCP servers configured. Opening documentation in your browser: https://goo.gle/gemini-cli-docs-mcp',
+ 'No MCP servers configured. Please view MCP documentation in your browser: https://goo.gle/gemini-cli-docs-mcp or use the cli /docs command',
});
- expect(open).toHaveBeenCalledWith('https://goo.gle/gemini-cli-docs-mcp');
});
});