notParsec / 문서전체 문서

생성 코드·템플릿

development-progress.test.cjs

design/development-progress.test.cjs

출처: 현재 작업 폴더 · 원문 다운로드

const test = require('node:test');
const assert = require('node:assert/strict');
const fs = require('node:fs');
const path = require('node:path');
const D = require('./development-progress.js');
const C = require('./plan-core.js');
const P = JSON.parse(fs.readFileSync(path.join(__dirname, 'plan-data.json'), 'utf8'));
const R = JSON.parse(fs.readFileSync(path.join(__dirname, 'development-status.json'), 'utf8'));
const clone = value => structuredClone(value);

test('implementation ledger covers every feature and resolves its evidence', () => {
  assert.equal(D.validate(P, R), true);
  assert.equal(Object.keys(R.features).length, 82);
  for (const row of [...Object.values(R.features), ...R.milestones]) {
    for (const e of row.evidence) assert.ok(fs.statSync(path.resolve(__dirname, e.path)).isFile(), e.path);
  }
  const missing = clone(R); delete missing.features.F82;
  assert.throws(() => D.validate(P, missing), /전체 기능/);
  const unsafe = clone(R); unsafe.features.F01.evidence[0].path = 'javascript:alert(1)';
  assert.throws(() => D.validate(P, unsafe), /근거 링크/);
});

test('full completion requires evidence, all gates and completed prerequisites', () => {
  const bad = clone(R); bad.features.F80.state = 'done';
  assert.throws(() => D.validate(P, bad), /완료 근거/);
  bad.features.F80.remaining = [];
  bad.features.F80.stages = {design:'documented', code:'complete', test:'complete', integration:'complete'};
  assert.throws(() => D.validate(P, bad), /완료 근거/);
  const good = clone(R); Object.assign(good.features.F01, {state:'done', remaining:[], stages:{design:'documented', code:'complete', test:'complete', integration:'complete'}});
  assert.throws(() => D.validate(P, good), /원본 대조 완료/);
  good.features.F01.parity = {status:'matched', sourceEvidence:[{label:'test source fixture',path:'PARSEC_PARITY.ko.md'}], comparisonEvidence:[{label:'test comparison fixture',path:'VERIFICATION.md'}],exceptionIds:[]};
  assert.equal(D.validate(P, good), true);
  good.features.F01.evidence = [];
  assert.throws(() => D.validate(P, good), /진행 근거/);
});

test('parity cannot be signed off without comparison evidence or by inventing an exception', () => {
  const r=clone(R), p=r.features.F24.parity;
  p.status='matched';p.comparisonEvidence=[];
  assert.throws(()=>D.validate(P,r),/원본 대조 근거/);
  p.comparisonEvidence=[{label:'test comparison fixture',path:'VERIFICATION.md'}];
  p.status='exception_verified';p.exceptionIds=[];
  assert.throws(()=>D.validate(P,r),/예외 범위/);
  p.exceptionIds=['E999'];assert.throws(()=>D.validate(P,r),/명시되지 않은 예외/);
  p.exceptionIds=['E04'];assert.equal(D.validate(P,r),true);
  p.status='matched';assert.throws(()=>D.validate(P,r),/예외 범위/);
  p.status='exception_verified';p.sourceEvidence[0].path='javascript:alert(1)';
  assert.throws(()=>D.validate(P,r),/근거 링크/);
});

test('phase totals count complete features without treating partial work as completion', () => {
  const s = D.summary(P, R);
  assert.deepEqual([s.total,s.done,s.doing,s.validation,s.todo,s.blocked,s.percent], [82,0,59,1,22,0,0]);
  assert.equal(s.phases.reduce((n,p)=>n+p.total,0),82);
  assert.equal(s.phases.reduce((n,p)=>n+p.doing,0),59);
  assert.equal(s.phases.find(p=>p.id==='M4').doing,13);
  assert.equal(D.summary({...P,features:[]}, {...R,features:{}}).percent,0);
});

test('combined filters and manual completion never mutate the evidence ledger', () => {
  const user=C.initial(P); user.status.F80='done'; user.selected=['F80'];
  const original=JSON.stringify(R), selected=JSON.stringify(user);
  assert.deepEqual(D.rows(P,R,user,{scope:'selected'}).map(f=>f.id),['F80']);
  assert.deepEqual(D.rows(P,R,user,{status:'validation',phase:'M0',query:'DPAPI'}).map(f=>f.id),['F80']);
  assert.equal(D.rows(P,R,user,{status:'done'}).length,0);
  assert.equal(D.rows(P,R,user,{phase:'M2',status:'doing'}).length,6);
  assert.equal(D.summary(P,R).done,0);
  assert.equal(JSON.stringify(R),original); assert.equal(JSON.stringify(user),selected);
  const exported=D.markdown(P,R,user);
  assert.match(exported,/F80.*검증 대기/); assert.match(exported,/사용자 기록: 범위 포함 \/ done/);
  for(const f of P.features) assert.ok(exported.includes('- '+f.id+' '));
  assert.match(C.brief(P,user,R),/구현 기록 F80: validation/);
  assert.match(C.brief(P,user,R),/development-status\.json/);
});

test('standalone HTML embeds the complete ledger and progress controls', () => {
  const html=fs.readFileSync(path.join(__dirname,'notparsec-plan.html'),'utf8');
  assert.deepEqual(JSON.parse(html.match(/<script id="development-data" type="application\/json">([\s\S]*?)<\/script>/)[1]),R);
  assert.ok(!html.includes('__PROGRESS_'));
  for(const id of ['development','matrix-search','phase-filter','matrix-status','features','export-json','dev-history']) assert.ok(html.includes('id="'+id+'"'));
  assert.ok(!html.includes('data-complete='));
  assert.ok(!html.includes('data-status='));
  assert.ok(!html.includes('data-select='));
  for(const milestone of R.milestones)assert.ok(html.includes(milestone.title));
});