import fs from 'node:fs';import assert from 'node:assert/strict';import crypto from 'node:crypto';import {session} from './sgf-single-http.mjs';import {overviewPage,overviewSources} from '../resources/js/workspace-overview.js'; const run=JSON.parse(fs.readFileSync('C:/laragon/data/sgf-tempo/run/modular-regression-current.json')),root=run.root+'/private/receipt-composition-cc50a276c10c',state=JSON.parse(fs.readFileSync(root+'/state.json')),manifest=JSON.parse(fs.readFileSync(state.app+'/public/build/manifest.json')),checks=[];const ok=(v,n)=>{assert(v,n);checks.push(n);};let r=await fetch('http://127.0.0.1:8085/sgf');const entry=await r.text();ok(r.status===200&&entry.includes('O que pode acompanhar em cada módulo'),'entry explains actual module scope');ok((entry.match(/Abrir início de /g)??[]).length===6,'six explicit module-home entries');ok(entry.includes('documento, movimento físico')||entry.includes('Documento, movimento físico'),'business facts distinguished');for(const [profile,module]of [['sgf:commercial_prepare','commercial'],['purchasing:actor','purchasing'],['purchasing:validator','stock'],['sgf:workshop_manage','workshop'],['sgf:finance_prepare','finance'],['sgf:accounting_prepare','accounting']]){const s=await session(profile,module);r=await s.get('/',{headers:{Accept:'text/html'}});const html=await r.text();ok(r.status===200&&html.includes(manifest['resources/js/app.jsx'].file),module+' installed client served');if(module==='finance'){const c=s.identity.context,source=overviewSources(c,(right,unit)=>c.grants.some(g=>g.permission===right&&g.unit_id===unit)).find(s=>s.id==='cash');const response=await s.get(source.path),page=overviewPage(source,await response.json());ok(page.facts.some(f=>f.value==='950,00 MZN')&&page.facts.some(f=>f.value==='Fechada'),'live cash authoritative950 closed');}} const lazy=manifest['resources/js/WorkspaceHome.jsx'].file;r=await fetch('http://127.0.0.1:8085/build/'+lazy);const bytes=Buffer.from(await r.arrayBuffer());ok(r.status===200&&crypto.createHash('sha256').update(bytes).digest('hex')===crypto.createHash('sha256').update(fs.readFileSync(state.app+'/public/build/'+lazy)).digest('hex'),'installed overview asset exact HTTP checksum');const file=root+'/overview-entry-http-20261110.json';fs.writeFileSync(file,JSON.stringify({passed:true,checks,business_commands:0,source_mutations:0,new_grants:0,browser_visual_review:false},null,2));console.log(JSON.stringify({passed:true,checks:checks.length,proof:file}));