/**
* Token 认证测试
* 测试 Token 的获取、验证、更新等流程
*/
/// <reference path="../global.d.ts" />
describe('batch_create_tasks Tool', () => {
beforeEach(() => {
global.testCache.clear();
});
test('should create multiple tasks successfully', async () => {
const tasks = createBatchTaskData(3, 2);
const result = await batchCreateTasks(global.testClient, global.testCache, tasks, {
continueOnError: true,
reportMode: 'detailed',
maxConcurrency: 5
});
expect(result).toBeDefined();
expect(result.success).toBe(3);
expect(result.failed).toBe(0);
console.log(`✅ Created 3 tasks successfully`);
// 清理
for (const r of result.results) {
if (r.status === 'success') {
await cleanupTask(global.testClient, r.id);
}
}
});
test('should handle partial failures', async () => {
const tasks = [
{ name: 'Valid Task', project: 2, assignedTo: 's000001' },
{ name: 'Invalid Project', project: 999999, assignedTo: 's000001' }
];
const result = await batchCreateTasks(global.testClient, global.testCache, tasks, {
continueOnError: true
});
expect(result.success + result.failed).toBe(result.total);
console.log(`✅ Handled partial failures: ${result.success} success, ${result.failed} failed`);
});
test('should respect maxConcurrency limit', async () => {
const tasks = createBatchTaskData(5, 2);
const result = await batchCreateTasks(global.testClient, global.testCache, tasks, {
maxConcurrency: 2
});
expect(result.success).toBe(5);
console.log(`✅ Respected concurrency limit`);
// 清理
for (const r of result.results) {
if (r.status === 'success') {
await cleanupTask(global.testClient, r.id);
}
}
});
});