Files
compras/scripts/award-task-integration-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

50 lines
2.3 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 routes = [];
for (const role of ['procurement', 'department_head', 'finance']) {
const viewer = client();
await viewer.enter(role);
const dashboard = await viewer.request('/dashboard');
const context = dashboard.page?.props.workContext ?? dashboard.page?.props.context;
if (context?.enforced) {
assert.ok(context.available?.includes('procurement.internal'));
assert.equal((await viewer.request('/contexto', 'POST', { area: 'procurement', option: 'procurement.internal' })).status, 302);
}
const response = await viewer.request('/requisicoes/tarefas?module=purchases');
assert.equal(response.status, 200);
assert.equal(response.page.props.filters.module, 'purchases');
const rows = response.page.props.tasks.data;
assert.ok(rows.every(row => row.module === 'purchases'));
const awards = rows.filter(row => ['award_approve', 'order_issue_review'].includes(row.task));
for (const task of awards) {
const detail = await viewer.request(task.href);
assert.equal(detail.status, 200);
assert.equal(detail.page.props[task.task === 'award_approve' ? 'canDecide' : 'canIssue'], true);
}
routes.push({ role, total_purchase_tasks: response.page.props.tasks.total, shown_award_tasks: awards.length, result: 'passed' });
}
await fs.writeFile('docs/proofs/award-task-integration-http.json', JSON.stringify({
checked_at: new Date().toISOString(), environment: base, routes, existing_accounts_used: true,
business_commands: false, accounts_or_grants_changed: false, visual_review: false,
note: 'Only current first-page tasks are followed; disposable tests cover pending approval and issuance.'
}, null, 2));
console.log('Encaminhamento de adjudicacoes conferido com o ambito actual dos perfis existentes.');
` +
'})()',
)(fs, assert);