/** * Settlements — 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 debtSimplification from '../debt-simplification.js'; import * as recordingSettlements from '../recording-settlements.js'; import * as settlementStatus from '../settlement-status.js'; describe('Settlements modules', () => { describe('Debt Simplification', () => { it('exports Phoenix traceability metadata', () => { expect(debtSimplification._phoenix).toBeDefined(); expect(debtSimplification._phoenix.name).toBe('Debt Simplification'); expect(debtSimplification._phoenix.risk_tier).toBeTruthy(); }); it('has exported functions', () => { const exports = Object.keys(debtSimplification).filter(k => k !== '_phoenix'); expect(exports.length).toBeGreaterThan(0); }); }); describe('Recording Settlements', () => { it('exports Phoenix traceability metadata', () => { expect(recordingSettlements._phoenix).toBeDefined(); expect(recordingSettlements._phoenix.name).toBe('Recording Settlements'); expect(recordingSettlements._phoenix.risk_tier).toBeTruthy(); }); it('has exported functions', () => { const exports = Object.keys(recordingSettlements).filter(k => k !== '_phoenix'); expect(exports.length).toBeGreaterThan(0); }); }); describe('Settlement Status', () => { it('exports Phoenix traceability metadata', () => { expect(settlementStatus._phoenix).toBeDefined(); expect(settlementStatus._phoenix.name).toBe('Settlement Status'); expect(settlementStatus._phoenix.risk_tier).toBeTruthy(); }); it('has exported functions', () => { const exports = Object.keys(settlementStatus).filter(k => k !== '_phoenix'); expect(exports.length).toBeGreaterThan(0); }); }); }); describe('Settlements 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('Settlements'); }); 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(3); }); it('GET /unknown returns 404', async () => { await instance.ready; const res = await fetch(`http://localhost:${instance.port}/unknown`); expect(res.status).toBe(404); }); });