Revert "chore(cleanup): Consolidate MockTool definitions (#7228)" (#7283)

This commit is contained in:
Gal Zahavi
2025-08-27 21:06:50 -07:00
committed by GitHub
parent bfdddcbd99
commit 5f16541c38
6 changed files with 236 additions and 194 deletions
+38 -29
View File
@@ -32,8 +32,8 @@ import {
assertUniqueFinalEventIsLast,
assertTaskCreationAndWorkingStatus,
createStreamMessageRequest,
MockTool,
} from './testing_utils.js';
import { MockTool } from '@google/gemini-cli-core';
const mockToolConfirmationFn = async () =>
({}) as unknown as ToolCallConfirmationDetails;
@@ -189,10 +189,13 @@ describe('E2E Tests', () => {
yield* [];
});
const mockTool = new MockTool({
name: 'test-tool',
shouldConfirmExecute: vi.fn(mockToolConfirmationFn),
});
const mockTool = new MockTool(
'test-tool',
'Test Tool',
true,
false,
mockToolConfirmationFn,
);
getToolRegistrySpy.mockReturnValue({
getAllTools: vi.fn().mockReturnValue([mockTool]),
@@ -281,16 +284,20 @@ describe('E2E Tests', () => {
yield* [];
});
const mockTool1 = new MockTool({
name: 'test-tool-1',
displayName: 'Test Tool 1',
shouldConfirmExecute: vi.fn(mockToolConfirmationFn),
});
const mockTool2 = new MockTool({
name: 'test-tool-2',
displayName: 'Test Tool 2',
shouldConfirmExecute: vi.fn(mockToolConfirmationFn),
});
const mockTool1 = new MockTool(
'test-tool-1',
'Test Tool 1',
false,
false,
mockToolConfirmationFn,
);
const mockTool2 = new MockTool(
'test-tool-2',
'Test Tool 2',
false,
false,
mockToolConfirmationFn,
);
getToolRegistrySpy.mockReturnValue({
getAllTools: vi.fn().mockReturnValue([mockTool1, mockTool2]),
@@ -397,13 +404,13 @@ describe('E2E Tests', () => {
yield* [{ type: 'content', value: 'Tool executed successfully.' }];
});
const mockTool = new MockTool({
name: 'test-tool-no-approval',
displayName: 'Test Tool No Approval',
execute: vi.fn().mockResolvedValue({
llmContent: 'Tool executed successfully.',
returnDisplay: 'Tool executed successfully.',
}),
const mockTool = new MockTool(
'test-tool-no-approval',
'Test Tool No Approval',
);
mockTool.execute.mockResolvedValue({
llmContent: 'Tool executed successfully.',
returnDisplay: 'Tool executed successfully.',
});
getToolRegistrySpy.mockReturnValue({
@@ -528,13 +535,15 @@ describe('E2E Tests', () => {
// Set approval mode to yolo
getApprovalModeSpy.mockReturnValue(ApprovalMode.YOLO);
const mockTool = new MockTool({
name: 'test-tool-yolo',
displayName: 'Test Tool YOLO',
execute: vi.fn().mockResolvedValue({
llmContent: 'Tool executed successfully.',
returnDisplay: 'Tool executed successfully.',
}),
const mockTool = new MockTool(
'test-tool-yolo',
'Test Tool YOLO',
false,
false,
);
mockTool.execute.mockResolvedValue({
llmContent: 'Tool executed successfully.',
returnDisplay: 'Tool executed successfully.',
});
getToolRegistrySpy.mockReturnValue({