summaryrefslogtreecommitdiff
path: root/packages/core/src/tools/write-file.test.ts
diff options
context:
space:
mode:
authorLeo <[email protected]>2025-06-28 19:02:44 +0100
committerGitHub <[email protected]>2025-06-28 18:02:44 +0000
commit601d9ba36d1c8f6d1e180a0c5cc1d5597906d33a (patch)
tree4f34dfee0c6391a321b5a259957854ae2743cb3f /packages/core/src/tools/write-file.test.ts
parent3518ff766345ba98d90495b46c84439e6fc1a61c (diff)
fix edit retrigger (#2306)
Diffstat (limited to 'packages/core/src/tools/write-file.test.ts')
-rw-r--r--packages/core/src/tools/write-file.test.ts44
1 files changed, 44 insertions, 0 deletions
diff --git a/packages/core/src/tools/write-file.test.ts b/packages/core/src/tools/write-file.test.ts
index 4646f30a..3f9825c6 100644
--- a/packages/core/src/tools/write-file.test.ts
+++ b/packages/core/src/tools/write-file.test.ts
@@ -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`/);
+ });
});
});