Reference implementation for the Phoenix Architecture. Work in progress. aicoding.leaflet.pub/
ai coding crazy
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 117 lines 4.0 kB view raw
1/** 2 * Ui — Generated Tests 3 * 4 * AUTO-GENERATED by Phoenix VCS 5 * Tests module structure, server health, and Phoenix traceability. 6 */ 7 8import { describe, it, expect, afterAll } from 'vitest'; 9import { startServer } from '../server.js'; 10 11import * as feedback from '../feedback.js'; 12import * as gridRendering from '../grid-rendering.js'; 13import * as layout from '../layout.js'; 14import * as responsiveness from '../responsiveness.js'; 15 16describe('Ui modules', () => { 17 describe('Feedback', () => { 18 it('exports Phoenix traceability metadata', () => { 19 expect(feedback._phoenix).toBeDefined(); 20 expect(feedback._phoenix.name).toBe('Feedback'); 21 expect(feedback._phoenix.risk_tier).toBeTruthy(); 22 }); 23 24 it('has exported functions', () => { 25 const exports = Object.keys(feedback).filter(k => k !== '_phoenix'); 26 expect(exports.length).toBeGreaterThan(0); 27 }); 28 }); 29 30 describe('Grid Rendering', () => { 31 it('exports Phoenix traceability metadata', () => { 32 expect(gridRendering._phoenix).toBeDefined(); 33 expect(gridRendering._phoenix.name).toBe('Grid Rendering'); 34 expect(gridRendering._phoenix.risk_tier).toBeTruthy(); 35 }); 36 37 it('has exported functions', () => { 38 const exports = Object.keys(gridRendering).filter(k => k !== '_phoenix'); 39 expect(exports.length).toBeGreaterThan(0); 40 }); 41 }); 42 43 describe('Layout', () => { 44 it('exports Phoenix traceability metadata', () => { 45 expect(layout._phoenix).toBeDefined(); 46 expect(layout._phoenix.name).toBe('Layout'); 47 expect(layout._phoenix.risk_tier).toBeTruthy(); 48 }); 49 50 it('has exported functions', () => { 51 const exports = Object.keys(layout).filter(k => k !== '_phoenix'); 52 expect(exports.length).toBeGreaterThan(0); 53 }); 54 }); 55 56 describe('Responsiveness', () => { 57 it('exports Phoenix traceability metadata', () => { 58 expect(responsiveness._phoenix).toBeDefined(); 59 expect(responsiveness._phoenix.name).toBe('Responsiveness'); 60 expect(responsiveness._phoenix.risk_tier).toBeTruthy(); 61 }); 62 63 it('has exported functions', () => { 64 const exports = Object.keys(responsiveness).filter(k => k !== '_phoenix'); 65 expect(exports.length).toBeGreaterThan(0); 66 }); 67 }); 68 69}); 70 71describe('Ui server', () => { 72 const instance = startServer(0); // random port 73 74 afterAll(() => new Promise<void>(resolve => instance.server.close(() => resolve()))); 75 76 it('GET /health returns 200', async () => { 77 await instance.ready; 78 const res = await fetch(`http://localhost:${instance.port}/health`); 79 expect(res.status).toBe(200); 80 const body = await res.json() as Record<string, unknown>; 81 expect(body.status).toBe('ok'); 82 expect(body.service).toBe('Ui'); 83 }); 84 85 it('GET /metrics returns request counts', async () => { 86 await instance.ready; 87 const res = await fetch(`http://localhost:${instance.port}/metrics`); 88 expect(res.status).toBe(200); 89 const body = await res.json() as Record<string, unknown>; 90 expect(typeof body.requests_total).toBe('number'); 91 }); 92 93 it('GET /modules lists all registered modules', async () => { 94 await instance.ready; 95 const res = await fetch(`http://localhost:${instance.port}/modules`); 96 expect(res.status).toBe(200); 97 const body = await res.json() as Array<Record<string, unknown>>; 98 expect(body.length).toBe(4); 99 }); 100 101 it('GET /unknown returns 404', async () => { 102 await instance.ready; 103 const res = await fetch(`http://localhost:${instance.port}/unknown`); 104 expect(res.status).toBe(404); 105 }); 106 107 it('GET / serves HTML page', async () => { 108 await instance.ready; 109 const res = await fetch(`http://localhost:${instance.port}/`); 110 expect(res.status).toBe(200); 111 const ct = res.headers.get('content-type') ?? ''; 112 expect(ct).toContain('text/html'); 113 const body = await res.text(); 114 expect(body).toContain('<!DOCTYPE html>'); 115 expect(body).toContain('<title>Ui</title>'); 116 }); 117});