refactor: 统一 log.ts/debug.ts 的测试 mock 为共享定义

- 新增 tests/mocks/log.ts 和 tests/mocks/debug.ts,覆盖源文件全部实际导出
- 移除旧 mock 中不存在的导出(logToFile、logEvent、getLogFilePath)
- 13 个测试文件改为使用共享 mock,避免定义分散和不一致

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
claude-code-best
2026-04-22 23:35:59 +08:00
parent 7ea69ca279
commit 1173a62301
16 changed files with 87 additions and 134 deletions

View File

@@ -1,4 +1,5 @@
import { mock, describe, test, expect, beforeEach } from 'bun:test'
import { debugMock } from '../../../../tests/mocks/debug'
// Mock @langfuse/otel before any imports
const mockForceFlush = mock(() => Promise.resolve())
@@ -71,9 +72,7 @@ mock.module('@langfuse/tracing', () => ({
}))
// Mock debug logger
mock.module('src/utils/debug.ts', () => ({
logForDebugging: mock(() => {}),
}))
mock.module('src/utils/debug.ts', debugMock)
// Mock user data — resolveLangfuseUserId uses getCoreUserData().email and .deviceId
mock.module('src/utils/user.js', () => ({

View File

@@ -1,11 +1,10 @@
import { mock, describe, expect, test, afterEach } from "bun:test";
import { debugMock } from "../../../../tests/mocks/debug";
mock.module("axios", () => ({
default: { get: async () => ({ data: { servers: [] } }) },
}));
mock.module("src/utils/debug.ts", () => ({
logForDebugging: () => {},
}));
mock.module("src/utils/debug.ts", debugMock);
const { isOfficialMcpUrl, resetOfficialMcpUrlsForTesting } = await import(
"../officialRegistry"