From 296ef20ef7f1cde627cdfbca3a900366a40f38dd Mon Sep 17 00:00:00 2001 From: Stephan Rieche Date: Sat, 27 Dec 2025 13:37:19 +0100 Subject: [PATCH] test: update claude-provider tests for sandbox changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Updated tests to reflect changes made to sandbox mode implementation: 1. Changed permissionMode expectation from 'acceptEdits' to 'default' - ClaudeProvider now uses 'default' permission mode 2. Renamed test "should enable sandbox by default" to "should pass sandbox configuration when provided" - Sandbox is no longer enabled by default in the provider - Provider now forwards sandbox config only when explicitly provided via ExecuteOptions 3. Updated error handling test expectations - Now expects two console.error calls with new format - First call: '[ClaudeProvider] ERROR: executeQuery() error during execution:' - Second call: '[ClaudeProvider] ERROR stack:' with stack trace All 32 tests in claude-provider.test.ts now pass. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 --- .../unit/providers/claude-provider.test.ts | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/apps/server/tests/unit/providers/claude-provider.test.ts b/apps/server/tests/unit/providers/claude-provider.test.ts index 45deb0d1..b06642e9 100644 --- a/apps/server/tests/unit/providers/claude-provider.test.ts +++ b/apps/server/tests/unit/providers/claude-provider.test.ts @@ -73,7 +73,7 @@ describe('claude-provider.ts', () => { maxTurns: 10, cwd: '/test/dir', allowedTools: ['Read', 'Write'], - permissionMode: 'acceptEdits', + permissionMode: 'default', }), }); }); @@ -100,7 +100,7 @@ describe('claude-provider.ts', () => { }); }); - it('should enable sandbox by default', async () => { + it('should pass sandbox configuration when provided', async () => { vi.mocked(sdk.query).mockReturnValue( (async function* () { yield { type: 'text', text: 'test' }; @@ -110,6 +110,10 @@ describe('claude-provider.ts', () => { const generator = provider.executeQuery({ prompt: 'Test', cwd: '/test', + sandbox: { + enabled: true, + autoAllowBashIfSandboxed: true, + }, }); await collectAsyncGenerator(generator); @@ -242,11 +246,21 @@ describe('claude-provider.ts', () => { }); await expect(collectAsyncGenerator(generator)).rejects.toThrow('SDK execution failed'); - expect(consoleErrorSpy).toHaveBeenCalledWith( - '[ClaudeProvider] executeQuery() error during execution:', + + // Should log error message + expect(consoleErrorSpy).toHaveBeenNthCalledWith( + 1, + '[ClaudeProvider] ERROR: executeQuery() error during execution:', testError ); + // Should log stack trace + expect(consoleErrorSpy).toHaveBeenNthCalledWith( + 2, + '[ClaudeProvider] ERROR stack:', + testError.stack + ); + consoleErrorSpy.mockRestore(); }); });