test(core): add regression test for issue for ToolConfirmationResponse (#26194)

This commit is contained in:
Adib234
2026-04-29 13:51:09 -04:00
committed by GitHub
parent 011c0f9bc0
commit 3bc56d0ef5
@@ -357,6 +357,45 @@ describe('confirmation.ts', () => {
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 () => {
const idePromise = Promise.resolve({
status: 'accepted' as const,