import test from 'node:test'; import assert from 'node:assert/strict'; import {readFileSync} from 'node:fs'; import {targetCaption} from './target-caption.mjs'; const read = p => readFileSync(p,'utf8'); const matrix = JSON.parse(read('research/ai-adoption/assignment-evidence.json')); test('PDF assignment and audit matrix map to actual page evidence',()=>{ assert.deepEqual(matrix.requirements.map(r=>r.id),['format','context','q1','q2','q3','q4','assumptions','F1','F2-F3']); for(const row of matrix.requirements){ const text=row.pages.map(p=>read(`docs/strategy/${p}.mdx`)).join('\n').toLowerCase(); for(const marker of row.markers) assert(text.includes(marker.toLowerCase()),`${row.id}: ${marker}`); } for(const p of matrix.verification_sources)assert(read(p)); assert.equal(35+15,50); }); test('main reading path does not promise skills rollout or autonomous destination',()=>{ const main=read('docs/strategy/target-operating-model.mdx').split('
')[0]; assert(main.indexOf('strategy-six-months'){ const pair=['','-mobile'].map(s=>JSON.parse(read(`diagrams/strategy-six-months${s}.architecture.json`))); const nodes=d=>d.components.map(({pos,size,...n})=>n); assert.deepEqual(nodes(pair[0]),nodes(pair[1])); for(const d of pair){ for(let m=1;m<=6;m++)assert(d.components.some(n=>n.label.startsWith(`Month ${m}:`))); const legend=d.components.find(n=>n.id==='reference'); assert(legend.sublabel.includes('Month 6 → 2:'));assert(legend.sublabel.includes('Month 5 → 1:')); assert(legend.sublabel.includes('not company commitments')); } }); test('first-revision recovery and diagram decisions cannot disappear',()=>{ for(const id of ['skills-quality','skills-governance','skills-maintenance']){ const text=read(`docs/strategy/${id}.mdx`); for(const term of ['N/A','pinned clean','current'])assert(text.includes(term),id); } for(const s of ['','-mobile']){ const g=JSON.parse(read(`diagrams/strategy-governance${s}.architecture.json`)); assert(g.components.find(n=>n.id==='canary').sublabel.includes('pilot')); assert(g.components.find(n=>n.id==='approve').sublabel.includes('approve / hold')); const a=JSON.parse(read(`diagrams/strategy-adoption${s}.architecture.json`)); assert(a.components.find(n=>n.id==='expand').sublabel.includes('Retain / improve / hold / stop')); } const mobile=JSON.parse(read('diagrams/strategy-maintenance-mobile.architecture.json')); const order=[...mobile.components].sort((a,b)=>a.pos[1]-b.pos[1]).map(n=>n.id); assert.deepEqual(order.slice(0,2),['observe','triage']); }); test('target caption is inside SVG, expands canvas and fails closed',()=>{ const svg=''; const out=targetCaption(svg); for(const term of ['Proposed optional target','Solid: lifecycle','Dotted: execution','Dashed: human-controlled'])assert(out.includes(term)); assert(out.includes('viewBox="0 0 1200 1130"')); assert(out.indexOf('eldorado-target-caption')')); assert.equal((out.match(/data-node-id=/g)||[]).length,1); assert.throws(()=>targetCaption('')); });