// ============================================================ // PE_DATA parity counts — catches the class of bug where an LLM // silently drops entries from a long clinical array during a port. // Numbers captured 2026-04-24 against public/js/peGuide.js commit // 313ba7f. If the vanilla source changes, update both files in the // same commit. // ============================================================ import { describe, expect, it } from 'vitest'; import { PE_DATA, AGE_GROUP_ORDER, SYSTEM_ORDER } from './pe-data'; describe('PE_DATA shape', () => { it('has the six expected age groups', () => { expect(Object.keys(PE_DATA).sort()).toEqual([...AGE_GROUP_ORDER].sort()); }); it.each([...AGE_GROUP_ORDER])('%s has all four systems', (age) => { const group = PE_DATA[age]; for (const s of SYSTEM_ORDER) { expect(group[s]).toBeDefined(); expect(group[s].overview.length).toBeGreaterThan(0); expect(Array.isArray(group[s].components)).toBe(true); expect(group[s].components.length).toBeGreaterThan(0); } }); it('component + abnormalHints + pearl + significance counts match vanilla', () => { let componentCount = 0; let pearlCount = 0; let significanceCount = 0; for (const age of AGE_GROUP_ORDER) { for (const sys of SYSTEM_ORDER) { const comps = PE_DATA[age][sys].components; for (const c of comps) { componentCount++; if (c.pearl) pearlCount++; if (c.significance) significanceCount++; expect(Array.isArray(c.steps)).toBe(true); expect(c.steps.length).toBeGreaterThan(0); expect(Array.isArray(c.abnormalHints)).toBe(true); } } } // Locked against vanilla peGuide.js (2026-04-24): // 103 components, 27 pearl, 23 significance. expect(componentCount).toBe(103); expect(pearlCount).toBe(27); expect(significanceCount).toBe(23); }); }); // Per-age-group × per-system component counts — captured from the // legacy file with: // awk 'NR>=316 && NR<=1334' public/js/peGuide.js | // awk '/^ [a-z]+: \{$/{age=$1} /^ [a-z]+: \{$/{sys=$1} // /^ { name:/{c[age" "sys]++} END{for(k in c) print k" "c[k]}' | sort // so any drift in the TS port surfaces as a failing test here. describe('PE_DATA per-cell component counts', () => { const EXPECTED: Record = { 'newborn msk': 6, 'newborn neuro': 6, 'newborn resp': 2, 'newborn cv': 2, 'infant msk': 4, 'infant neuro': 5, 'infant resp': 2, 'infant cv': 2, 'toddler msk': 5, 'toddler neuro': 7, 'toddler resp': 2, 'toddler cv': 2, 'preschool msk': 5, 'preschool neuro': 7, 'preschool resp': 2, 'preschool cv': 2, 'school msk': 5, 'school neuro': 7, 'school resp': 3, 'school cv': 2, 'adolescent msk': 6, 'adolescent neuro': 8, 'adolescent resp': 6, 'adolescent cv': 5, }; it.each(Object.entries(EXPECTED))('%s matches', (key, expected) => { const [age, sys] = key.split(' ') as ['newborn', 'msk']; expect(PE_DATA[age][sys].components.length).toBe(expected); }); });