/** * Implementation — 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 architecturalLinter from '../architectural-linter.js'; import * as boundaryPolicySchema from '../boundary-policy-schema.js'; import * as implementationUnitStructure from '../implementation-unit-structure.js'; import * as regenerationEngine from '../regeneration-engine.js'; describe('Implementation modules', () => { describe('Architectural Linter', () => { it('exports Phoenix traceability metadata', () => { expect(architecturalLinter._phoenix).toBeDefined(); expect(architecturalLinter._phoenix.name).toBe('Architectural Linter'); expect(architecturalLinter._phoenix.risk_tier).toBeTruthy(); }); it('has exported functions', () => { const exports = Object.keys(architecturalLinter).filter(k => k !== '_phoenix'); expect(exports.length).toBeGreaterThan(0); }); }); describe('Boundary Policy Schema', () => { it('exports Phoenix traceability metadata', () => { expect(boundaryPolicySchema._phoenix).toBeDefined(); expect(boundaryPolicySchema._phoenix.name).toBe('Boundary Policy Schema'); expect(boundaryPolicySchema._phoenix.risk_tier).toBeTruthy(); }); it('has exported functions', () => { const exports = Object.keys(boundaryPolicySchema).filter(k => k !== '_phoenix'); expect(exports.length).toBeGreaterThan(0); }); }); describe('Implementation Unit Structure', () => { it('exports Phoenix traceability metadata', () => { expect(implementationUnitStructure._phoenix).toBeDefined(); expect(implementationUnitStructure._phoenix.name).toBe('Implementation Unit Structure'); expect(implementationUnitStructure._phoenix.risk_tier).toBeTruthy(); }); it('has exported functions', () => { const exports = Object.keys(implementationUnitStructure).filter(k => k !== '_phoenix'); expect(exports.length).toBeGreaterThan(0); }); }); describe('Regeneration Engine', () => { it('exports Phoenix traceability metadata', () => { expect(regenerationEngine._phoenix).toBeDefined(); expect(regenerationEngine._phoenix.name).toBe('Regeneration Engine'); expect(regenerationEngine._phoenix.risk_tier).toBeTruthy(); }); it('has exported functions', () => { const exports = Object.keys(regenerationEngine).filter(k => k !== '_phoenix'); expect(exports.length).toBeGreaterThan(0); }); }); }); describe('Implementation 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('Implementation'); }); 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); }); });