const test=require('node:test'),assert=require('node:assert/strict'),fs=require('node:fs'),path=require('node:path'); const R=path.dirname(__dirname),load=p=>JSON.parse(fs.readFileSync(path.join(R,p),'utf8')); test('founder direction is not CTO approval or running agents',()=>{ const a=load('delivery_blocks/source.json').agentPhasing; assert.equal(a.founderDirectionConfirmed,true);assert.equal(a.technicalAcceptanceConfirmed,false);assert.equal(a.actualRunningCoreAgents,0); assert.equal(a.status,'founder_confirmed_product_direction_cto_capacity_acceptance_pending'); const group=load('delivery_blocks/source.json').groups.find(g=>g.key==='core_agents_mvp'); assert.equal(group.block,1);assert.equal(group.screens.length,0);assert.deepEqual(group.agentIds,a.m3); assert.equal(load('delivery_blocks/source.json').groups.find(g=>g.screens.includes('assistanceJobs')).block,2); }); test('all public entry aliases load phase navigation',()=>{ for(const p of ['index.html','00_START_HERE.html','00_NAVIGATION_INDEX.html'])assert.match(fs.readFileSync(path.join(R,p),'utf8'),/delivery_blocks\/portal\.js/); }); test('current static term pages include confirmed cap, not just runtime override',()=>{ for(const p of ['index.html','00_START_HERE.html','00_NAVIGATION_INDEX.html','html/index.html','html/00_data_room_index.html','html/01_investment_memo.html','html/10_canonical_numbers_and_language.html','html/18_corporate_structure.html','html/financial_summary.html','html/Seed_Round_Vision_en.html','html/The_Thesis_en.html','html/27_the_thesis.html']){ const s=fs.readFileSync(path.join(R,p),'utf8');assert.ok(s.includes('12M'),p);assert.ok(s.includes('post-money'),p);assert.ok(!s.includes('v46.24'),p); } }); test('editable pitch and private scope workbook are not investor publication',()=>{ const p=load('deployment/investor-package-policy.json');assert.ok(p.excludedRootFiles.includes('GlemO Pitch.pptx'));assert.ok(p.excludedDirectories.includes('private')); assert.ok(fs.existsSync(path.join(R,'GlemO Pitch.pptx'))); }); test('qualified demo is separate from unchanged retail and Brazil denial fixtures',()=>{ const M=require('../wireframe_package/market-access-model.js'); const assets=[{id:'RWA-03',name:'Demo offer',category:'Real estate',issuer:'Nura Capital',country:'United Arab Emirates',assetCountry:'United Arab Emirates',minimum:25000,available:1000000}]; const s=M.createStore(null,{assets,clock:()=> '2026-10-17'}); const q=s.getIdentity('PERSON-AE-QUALIFIED');assert.equal(q.kind,'individual');assert.equal(q.type,'professional');assert.equal(q.country,'AE'); assert.equal(s.checkBuy('RWA-03',q.id).ok,true); assert.equal(s.checkBuy('RWA-03','PERSON-AE').ok,false);assert.equal(s.checkBuy('RWA-03','PERSON-BR').ok,false); assert.equal(s.getPolicy('BR').reason,'PLATFORM_REGISTRATION_ONLY');assert.equal(s.getPolicy('BR').buy,false); }); test('historic QA explicitly points to current SAFE source',()=>{ for(const l of ['en','pt','es','fr','ar','zh']){ const s=fs.readFileSync(path.join(R,`qa/investor-readiness-2026-10-14/INVESTOR_READINESS_${l}.txt`),'utf8'); assert.ok(s.split('\n')[0].includes('SAFE_TERMS.json'));assert.ok(/12|1200/.test(s.split('\n')[0])); } }); test('legacy demo gets the missing synthetic profile without a read-time write',()=>{ const M=require('../wireframe_package/market-access-model.js'),state=M.seed(); state.identities=state.identities.filter(p=>p.id!=='PERSON-AE-QUALIFIED'); const before=JSON.stringify(state);let writes=0; const storage={getItem:()=>before,setItem:()=>{writes++;}}; const s=M.createStore(storage,{clock:()=> '2026-10-17'}); assert.ok(s.getIdentity('PERSON-AE-QUALIFIED'));assert.equal(writes,0); assert.equal(JSON.stringify(s.getState().identities.filter(p=>p.id!=='PERSON-AE-QUALIFIED')),JSON.stringify(state.identities)); assert.deepEqual(s.getState().policies,state.policies);assert.deepEqual(s.getState().offers,state.offers); }); test('demo extension never overwrites an existing profile or a recovered store',()=>{ const M=require('../wireframe_package/market-access-model.js'),state=M.seed(); const q=state.identities.find(p=>p.id==='PERSON-AE-QUALIFIED');q.verified=false;q.reference='MANUAL-REVIEW'; const s=M.createStore({getItem:()=>JSON.stringify(state),setItem:()=>{throw Error('unexpected write');}}); assert.equal(s.getIdentity(q.id).verified,false);assert.equal(s.getIdentity(q.id).reference,'MANUAL-REVIEW'); const broken=M.createStore({getItem:()=>'{broken',setItem:()=>{throw Error('unexpected write');}}); assert.equal(broken.health().recovered,true);assert.equal(broken.getIdentity(q.id),null); const custom=M.seed();custom.identities=custom.identities.filter(p=>p.id!==q.id);custom.policies.AE.reference='CUSTOM-POLICY'; assert.equal(M.createStore({getItem:()=>JSON.stringify(custom)}).getIdentity(q.id),null); });