19 lines
2.9 KiB
JavaScript
19 lines
2.9 KiB
JavaScript
import fs from 'node:fs';import path from 'node:path';import assert from 'node:assert/strict';
|
|
const read=p=>JSON.parse(fs.readFileSync(p,'utf8')),state=read('C:/laragon/data/sgf-tempo/run/modular-regression-current.json'),tag=process.argv[2];
|
|
if(state.port!==55439||!/^[a-f0-9]{12}$/.test(tag??''))throw Error('Owned QA tag required');
|
|
const root=path.join(state.root,'private/ledger-'+tag),demo=read(path.join(root,'ledger-demo.json')),g=read(path.join(root,'ledger-fixture.json')),f=read(path.join(root,'fixture.json')),output=path.join(root,'ledger-flow-demo-http.json');
|
|
if(!g.integrated_flow||fs.existsSync(output))throw Error('Unfinished integrated team proof required');
|
|
let checks=0;const check=(v,s)=>{checks++;assert(v,s);},base=new URL(demo.url).origin;
|
|
let r=await fetch(demo.url);check(r.status===200&&(await r.text()).includes('data-ledger-demo="'+tag+'"'),'New integrated landing available');
|
|
for(const role of ['prepare','validate','read']){
|
|
const jar=new Map();let auth;
|
|
const req=async(url,body)=>{const r=await fetch(base+url,{method:body?'POST':'GET',headers:{Accept:'application/json',Cookie:[...jar].map(([k,v])=>k+'='+v).join('; '),'X-SGF-Context':auth?.context??'',...(body?{'Content-Type':'application/json','X-CSRF-TOKEN':auth.csrf}:{})},body:body?JSON.stringify(body):undefined,redirect:'manual'});for(const c of r.headers.getSetCookie()){const p=c.split(';')[0],at=p.indexOf('=');jar.set(p.slice(0,at),p.slice(at+1));}const text=await r.text();let data;try{data=JSON.parse(text);}catch{}return{status:r.status,text,data,headers:r.headers};};
|
|
r=await req('/qa/ledger-enter/'+role);check(r.status===200,'Dedicated '+role+' identity');auth=r.data;check(jar.has(demo.cookie)&&!jar.has('XSRF-TOKEN'),'Own cookie without changing shared CSRF cookie');
|
|
r=await req('/general-ledger/flow?source='+g.local_source_id);check(r.status===200&&r.text.includes('Ainda não reconhecida')&&r.text.includes('Nenhum lançamento aplicado'),'Pristine complete chain for '+role);
|
|
r=await req('/api/general-ledger');check(r.status===200&&r.data.journals.length===0&&r.data.proposals.length===0,'No accounting effects in team fixture');
|
|
r=await req('/api/context',{...f.scope,module_id:'purchasing'});check(r.status===200,'Existing module selection works');auth={csrf:r.data.csrf,context:r.data.context.token};
|
|
r=await req('/api/supplier-payables?source='+g.local_source_id);check(r.status===200&&r.data.obligations.length===0&&r.data.proposals.length===0,'Team starts before financial recognition');
|
|
r=await req('/supplier-payables?source='+g.local_source_id);check(r.status===200&&r.text.includes('ledger_flow_url'),'Financial handoff reachable');
|
|
}
|
|
fs.writeFileSync(output,JSON.stringify({passed:true,checks,url:demo.url,tag,financial_obligations:0,financial_proposals:0,ledger_proposals:0,journals:0,roles:3,no_business_commands:true,visual_review:false,browser_automation:false,cookie_isolated:true},null,2)+'\n');console.log(JSON.stringify({passed:true,checks,url:demo.url}));
|