fix(core): 修复测试用例以匹配最新实现
- todo-manager.test: 修复空日期字符串导致的 Invalid time value 错误 - config-loader.test: 更新测试以匹配简化后的配置加载逻辑 - mcp/config.test: 修复配置路径匹配问题 - task.test/task-extended.test: 添加缺失的 agentEventEmitter mock - presets/index.test: 更新预设 Agent 数量和 maxSteps 测试 - agent.test: 添加缺失的 mock 函数并修正模式切换测试 - 删除过时的 session/manager.test 和 storage.test (使用已废弃的 API)
This commit is contained in:
@@ -332,15 +332,18 @@ describe('MCP Config', () => {
|
||||
|
||||
let callCount = 0;
|
||||
vi.mocked(fs.existsSync).mockImplementation((filePath) => {
|
||||
return (
|
||||
String(filePath).includes('.ai-assist') &&
|
||||
String(filePath).endsWith('config.json')
|
||||
);
|
||||
const pathStr = String(filePath);
|
||||
// 用户级配置(mcp.json)或项目级配置(.ai-assist/config.json)
|
||||
return pathStr.endsWith('mcp.json') || pathStr.endsWith('config.json');
|
||||
});
|
||||
vi.mocked(fs.readFileSync).mockImplementation(() => {
|
||||
vi.mocked(fs.readFileSync).mockImplementation((filePath) => {
|
||||
const pathStr = String(filePath);
|
||||
callCount++;
|
||||
// 第一次调用返回用户配置,第二次返回项目配置
|
||||
return JSON.stringify(callCount === 1 ? userConfig : projectConfig);
|
||||
// 根据文件路径返回不同配置
|
||||
if (pathStr.endsWith('mcp.json')) {
|
||||
return JSON.stringify(userConfig);
|
||||
}
|
||||
return JSON.stringify(projectConfig);
|
||||
});
|
||||
|
||||
const config = loadMCPConfig('/test/dir');
|
||||
|
||||
Reference in New Issue
Block a user