mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-23 11:34:44 -07:00
feat(plan): refactor ToolConfirmationPayload to union type (#17980)
This commit is contained in:
@@ -193,13 +193,46 @@ describe('ToolModificationHandler', () => {
|
||||
|
||||
const result = await handler.applyInlineModify(
|
||||
mockWaitingToolCall,
|
||||
{ newContent: undefined } as unknown as ToolConfirmationPayload,
|
||||
{} as ToolConfirmationPayload, // no newContent property
|
||||
new AbortController().signal,
|
||||
);
|
||||
|
||||
expect(result).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should process empty string as valid new content', async () => {
|
||||
vi.mocked(
|
||||
modifiableToolModule.isModifiableDeclarativeTool,
|
||||
).mockReturnValue(true);
|
||||
(Diff.createPatch as unknown as Mock).mockReturnValue('mock-diff-empty');
|
||||
|
||||
mockModifyContext.getCurrentContent.mockResolvedValue('old content');
|
||||
mockModifyContext.getFilePath.mockReturnValue('test.txt');
|
||||
mockModifyContext.createUpdatedParams.mockReturnValue({
|
||||
content: '',
|
||||
});
|
||||
|
||||
const mockWaitingToolCall = createMockWaitingToolCall({
|
||||
tool: mockModifiableTool,
|
||||
});
|
||||
|
||||
const result = await handler.applyInlineModify(
|
||||
mockWaitingToolCall,
|
||||
{ newContent: '' },
|
||||
new AbortController().signal,
|
||||
);
|
||||
|
||||
expect(mockModifyContext.createUpdatedParams).toHaveBeenCalledWith(
|
||||
expect.any(String),
|
||||
'',
|
||||
expect.any(Object),
|
||||
);
|
||||
expect(result).toEqual({
|
||||
updatedParams: { content: '' },
|
||||
updatedDiff: 'mock-diff-empty',
|
||||
});
|
||||
});
|
||||
|
||||
it('should calculate diff and return updated params', async () => {
|
||||
vi.mocked(
|
||||
modifiableToolModule.isModifiableDeclarativeTool,
|
||||
|
||||
Reference in New Issue
Block a user