From fbb9d34fd1bfff6ff9720e314a722725df2ec02b Mon Sep 17 00:00:00 2001 From: Brian La Plume Date: Wed, 28 Oct 2026 11:54:16 -0700 Subject: [PATCH] test(config-protection): missing protected target before an existing one --- tests/hooks/config-protection.test.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/hooks/config-protection.test.js b/tests/hooks/config-protection.test.js index 8f766ff3c..6d78bedac 100644 --- a/tests/hooks/config-protection.test.js +++ b/tests/hooks/config-protection.test.js @@ -494,6 +494,19 @@ function runTests() { }); assert.strictEqual(mixed.code, 2, 'mixed ordinary/config batch should be blocked: ' + mixed.stderr); assert.ok(mixed.stderr.includes('BLOCKED: Modifying .eslintrc.json is not allowed.'), mixed.stderr); + + const missingThenExisting = runHook({ + tool_name: 'MultiEdit', + tool_input: { + file_path: path.join(tmpDir, 'missing', 'ruff.toml'), + edits: [ + { old_string: '', new_string: '[lint]' }, + { file_path: eslintrc, old_string: '{}', new_string: '{ }' } + ] + } + }); + assert.strictEqual(missingThenExisting.code, 2, 'existing config after a missing one should be blocked: ' + missingThenExisting.stderr); + assert.ok(missingThenExisting.stderr.includes('BLOCKED: Modifying .eslintrc.json is not allowed.'), missingThenExisting.stderr); }); }) );