mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-12 21:03:05 -07:00
test(core): add regression test for issue for ToolConfirmationResponse (#26194)
This commit is contained in:
@@ -357,6 +357,45 @@ describe('confirmation.ts', () => {
|
|||||||
expect(mockState.updateArgs).toHaveBeenCalled();
|
expect(mockState.updateArgs).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should pass payload to onConfirm callback', async () => {
|
||||||
|
const details = {
|
||||||
|
type: 'ask_user' as const,
|
||||||
|
questions: [],
|
||||||
|
title: 'Title',
|
||||||
|
onConfirm: vi.fn(),
|
||||||
|
};
|
||||||
|
invocationMock.shouldConfirmExecute.mockResolvedValue(details);
|
||||||
|
|
||||||
|
const listenerPromise = waitForListener(
|
||||||
|
MessageBusType.TOOL_CONFIRMATION_RESPONSE,
|
||||||
|
);
|
||||||
|
const promise = resolveConfirmation(toolCall, signal, {
|
||||||
|
config: mockConfig,
|
||||||
|
messageBus: mockMessageBus,
|
||||||
|
state: mockState,
|
||||||
|
modifier: mockModifier,
|
||||||
|
getPreferredEditor,
|
||||||
|
schedulerId: ROOT_SCHEDULER_ID,
|
||||||
|
});
|
||||||
|
|
||||||
|
await listenerPromise;
|
||||||
|
|
||||||
|
const payload = { answers: { '0': 'user choice' } };
|
||||||
|
emitResponse({
|
||||||
|
type: MessageBusType.TOOL_CONFIRMATION_RESPONSE,
|
||||||
|
correlationId: '123e4567-e89b-12d3-a456-426614174000',
|
||||||
|
confirmed: true,
|
||||||
|
outcome: ToolConfirmationOutcome.ProceedOnce,
|
||||||
|
payload,
|
||||||
|
});
|
||||||
|
|
||||||
|
await promise;
|
||||||
|
expect(details.onConfirm).toHaveBeenCalledWith(
|
||||||
|
ToolConfirmationOutcome.ProceedOnce,
|
||||||
|
payload,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
it('should resolve immediately if IDE confirmation resolves first', async () => {
|
it('should resolve immediately if IDE confirmation resolves first', async () => {
|
||||||
const idePromise = Promise.resolve({
|
const idePromise = Promise.resolve({
|
||||||
status: 'accepted' as const,
|
status: 'accepted' as const,
|
||||||
|
|||||||
Reference in New Issue
Block a user