agenthub/tests/team.test.ts
chahinebrini 986639a5f3 TSK-0028: AgentHub UI foundation + /team page
- Add src/server/ui-shared.ts: design tokens, agentAvatar(), statusPill(),
  escapeHtml(), liveTimerJs(), pageHeader(). No emojis, no deps.
- Add src/server/team.ts: role hierarchy renderer (architect -> implementer/
  reviewer/tester) with per-agent free/busy state derived from in-progress tasks.
- Wire GET /team route in src/server/routes.ts.
- Add tests/team.test.ts and tests/ui-shared.test.ts.

Build: npm run build clean. Tests: 132 passed (was 122).
2026-06-29 00:24:39 +02:00

62 lines
1.9 KiB
TypeScript

import { describe, it, expect, beforeEach, afterEach } from 'vitest';
import { mkdtempSync, rmSync } from 'fs';
import { tmpdir } from 'os';
import { join } from 'path';
import { buildApp } from '../src/server/index.js';
import { init } from '../src/cli/commands/init.js';
describe('GET /team', () => {
let cwd: string;
let app: ReturnType<typeof buildApp>;
beforeEach(() => {
cwd = mkdtempSync(join(tmpdir(), 'ah-team-'));
init(cwd, { projectName: 'team-test', yes: true });
app = buildApp(cwd);
});
afterEach(() => {
rmSync(cwd, { recursive: true, force: true });
});
it('serves the team page as HTML', async () => {
const res = await app.inject({ method: 'GET', url: '/team' });
expect(res.statusCode).toBe(200);
expect(res.headers['content-type']).toContain('text/html');
const html = res.payload;
expect(html).toContain('<title>AgentHub Team</title>');
expect(html).toContain('team-test');
expect(html).toContain('/board');
expect(html).toContain('/team');
});
it('renders configured agents by role', async () => {
const res = await app.inject({ method: 'GET', url: '/team' });
const html = res.payload;
expect(html).toContain('architect');
expect(html).toContain('implementer');
expect(html).toContain('claude');
expect(html).toContain('codex');
});
it('marks an agent as busy when they have an in-progress task', async () => {
await app.inject({
method: 'POST',
url: '/tasks',
payload: { title: 'Busy work', role: 'implementer' },
});
await app.inject({
method: 'PATCH',
url: '/tasks/TSK-0001',
payload: { status: 'in_progress', assignedTo: 'codex' },
});
const res = await app.inject({ method: 'GET', url: '/team' });
const html = res.payload;
expect(html).toContain('TSK-0001');
expect(html).toContain('data-live-timer');
expect(html).toContain('claimed');
});
});