mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-16 16:21:27 -07:00
feat(ui): add visual indicators for hook execution (#15408)
This commit is contained in:
@@ -31,6 +31,8 @@ const mockDebugLogger = vi.hoisted(() => ({
|
||||
// Mock coreEvents
|
||||
const mockCoreEvents = vi.hoisted(() => ({
|
||||
emitFeedback: vi.fn(),
|
||||
emitHookStart: vi.fn(),
|
||||
emitHookEnd: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock('../utils/debugLogger.js', () => ({
|
||||
@@ -158,8 +160,31 @@ describe('HookEventHandler', () => {
|
||||
tool_name: 'EditTool',
|
||||
tool_input: { file: 'test.txt' },
|
||||
}),
|
||||
expect.any(Function),
|
||||
expect.any(Function),
|
||||
);
|
||||
|
||||
// Verify event emission via callbacks
|
||||
const onHookStart = vi.mocked(mockHookRunner.executeHooksParallel).mock
|
||||
.calls[0][3];
|
||||
const onHookEnd = vi.mocked(mockHookRunner.executeHooksParallel).mock
|
||||
.calls[0][4];
|
||||
|
||||
if (onHookStart) onHookStart(mockPlan[0].hookConfig, 0);
|
||||
expect(mockCoreEvents.emitHookStart).toHaveBeenCalledWith({
|
||||
hookName: './test.sh',
|
||||
eventName: HookEventName.BeforeTool,
|
||||
hookIndex: 1,
|
||||
totalHooks: 1,
|
||||
});
|
||||
|
||||
if (onHookEnd) onHookEnd(mockPlan[0].hookConfig, mockResults[0]);
|
||||
expect(mockCoreEvents.emitHookEnd).toHaveBeenCalledWith({
|
||||
hookName: './test.sh',
|
||||
eventName: HookEventName.BeforeTool,
|
||||
success: true,
|
||||
});
|
||||
|
||||
expect(result).toBe(mockAggregated);
|
||||
});
|
||||
|
||||
@@ -294,6 +319,8 @@ describe('HookEventHandler', () => {
|
||||
tool_input: toolInput,
|
||||
tool_response: toolResponse,
|
||||
}),
|
||||
expect.any(Function),
|
||||
expect.any(Function),
|
||||
);
|
||||
|
||||
expect(result).toBe(mockAggregated);
|
||||
@@ -352,6 +379,8 @@ describe('HookEventHandler', () => {
|
||||
expect.objectContaining({
|
||||
prompt,
|
||||
}),
|
||||
expect.any(Function),
|
||||
expect.any(Function),
|
||||
);
|
||||
|
||||
expect(result).toBe(mockAggregated);
|
||||
@@ -415,6 +444,8 @@ describe('HookEventHandler', () => {
|
||||
notification_type: 'ToolPermission',
|
||||
details: { type: 'ToolPermission', title: 'Test Permission' },
|
||||
}),
|
||||
expect.any(Function),
|
||||
expect.any(Function),
|
||||
);
|
||||
|
||||
expect(result).toBe(mockAggregated);
|
||||
@@ -478,6 +509,8 @@ describe('HookEventHandler', () => {
|
||||
expect.objectContaining({
|
||||
source: 'startup',
|
||||
}),
|
||||
expect.any(Function),
|
||||
expect.any(Function),
|
||||
);
|
||||
|
||||
expect(result).toBe(mockAggregated);
|
||||
@@ -548,6 +581,8 @@ describe('HookEventHandler', () => {
|
||||
]),
|
||||
}),
|
||||
}),
|
||||
expect.any(Function),
|
||||
expect.any(Function),
|
||||
);
|
||||
|
||||
expect(result).toBe(mockAggregated);
|
||||
@@ -591,6 +626,8 @@ describe('HookEventHandler', () => {
|
||||
hook_event_name: 'BeforeTool',
|
||||
timestamp: expect.any(String),
|
||||
}),
|
||||
expect.any(Function),
|
||||
expect.any(Function),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user