commit compras1 2911
tests / ci (push) Waiting to run

This commit is contained in:
2026-11-29 05:28:30 +02:00
parent 1ddabbbdcc
commit 448948a487
137 changed files with 9481 additions and 1926 deletions
+59
View File
@@ -60,6 +60,21 @@ export async function verifyOfficePurchaseHttp(origin, fixture, readState, progr
current = await state();
const requestId = current.request.id;
const lineId = current.request.items[0].id;
let capital = null;
if (office.capital_register) {
await post(buyer, '/projectos-imobilizado', { operation_key: crypto.randomUUID(), record_key: null, version: 0,
type: 'project', code: office.capital_register.code, name: 'Projecto exclusivamente sintético do percurso HTTP',
department_id: office.capital_register.department_id, equipment_id: null, reference: 'Origem documental fictícia de ensaio',
state: 'active', reason: 'Cadastro próprio de Compras para conferir rastreabilidade sem dados reais' });
const register = await buyer.page('/projectos-imobilizado', 'equipment/capital-register');
capital = register.props.records.data.find(row => row.data.code === office.capital_register.code);
check(capital !== undefined && capital.version === 1, 'own project created through native HTTP');
const choices = await owner.page(`/requisicoes/${requestId}/projectos-imobilizado`, 'requisitions/capital-assignments');
check(choices.props.canWrite && choices.props.choices.data.some(row => row.id === capital.id), 'request owner sees the native capital destination');
await post(owner, `/requisicoes/${requestId}/projectos-imobilizado`, { operation_key: crypto.randomUUID(), version: 0,
item_id: lineId, capital_id: capital.id, reason: 'Destino explícito da linha para o projecto estritamente sintético' });
check((await owner.request('/projectos-imobilizado')).status === 403, 'assignment visibility does not grant the requester access to the register');
}
const accountPage = await owner.page(`/requisicoes/${requestId}/contas`, 'requisitions/accounts');
const account = accountPage.props.accounts.data[0];
check(account !== undefined, 'actual common movement account available');
@@ -135,8 +150,32 @@ export async function verifyOfficePurchaseHttp(origin, fixture, readState, progr
current = await state();
check(current.order.id === orderId && current.financial_fingerprint === issued, 'order replay has no financial or document effect');
check(Number(current.order.total_minor) === 10000 && current.order.account_assignments[lineId].data.allocations[0].account.id === account.id, 'order preserves exact amount and native chart attribution');
check(current.order.budget_checked === true, 'new order preserves the budget authority confirmation already returned at issuance');
if (capital) check(current.order.capital_assignments[lineId].snapshot.source.record_key === capital.record_key
&& current.order.capital_assignments[lineId].snapshot.source.version === 1, 'issued order preserves the exact native project version');
const financialDocumentsHref = `/facturas?purchase_order_id=${orderId}#invoice-documents`;
const financeOrder = await finance.page(`/ordens/${orderId}`, 'purchases/show');
check(financeOrder.props.financialDocumentsHref === financialDocumentsHref
&& financeOrder.props.relatedProcesses.some(source => source.id === requestId && source.href === `/requisicoes/${requestId}/processo`), 'order navigation preserves exact financial and process context');
const printRoute = `/ordens/${orderId}/imprimir`;
const printHeaders = { 'X-Inertia': 'true', ...(financeOrder.version === null ? {} : { 'X-Inertia-Version': financeOrder.version }) };
const printNavigation = await finance.request(printRoute, { headers: printHeaders });
check(printNavigation.status === 409 && printNavigation.headers.get('x-inertia-location') === printRoute, 'authorised print navigation requests the complete HTML document');
const printDocument = await finance.request(printRoute);
check(printDocument.status === 200 && (await printDocument.text()).includes('Controlo orçamental registado na emissão.'), 'native controlled print preserves the actual budget confirmation');
const privatePrint = await owner.request(printRoute, { headers: printHeaders });
check(privatePrint.status === 403 && !privatePrint.headers.has('x-inertia-location'), 'requester receives no print redirect without native order access');
const buyerOrder = await buyer.page(`/ordens/${orderId}`, 'purchases/show');
// This synthetic buyer also has Admin; use the independent Procurement-only reviewer to test redaction.
const independentOrder = await procurementReviewer.page(`/ordens/${orderId}`, 'purchases/show');
check(buyerOrder.props.financialDocumentsHref === financialDocumentsHref && independentOrder.props.financialDocumentsHref === null,
'order financial link follows native Admin/Finance access without Procurement inheritance');
stage('receipt_and_invoice');
const financeReceipt = await finance.page(`/ordens/${orderId}/recepcoes`, 'receipts/order');
const warehouseReceipt = await warehouse.page(`/ordens/${orderId}/recepcoes`, 'receipts/order');
check(financeReceipt.props.financialDocumentsHref === financialDocumentsHref && warehouseReceipt.props.financialDocumentsHref === null,
'receipt navigation exposes financial context only to the native reader');
await post(warehouse, '/stock/artigos', { code: 'HTTP-OFFICE-QA', name: 'Material de escritório HTTP QA', unit: 'un' });
current = await state();
const receipt = { idempotency_key: crypto.randomUUID(), delivery_note: 'HTTP-OFFICE-DELIVERY-QA', received_on: date(0),
@@ -145,6 +184,14 @@ export async function verifyOfficePurchaseHttp(origin, fixture, readState, progr
await post(warehouse, `/ordens/${orderId}/recepcoes`, receipt, 201);
current = await state();
const received = current.financial_fingerprint;
const confirmedReceiptId = current.order.receipts[0].id;
const financialReceiptDetail = await finance.page(`/recepcoes/${confirmedReceiptId}`, 'receipts/show');
const warehouseReceiptDetail = await warehouse.page(`/recepcoes/${confirmedReceiptId}`, 'receipts/show');
check(financialReceiptDetail.props.financialDocumentsHref === financialDocumentsHref
&& warehouseReceiptDetail.props.financialDocumentsHref === null,
'confirmed receipt detail offers the exact financial context only to its native reader');
current = await state();
check(current.financial_fingerprint === received, 'receipt detail consultation preserves financial and stock sources');
await post(warehouse, `/ordens/${orderId}/recepcoes`, receipt, 200);
current = await state();
check(current.financial_fingerprint === received && current.order.receipts.length === 1 && current.stock.movements === 1 && current.stock.quantity_milli === 1000, 'receipt replay preserves one physical movement');
@@ -221,15 +268,27 @@ export async function verifyOfficePurchaseHttp(origin, fixture, readState, progr
const report = await process.json();
check(report.props.stages[7].state === 'restricted' && report.props.stages[8].state === 'restricted'
&& !Object.hasOwn(report.props, 'invoices') && !Object.hasOwn(report.props, 'payments') && !Object.hasOwn(report.props, 'bank_snapshot'), 'requester process does not disclose financial or bank records');
if (capital) {
stage('project_trace');
const beforeTrace = current.financial_fingerprint;
const trace = await finance.page(`/projectos-imobilizado?history=${capital.record_key}`, 'equipment/capital-register');
check(trace.props.trace.orders.data.some(row => row.order_id === orderId), 'project trace reaches its actual issued order');
check(trace.props.trace.receipts.data.some(row => row.order_id === orderId), 'project trace reaches its actual physical receipt');
check(trace.props.history.data[0].record_key === capital.record_key && trace.props.history.data[0].version === 1, 'project history remains its native version');
current = await state();
check(current.financial_fingerprint === beforeTrace, 'project trace consultation changes no financial or stock source');
}
for (const client of Object.values(clients)) await client.logout();
return { checks, native_post_requests: commands, fortify_sessions: Object.keys(clients).length,
request_id: requestId, order_id: orderId, invoice_id: invoiceId, payment_ids: current.payments.map(p => p.id),
request_total_minor: current.request.total_minor, order_total_minor: current.order.total_minor, invoice_total_minor: current.invoice.total_minor,
confirmed_payments_minor: current.payments.map(p => p.amount_minor), outstanding_minor: current.invoice.outstanding_minor,
budget_consumed_minor: current.budget.balance.consumed_minor, budget_available_minor: current.budget.balance.available_minor,
order_budget_checked: current.order.budget_checked,
stock_quantity_milli: current.stock.quantity_milli, stock_movements: current.stock.movements, journals: current.journals,
explicit_finance_category_total_minor: current.analytics.category_attribution.groups.data[0].amount_minor,
all_business_mutations_via_native_http: true, assertions_use_readonly_transactions: true, budget_balance_via_native_http: true,
selector_self_final_approval_refused: selectorRefused, synthetic_only: true,
project_trace: capital ? { record_key: capital.record_key, code: capital.data.code, version: capital.version, order_id: orderId } : null,
real_bank_or_sgf_operations: false, browser_visual_acceptance: false };
}