3 lines
4.0 KiB
JavaScript
3 lines
4.0 KiB
JavaScript
import fs from'node:fs';import assert from'node:assert/strict';import crypto from'node:crypto';import{session}from'./sgf-single-http.mjs';const root=JSON.parse(fs.readFileSync('C:/laragon/data/sgf-tempo/run/modular-regression-current.json')).root+'/private/receipt-composition-cc50a276c10c',p=JSON.parse(fs.readFileSync(root+'/hp-http-progress-private.json')),s=await session('hr:hr_read','human_resources'),checks=[],ok=(v,n)=>{assert(v,n);checks.push(n);};let reportBytes;for(const[kind,step]of[['contract','contract-review'],['day','day9-review'],['entitlement','entitlement-review'],['leave','take-review'],['report','report-review']]){const row=p.steps[step].result,id=row.id,source=row.impact.after.proposal.artifact_sha256;let r=await s.get('/api/hr-personnel/readable/'+id);assert.equal(r.status,200);const bytes=Buffer.from(await r.arrayBuffer());ok(/text\/csv/.test(r.headers.get('content-type'))&&r.headers.get('x-source-sha256')===source&&r.headers.get('x-sgf-read-format')==='SGF-HR-READABLE-CSV-v1'&&crypto.createHash('sha256').update(bytes).digest('hex')===r.headers.get('x-content-sha256'),'actual readable headers source and SHA '+kind);ok(bytes.toString().includes('não é documento legal')&&!bytes.toString().includes('{""'),'actual readable labels without raw objects '+kind);r=await s.get('/api/hr-personnel/exports/'+id);assert.equal(r.status,200);const original=Buffer.from(await r.arrayBuffer());ok(crypto.createHash('sha256').update(original).digest('hex')===source,'original preserved CSV SHA '+kind);if(kind==='report'){reportBytes=bytes;ok(bytes.toString().includes('Outros dias sem cobertura comprovada')&&bytes.toString().includes('Não demonstrado')&&bytes.toString().includes('480 minutos'),'real partial period and time limits legible');ok(original.equals(fs.readFileSync(root+'/hp-frozen-period-private.csv')),'original period CSV bytes unchanged');}}
|
|
const historical=p.steps['day10-review'].result;let r=await s.get('/api/hr-personnel/readable/'+historical.id);assert.equal(r.status,200);ok((await r.text()).includes('Desconhecida'),'old unknown declaration not replaced by current empty declaration');r=await s.get('/api/hr-personnel/readable/'+p.steps['day10-conference-review'].result.id);assert.equal(r.status,200);ok((await r.text()).includes('Conjunto explicitamente vazio'),'current explicitly empty declaration distinguished');r=await s.get('/api/hr-personnel/readable/2147483647');ok(r.status===403,'foreign readable version refused');r=await s.get('/api/hr-personnel/readable/'+p.steps['contract-prepare'].result.id);ok(r.status===403,'prepared readable version refused');r=await s.get('/api/hr-personnel/readable/'+p.steps['contract-review'].result.id+'?tenant_id=2');ok(r.status===422,'readable tenant override refused');const finance=await session('sgf:finance_prepare','finance');r=await finance.get('/api/hr-personnel/readable/'+p.steps['contract-review'].result.id);ok([403,409].includes(r.status),'financial profile cannot read HR summary');r=await fetch('http://127.0.0.1:8085/api/hr-personnel/readable/'+p.steps['contract-review'].result.id,{headers:{Accept:'application/json'}});ok(r.status===401,'unauthenticated summary refused');const manifest=JSON.parse(fs.readFileSync(root+'/app/public/build/manifest.json'));for(const e of Object.values(manifest).filter(e=>e.isEntry||/PersonnelWorkspace|statement-download/.test(e.file))){r=await fetch('http://127.0.0.1:8085/build/'+e.file);const b=Buffer.from(await r.arrayBuffer());ok(r.status===200&&/javascript/.test(r.headers.get('content-type'))&&crypto.createHash('sha256').update(b).digest('hex')===crypto.createHash('sha256').update(fs.readFileSync(root+'/app/public/build/'+e.file)).digest('hex'),'served JS MIME SHA '+e.file);}fs.writeFileSync(root+'/hp-readable-period-private.csv',reportBytes);const file=root+'/hp-readable-http-20261111.json';fs.writeFileSync(file,JSON.stringify({passed:true,checks,business_commands:0,new_grants:0,browser_visual_review:false},null,2));console.log(JSON.stringify({passed:true,checks:checks.length,proof:file}));
|