Files
compras/scripts/warehouse-exchange-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

46 lines
1.9 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 viewer = client();
await viewer.enter('admin');
const dashboard = await viewer.request('/dashboard');
if (dashboard.page?.props.context?.enforced) {
await viewer.request('/contexto', 'POST', { area: 'procurement', option: 'procurement.internal' });
}
const first = await viewer.request('/stock/integracao/entregas?limit=1', 'GET', undefined, false);
assert.equal(first.status, 200);
const data = JSON.parse(first.text);
assert.equal(data.schema, 'sgc.warehouse.fulfilment-feed.v1');
assert.ok(Array.isArray(data.items) && data.items.length <= 1);
assert.equal(typeof data.has_more, 'boolean');
assert.equal(typeof data.next_cursor, 'string');
const next = await viewer.request('/stock/integracao/entregas?cursor=' + encodeURIComponent(data.next_cursor), 'GET', undefined, false);
assert.equal(next.status, 200);
assert.equal(JSON.parse(next.text).schema, data.schema);
const invalid = await viewer.request('/stock/integracao/entregas?limit=101');
assert.equal(invalid.status, 422);
await fs.writeFile('docs/proofs/warehouse-exchange-http.json', JSON.stringify({
checked_at: new Date().toISOString(), environment: base, result: 'passed',
cursor_roundtrip: true, limit_validated: true, observed_first_page_items: data.items.length,
business_commands: false, accounts_or_grants_changed: false,
sgf_installation_changed: false, visual_review: false
}, null, 2));
console.log('Consulta de integração do armazém e cursor conferidos em HTTP.');
` +
'})()',
)(fs, assert);