fix edit retrigger (#2306)

This commit is contained in:
Leo
2025-06-28 19:02:44 +01:00
committed by GitHub
parent 3518ff7663
commit 601d9ba36d
4 changed files with 142 additions and 9 deletions

View File

@@ -567,5 +567,49 @@ describe('WriteFileTool', () => {
expect(fs.existsSync(filePath)).toBe(true);
expect(fs.readFileSync(filePath, 'utf8')).toBe(content);
});
it('should include modification message when proposed content is modified', async () => {
const filePath = path.join(rootDir, 'new_file_modified.txt');
const content = 'New file content modified by user';
mockEnsureCorrectFileContent.mockResolvedValue(content);
const params = {
file_path: filePath,
content,
modified_by_user: true,
};
const result = await tool.execute(params, abortSignal);
expect(result.llmContent).toMatch(/User modified the `content`/);
});
it('should not include modification message when proposed content is not modified', async () => {
const filePath = path.join(rootDir, 'new_file_unmodified.txt');
const content = 'New file content not modified';
mockEnsureCorrectFileContent.mockResolvedValue(content);
const params = {
file_path: filePath,
content,
modified_by_user: false,
};
const result = await tool.execute(params, abortSignal);
expect(result.llmContent).not.toMatch(/User modified the `content`/);
});
it('should not include modification message when modified_by_user is not provided', async () => {
const filePath = path.join(rootDir, 'new_file_unmodified.txt');
const content = 'New file content not modified';
mockEnsureCorrectFileContent.mockResolvedValue(content);
const params = {
file_path: filePath,
content,
};
const result = await tool.execute(params, abortSignal);
expect(result.llmContent).not.toMatch(/User modified the `content`/);
});
});
});