62 lines
3.6 KiB
JavaScript
62 lines
3.6 KiB
JavaScript
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('six-month reading path does not promise skills rollout or autonomous delivery',()=>{
|
|
const main=read('docs/strategy/six-months-target.mdx').split('<details>')[0];
|
|
assert(main.indexOf('strategy-six-months')<main.indexOf('Choose the smallest intervention'));
|
|
for(const stale of ['The first investment is a governed skills system','An autonomous agent executes and governs every phase','foundation for Stage 2'])assert(!main.includes(stale));
|
|
const roadmap=read('docs/strategy/six-months-roadmap.mdx');
|
|
for(const month of [1,2,3,4,5,6]){
|
|
const block=roadmap.split(`**Month ${month} — `)[1].split('\n\n')[0];
|
|
for(const word of ['Output:','Dependency:'])assert(block.includes(word),`${month}: ${word}`);
|
|
}
|
|
});
|
|
test('proposed diagram preserves months and explicit mobile feedback legend',()=>{
|
|
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='<svg role="img" viewBox="0 0 1200 1000"><g data-node-id="agent"/></svg>';
|
|
const out=targetCaption(svg);
|
|
for(const term of ['Long-term 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')<out.indexOf('</svg>'));
|
|
assert.equal((out.match(/data-node-id=/g)||[]).length,1);
|
|
assert.throws(()=>targetCaption('<svg/>'));
|
|
});
|