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);