From 25f22b98394a74205e4d90d9a71fc46446563499 Mon Sep 17 00:00:00 2001 From: Devvyn <22340871+opticon454@users.noreply.github.com> Date: Wed, 16 Sep 2026 13:23:54 +0800 Subject: [PATCH] test(custom-model): update session-custom-model route test for CLAUDE_CONFIG_DIR isolation Fixes the CI failure on the last two commits: this route test asserted an exact envKeys list for a claude-mode apply that predates the CLAUDE_CONFIG_DIR isolation fix, so it failed on the new CLAUDE_CONFIG_DIR entry it correctly started appending. Updates the expected list and adds assertions for the isolated config dir path and the pre-seeded .claude.json trust-approval file, matching the behavior added in the two prior commits rather than just tolerating it. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01RqZeHrRS6DYcGcGX2p9EwG --- test/routes/session-custom-model.test.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/test/routes/session-custom-model.test.ts b/test/routes/session-custom-model.test.ts index b6d04d98..8797e8ac 100644 --- a/test/routes/session-custom-model.test.ts +++ b/test/routes/session-custom-model.test.ts @@ -8,7 +8,7 @@ import { registerSessionRoutes } from '../../src/web/routes/session-routes.js'; import { createRouteTestHarness } from './_route-test-utils.js'; import { getDataDir } from '../../src/config/instance.js'; import { writeCustomModelHosts, type CustomModelHost } from '../../src/custom-model-hosts.js'; -import { existsSync, statSync } from 'node:fs'; +import { existsSync, readFileSync, statSync } from 'node:fs'; import { join } from 'node:path'; const CLAUDE_ENDPOINT: CustomModelHost = { @@ -54,9 +54,19 @@ describe('POST /api/sessions/:id/custom-model', () => { 'ANTHROPIC_DEFAULT_SONNET_MODEL', 'ANTHROPIC_DEFAULT_HAIKU_MODEL', 'ANTHROPIC_DEFAULT_OPUS_MODEL', + 'CLAUDE_CONFIG_DIR', ]); expect(envOverrides.ANTHROPIC_BASE_URL).toBe('http://192.168.1.50:8080'); expect(envOverrides.ANTHROPIC_API_KEY).toBe('k'); + + // CLAUDE_CONFIG_DIR isolates this session from a stored claude.ai OAuth login, and the + // trust-dialog file it points at is pre-seeded so the injected key doesn't hit an + // interactive "Detected a custom API key" prompt with nobody there to answer it. + const isolatedDir = join(getDataDir(), 'custom-model-configs', 'test-session-1'); + expect(envOverrides.CLAUDE_CONFIG_DIR).toBe(isolatedDir); + expect(next.configDir).toBe(isolatedDir); + const trustFile = JSON.parse(readFileSync(join(isolatedDir, '.claude.json'), 'utf8')); + expect(trustFile.customApiKeyResponses.approved).toEqual(['k']); }); it('clears back to the native default', async () => {