10 lines
3.3 KiB
JavaScript
10 lines
3.3 KiB
JavaScript
import fs from'node:fs';import assert from'node:assert/strict';import{session}from'./sgf-single-http.mjs';
|
|
const checks=[],test=(condition,label)=>{assert(condition,label);checks.push(label);};const warehouse=await session('purchasing:validator','stock'),review=await session('sgf:workshop_verify','stock');
|
|
for(const [s,label]of[[warehouse,'Armazém'],[review,'Conferência']]){let r=await s.get('/api/stock-final?per_page=100');test(r.status===200,label+' authorized current page100');const data=await r.json();test(data.transfers.total===1&&data.in_transit_milli===0,label+' sees the same completed transfer without another operation');r=await s.get('/api/stock-final/history?per_page=25');test(r.status===200,label+' audit page25');const h=await r.json();test(h.data.length>=9&&h.data.every(e=>e.reason&&e.host_author_id),label+' history includes individual author and reason');}
|
|
let r=await warehouse.get('/api/stock-final?per_page=26');test(r.status===422,'unsupported page size422');await r.text();r=await warehouse.get('/api/stock-final?company_id=999');test(r.status===422,'caller cannot replace company through query');await r.text();r=await warehouse.get('/api/stock-final',{headers:{'X-SGF-Context':'obsolete-context'}});test(r.status===409,'stale HTTP context409');await r.text();
|
|
const reader=await session('sgf:read_only','stock');r=await reader.get('/api/stock-final');test(r.status===403,'ordinary stock reader cannot obtain the restricted lot/transit adapter');await r.text();r=await reader.command('/api/stock-final/preview',{action:'dispatch',operation_key:crypto.randomUUID(),revision:'a'.repeat(64),reason:'Tentativa sem concessão de operação física.',data:{}});test(r.status===403,'unauthorised physical writer403');
|
|
const finance=await session('sgf:finance_prepare','finance');r=await finance.get('/api/finance/payables');test(r.status===200,'existing native finance permission survives QA profile mode');await r.text();r=await finance.get('/api/stock-final');test(r.status===409,'different module409 requires an explicit context change');await r.text();
|
|
const purchasing=await session('purchasing:validator','purchasing');r=await purchasing.get('/api/purchasing-receipts/history/1');test(r.status===200,'original native receipt1 remains readable after profile-mode extension');await r.text();
|
|
const accounting=await session('sgf:accounting_prepare','accounting');r=await accounting.get('/api/general-ledger');test(r.status===200,'shared accounting book remains readable');const ledger=await r.json();test(ledger.journals.length===18&&ledger.chart_accounts.length===15,'current18 journals and15 QA accounts');const original=ledger.stock.find(s=>s.ownership.owned_quantity_milli===1500);test(original.ownership.owned_quantity_milli===1500&&original.ownership.in_transit_milli===0,'accounting explicitly distinguishes owned1.5UN from source available0.5UN');
|
|
r=await accounting.get('/api/v1/integration/sgc/invoices');test(r.status===404,'SGC receiver route remains absent');await r.text();const run=JSON.parse(fs.readFileSync('C:/laragon/data/sgf-tempo/run/modular-regression-current.json')),file=run.root+'/private/receipt-composition-cc50a276c10c/stock-final-boundaries-http-20261110.json';fs.writeFileSync(file,JSON.stringify({passed:true,checks,business_commands_confirmed:0,browser_visual_review:false},null,2));console.log(JSON.stringify({passed:true,checks:checks.length,proof:file}));
|