diff --git a/src/commands/local-vault/__tests__/launchLocalVault.test.ts b/src/commands/local-vault/__tests__/launchLocalVault.test.ts index 5d89b2f12..5f9482678 100644 --- a/src/commands/local-vault/__tests__/launchLocalVault.test.ts +++ b/src/commands/local-vault/__tests__/launchLocalVault.test.ts @@ -7,9 +7,30 @@ import { logMock } from '../../../../tests/mocks/log.js' mock.module('src/utils/log.ts', logMock) mock.module('bun:bundle', () => ({ feature: () => false })) -// No keychain mock here — the real store falls back to encrypted file when -// @napi-rs/keyring is not installed (which it is not in this environment). -// This exercises the full file-fallback path without cross-test module pollution. +// Re-register ../keychain.js to override pollution from store.test.ts (which +// mocks keychain as always-throwing) and keychain.test.ts (which mocks it with +// an in-memory MockEntry). Force KeychainUnavailableError so the store always +// uses the encrypted-file fallback path. +class KeychainUnavailableError extends Error { + override name = 'KeychainUnavailableError' +} + +const keychainUnavailable = async (): Promise => { + throw new KeychainUnavailableError('test: keychain mocked as unavailable') +} + +mock.module('../../../services/localVault/keychain.js', () => ({ + KeychainUnavailableError, + tryKeychain: { + set: keychainUnavailable, + get: keychainUnavailable, + delete: keychainUnavailable, + list: keychainUnavailable, + _addToIndex: keychainUnavailable, + _removeFromIndex: keychainUnavailable, + }, + _resetKeychainModuleCache: () => {}, +})) let callLocalVault: typeof import('../launchLocalVault.js').callLocalVault diff --git a/src/services/api/openai/__tests__/thinking.test.ts b/src/services/api/openai/__tests__/thinking.test.ts index a18dfb5d0..a1f477a18 100644 --- a/src/services/api/openai/__tests__/thinking.test.ts +++ b/src/services/api/openai/__tests__/thinking.test.ts @@ -1,9 +1,27 @@ -import { describe, expect, test, beforeEach, afterEach } from 'bun:test' +import { describe, expect, test, beforeEach, afterEach, mock } from 'bun:test' import { isOpenAIThinkingEnabled, buildOpenAIRequestBody, } from '../requestBody.js' +// Re-register envUtils.js with correct isEnvDefinedFalsy and isEnvTruthy to +// override pollution from other test files (debug-tool-call, issue, +// break-cache, MagicDocs/prompts, SessionMemory/prompts, cacheStats) that +// mock this module without exporting isEnvDefinedFalsy. +mock.module('src/utils/envUtils.js', () => ({ + isEnvTruthy: (v: string | boolean | undefined): boolean => { + if (!v) return false + if (typeof v === 'boolean') return v + return ['1', 'true', 'yes', 'on'].includes(v.toLowerCase().trim()) + }, + isEnvDefinedFalsy: (v: string | boolean | undefined): boolean => { + if (v === undefined) return false + if (typeof v === 'boolean') return !v + if (!v) return false + return ['0', 'false', 'no', 'off'].includes(v.toLowerCase().trim()) + }, +})) + describe('isOpenAIThinkingEnabled', () => { const originalEnv = { OPENAI_ENABLE_THINKING: process.env.OPENAI_ENABLE_THINKING,