/** * Tasks — Generated Tests * * AUTO-GENERATED by Phoenix VCS * Tests module structure, server health, and Phoenix traceability. */ import { describe, it, expect, afterAll } from 'vitest'; import { startServer } from '../server.js'; import * as assignment from '../assignment.js'; import * as deadlineManagement from '../deadline-management.js'; import * as searchAndFiltering from '../search-and-filtering.js'; import * as taskLifecycle from '../task-lifecycle.js'; describe('Tasks modules', () => { describe('Assignment', () => { it('exports Phoenix traceability metadata', () => { expect(assignment._phoenix).toBeDefined(); expect(assignment._phoenix.name).toBe('Assignment'); expect(assignment._phoenix.risk_tier).toBeTruthy(); }); it('has exported functions', () => { const exports = Object.keys(assignment).filter(k => k !== '_phoenix'); expect(exports.length).toBeGreaterThan(0); }); }); describe('Deadline Management', () => { it('exports Phoenix traceability metadata', () => { expect(deadlineManagement._phoenix).toBeDefined(); expect(deadlineManagement._phoenix.name).toBe('Deadline Management'); expect(deadlineManagement._phoenix.risk_tier).toBeTruthy(); }); it('has exported functions', () => { const exports = Object.keys(deadlineManagement).filter(k => k !== '_phoenix'); expect(exports.length).toBeGreaterThan(0); }); }); describe('Search and Filtering', () => { it('exports Phoenix traceability metadata', () => { expect(searchAndFiltering._phoenix).toBeDefined(); expect(searchAndFiltering._phoenix.name).toBe('Search and Filtering'); expect(searchAndFiltering._phoenix.risk_tier).toBeTruthy(); }); it('has exported functions', () => { const exports = Object.keys(searchAndFiltering).filter(k => k !== '_phoenix'); expect(exports.length).toBeGreaterThan(0); }); }); describe('Task Lifecycle', () => { it('exports Phoenix traceability metadata', () => { expect(taskLifecycle._phoenix).toBeDefined(); expect(taskLifecycle._phoenix.name).toBe('Task Lifecycle'); expect(taskLifecycle._phoenix.risk_tier).toBeTruthy(); }); it('has exported functions', () => { const exports = Object.keys(taskLifecycle).filter(k => k !== '_phoenix'); expect(exports.length).toBeGreaterThan(0); }); }); }); describe('Tasks server', () => { const instance = startServer(0); // random port afterAll(() => new Promise(resolve => instance.server.close(() => resolve()))); it('GET /health returns 200', async () => { await instance.ready; const res = await fetch(`http://localhost:${instance.port}/health`); expect(res.status).toBe(200); const body = await res.json() as Record; expect(body.status).toBe('ok'); expect(body.service).toBe('Tasks'); }); it('GET /metrics returns request counts', async () => { await instance.ready; const res = await fetch(`http://localhost:${instance.port}/metrics`); expect(res.status).toBe(200); const body = await res.json() as Record; expect(typeof body.requests_total).toBe('number'); }); it('GET /modules lists all registered modules', async () => { await instance.ready; const res = await fetch(`http://localhost:${instance.port}/modules`); expect(res.status).toBe(200); const body = await res.json() as Array>; expect(body.length).toBe(4); }); it('GET /unknown returns 404', async () => { await instance.ready; const res = await fetch(`http://localhost:${instance.port}/unknown`); expect(res.status).toBe(404); }); });