agent-ecosystem/agent-teams-controller/test/controller.test.js
iliya 4cf330e8cc feat: integrate agent-teams-controller and enhance task management
- Added agent-teams-controller as a dependency and updated the bundling configuration to exclude it.
- Refactored task management functions to utilize the new taskStore, improving code organization and maintainability.
- Introduced new methods for handling task states, including soft deletion and restoration.
- Enhanced kanban functionality with improved reviewer management and task column updates.
- Updated tests to reflect changes in task creation and approval processes, ensuring robust coverage.
- Improved task ID handling and display logic for better user experience across components.
2026-03-07 16:01:32 +02:00

68 lines
2.4 KiB
JavaScript

const fs = require('fs');
const os = require('os');
const path = require('path');
const { createController } = require('../src/index.js');
describe('agent-teams-controller API', () => {
function makeClaudeDir() {
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'agent-teams-controller-'));
fs.mkdirSync(path.join(dir, 'teams', 'my-team'), { recursive: true });
fs.mkdirSync(path.join(dir, 'tasks', 'my-team'), { recursive: true });
fs.writeFileSync(
path.join(dir, 'teams', 'my-team', 'config.json'),
JSON.stringify(
{
name: 'my-team',
members: [
{ name: 'alice', role: 'team-lead' },
{ name: 'bob', role: 'developer' },
],
},
null,
2
)
);
return dir;
}
it('creates tasks and exposes grouped controller modules', () => {
const claudeDir = makeClaudeDir();
const controller = createController({ teamName: 'my-team', claudeDir });
const base = controller.tasks.createTask({ subject: 'Base task' });
const dependency = controller.tasks.createTask({ subject: 'Dependency task' });
const created = controller.tasks.createTask({
subject: 'Blocked task',
owner: 'bob',
'blocked-by': `${base.displayId},${dependency.displayId}`,
related: base.displayId,
});
expect(created.id).toMatch(
/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i
);
expect(created.displayId).toHaveLength(8);
expect(created.status).toBe('pending');
expect(controller.tasks.getTask(base.id).blocks).toEqual([created.id]);
expect(controller.tasks.getTask(created.displayId).blockedBy).toEqual([base.id, dependency.id]);
controller.kanban.addReviewer('alice');
controller.kanban.setKanbanColumn(created.id, 'review');
controller.review.approveReview(created.id, { 'notify-owner': true, from: 'alice' });
const kanbanState = controller.kanban.getKanbanState();
expect(kanbanState.reviewers).toEqual(['alice']);
expect(kanbanState.tasks[created.id].column).toBe('approved');
const proc = controller.processes.registerProcess({
pid: process.pid,
label: 'dev-server',
port: '3000',
});
expect(proc.port).toBe(3000);
expect(controller.processes.listProcesses()).toHaveLength(1);
const stopped = controller.processes.stopProcess({ pid: process.pid });
expect(typeof stopped.stoppedAt).toBe('string');
});
});