From 31b28ade010711c578d4be58c0dc439badebe000 Mon Sep 17 00:00:00 2001 From: Allen Hutchison Date: Fri, 13 Jun 2025 17:44:14 -0700 Subject: Improvements to web-fetch tool (#1030) --- .../messages/ToolConfirmationMessage.test.tsx | 50 ++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 packages/cli/src/ui/components/messages/ToolConfirmationMessage.test.tsx (limited to 'packages/cli/src/ui/components/messages/ToolConfirmationMessage.test.tsx') diff --git a/packages/cli/src/ui/components/messages/ToolConfirmationMessage.test.tsx b/packages/cli/src/ui/components/messages/ToolConfirmationMessage.test.tsx new file mode 100644 index 00000000..a2d76247 --- /dev/null +++ b/packages/cli/src/ui/components/messages/ToolConfirmationMessage.test.tsx @@ -0,0 +1,50 @@ +/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ + +import { render } from 'ink-testing-library'; +import { describe, it, expect, vi } from 'vitest'; +import { ToolConfirmationMessage } from './ToolConfirmationMessage.js'; +import { ToolCallConfirmationDetails } from '@gemini-cli/core'; + +describe('ToolConfirmationMessage', () => { + it('should not display urls if prompt and url are the same', () => { + const confirmationDetails: ToolCallConfirmationDetails = { + type: 'info', + title: 'Confirm Web Fetch', + prompt: 'https://example.com', + urls: ['https://example.com'], + onConfirm: vi.fn(), + }; + + const { lastFrame } = render( + , + ); + + expect(lastFrame()).not.toContain('URLs to fetch:'); + }); + + it('should display urls if prompt and url are different', () => { + const confirmationDetails: ToolCallConfirmationDetails = { + type: 'info', + title: 'Confirm Web Fetch', + prompt: + 'fetch https://github.com/google/gemini-react/blob/main/README.md', + urls: [ + 'https://raw.githubusercontent.com/google/gemini-react/main/README.md', + ], + onConfirm: vi.fn(), + }; + + const { lastFrame } = render( + , + ); + + expect(lastFrame()).toContain('URLs to fetch:'); + expect(lastFrame()).toContain( + '- https://raw.githubusercontent.com/google/gemini-react/main/README.md', + ); + }); +}); -- cgit v1.2.3