Files
compras/scripts/inventory-pagination-http.mjs
T
nalaandClaude Opus 5.5 ec934455e7 Aplicar Pint e formatação de frontend; delimitar o âmbito do lint
Só formatação automática (pint, vp check --fix), sem alterar comportamento.
Excluídos da formatação os registos e artefactos com bytes fixos: docs/,
integrations/, storage/, tmp/, output/, resources/data/, tests/Fixtures/,
compras-release.json e AGENTS*.md. Scripts operacionais, integrations e
auxiliares de teste ficam fora do lint (usam new Function; limpeza na fase 2).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 23:01:42 +02:00

44 lines
2.4 KiB
JavaScript

import fs from 'node:fs/promises';
import assert from 'node:assert/strict';
const source = await fs.readFile(
'scripts/supplier-evaluation-check.mjs',
'utf8',
);
const common = source.slice(
source.indexOf('const base ='),
source.indexOf('const author ='),
);
await new Function(
'fs',
'assert',
'return (async()=>{' +
common +
`
const records=[];
for(const [role,expected] of [['admin',200],['warehouse',200],['procurement',403],['finance',403]]) {
const viewer=client();await viewer.enter(role);
assert.equal((await viewer.request('/contexto','POST',{area:'procurement',option:'procurement.internal'})).status,302);
for(const path of ['/stock/ocorrencias','/stock/estornos']) {
const result=await viewer.request(path);assert.equal(result.status,expected);
if(expected===200) {
assert.equal(result.page.encryptHistory,true);assert.equal(result.page.props.recordPagination.total,0);
assert.deepEqual(result.page.props.records,[]);assert.deepEqual(result.page.props.filters,{search:'',state:''});
assert.equal(result.page.props.capabilities.prepare,false);assert.equal(result.page.props.capabilities.review,false);
assert.equal(result.page.props.capabilities.execute,role==='warehouse');
const filtered=await viewer.request(path+'?search=TEST&state=approved');assert.equal(filtered.status,200);
assert.equal(filtered.page.props.recordPagination.total,0);
assert.equal((await viewer.request(path+'?records_page=0')).status,422);
assert.equal((await viewer.request(path+'?state=unknown')).status,422);
}
records.push({role,path,status:result.status});
}
}
await fs.writeFile('docs/proofs/inventory-pagination-http.json',JSON.stringify({checked_at:new Date().toISOString(),environment:base,result:'passed',records,
business_commands:false,accounts_or_grants_changed:false,sgf_installation_changed:false,visual_review:false,
coverage:'Pilot access and empty paginated/filtered lists; pending processes, native corrections and old sources tested in disposable databases.'},null,2));
console.log('Ocorrências e estornos paginados conferidos sem decisões ou movimentos novos no piloto.');
` +
'})()',
)(fs, assert);