/**
* Token 认证测试
* 测试 Token 的获取、验证、更新等流程
*/
/// <reference path="../global.d.ts" />
describe('update_task_status Tool', () => {
beforeEach(() => {
global.testCache.clear();
});
test('should update task status successfully', async () => {
// 先创建测试任务
const task = await createTestTask(global.testClient, 2);
try {
const result = await updateTaskStatus(global.testClient, global.testCache, task.id, 'doing');
expect(result).toBeDefined();
expect(result.isError).toBeFalsy();
const text = result.content[0].text;
expect(text).toContain('状态更新成功');
console.log(`✅ Updated task status to doing`);
} finally {
// 清理
await cleanupTask(global.testClient, task.id);
}
});
test('should clear cache after status update', async () => {
const task = await createTestTask(global.testClient, 2);
try {
global.testCache.set(\`task:\${task.id}\`, task, 10 * 60 * 1000);
global.testCache.set('tasks:{"projectId":2}', [task], 5 * 60 * 1000);
await updateTaskStatus(global.testClient, global.testCache, task.id, 'done');
expect(global.testCache.get(\`task:\${task.id}\`)).toBeUndefined();
expect(global.testCache.get('tasks:{"projectId":2}')).toBeUndefined();
console.log(`✅ Cache cleared after status update`);
} finally {
await cleanupTask(global.testClient, task.id);
}
});
test('should handle invalid task ID', async () => {
const result = await updateTaskStatus(global.testClient, global.testCache, 999999, 'doing');
expect(result).toBeDefined();
expect(result.isError).toBe(true);
console.log(`✅ Invalid task ID handled`);
});
});