commit compras5 2711
tests / ci (push) Waiting to run

This commit is contained in:
2026-11-27 20:19:21 +02:00
parent 7486007fcf
commit d58b75c87a
57 changed files with 2803 additions and 116 deletions
+108
View File
@@ -0,0 +1,108 @@
import { App } from '@inertiajs/react';
import { renderToStaticMarkup } from 'react-dom/server';
import { expect, test } from 'vitest';
import ExpenseAllocation from '../../resources/js/pages/payments/expense-allocation';
import { ProcurementCategoryInsights } from '../../resources/js/components/procurement-category-insights';
function render(canWrite: boolean) {
return renderToStaticMarkup(
<App
initialComponent={ExpenseAllocation}
initialPage={{
component: 'payments/expense-allocation',
url: '/pagamentos/1/categorias',
version: null,
clearHistory: false,
encryptHistory: true,
props: {
errors: {},
canWrite,
actorId: 1,
tenantId: 1,
payment: {
id: 1,
invoice_id: 1,
invoice_number: 'FT-QA',
currency: 'MZN',
amount_minor: '4000',
},
categories: ['Material', '<script>Serviços</script>'],
fingerprint: 'a'.repeat(64),
current: {
id: 1,
version: 1,
reason: 'Synthetic explicit allocation',
data: {
allocations: [
{ category: 'Material', amount_minor: '1500' },
],
},
},
history: {
data: [],
prev_page_url: null,
next_page_url: null,
},
},
}}
/>,
);
}
test('read-only financial viewer sees the preserved attribution without a write form', () => {
const html = render(false);
expect(html).toContain('15,00 MZN');
expect(html).not.toContain('<form');
});
test('Finance starts with blank amounts and deliberately chooses whether to reuse the current attribution', () => {
const html = render(true);
expect(html).toContain('Usar a imputação actual como preparação');
expect(html).toContain('&lt;script&gt;Serviços&lt;/script&gt;');
expect(html).not.toContain('value="15.00"');
expect(html).toContain('Guardar imputação');
});
test('category summary preserves unassigned expenses and separates currencies without allocating them automatically', () => {
const html = renderToStaticMarkup(
<ProcurementCategoryInsights
pageHref="/relatorios?from=2026-11-01&supplier_page=2"
data={{
coverage: { allocated: 1, unallocated: 1, indeterminate: 1 },
unassigned: [
{
state: 'unallocated',
currency: 'USD',
count: 1,
amount_minor: '4000',
},
{
state: 'indeterminate',
currency: 'MZN',
count: 1,
amount_minor: '5000',
},
],
groups: {
data: [
{
category: 'Material',
currency: 'MZN',
count: 1,
amount_minor: '1500',
},
],
total: 21,
current_page: 1,
last_page: 2,
},
}}
/>,
);
expect(html).toContain('Despesa não imputada: 40,00 USD');
expect(html).toContain('Imputação indeterminada: 50,00 MZN');
expect(html).toContain('15,00 MZN');
expect(html).toContain('Não há distribuição proporcional automática');
expect(html).toContain('category_page=2');
expect(html).toContain('supplier_page=2');
});
@@ -0,0 +1,42 @@
import { renderToStaticMarkup } from 'react-dom/server';
import { expect, test } from 'vitest';
import { ProcurementContractInsights } from '../../resources/js/components/procurement-contract-insights';
test('contract association keeps unknown legacy orders distinct from orders without an association and payments', () => {
const html = renderToStaticMarkup(
<ProcurementContractInsights
data={{
coverage: { unknown: 1 },
currencies: [
{
classification: 'unknown',
currency: 'MZN',
count: 1,
amount_minor: '10000',
},
{
classification: 'partial',
currency: 'USD',
count: 1,
amount_minor: '20000',
},
{
classification: 'without_contract',
currency: null,
count: 1,
amount_minor: null,
},
],
}}
/>,
);
expect(html).toContain('Associação por determinar');
expect(html).toContain(
'não foram classificadas como compras fora de contrato',
);
expect(html).toContain('Parte das linhas com contrato associado');
expect(html).toContain('100,00 MZN');
expect(html).toContain('200,00 USD');
expect(html).toContain('Indeterminado');
expect(html).toContain('Não representam pagamentos');
});
@@ -3,6 +3,43 @@ import { describe, expect, it } from 'vitest';
import { ProcurementPaymentInsights } from '../../resources/js/components/procurement-payment-insights';
describe('confirmed payment expense', () => {
it('shows supplier identity with exact totals and preserves filters in its independent pagination', () => {
const html = renderToStaticMarkup(
<ProcurementPaymentInsights
pageHref="/relatorios?from=2026-11-01&search=REQ-QA"
data={{
from: null,
to: null,
coverage: {
invoices: 21,
indeterminate: 0,
confirmed_payments: 21,
},
currencies: [],
suppliers: {
data: [
{
supplier_id: 21,
supplier_name: '<script>synthetic</script>',
currency: 'MZN',
count: 1,
amount_minor: '9007199254740993',
},
],
total: 21,
current_page: 2,
last_page: 2,
},
}}
/>,
);
expect(html).toContain('Despesa por fornecedor');
expect(html).toContain('&lt;script&gt;synthetic&lt;/script&gt;');
expect(html).toContain('90.071.992.547.409,93 MZN');
expect(html).toContain('supplier_page=1');
expect(html).toContain('search=REQ-QA');
expect(html).toContain('Página 2 de 2');
});
it('keeps currencies separate and formats amounts without floating point', () => {
const html = renderToStaticMarkup(
<ProcurementPaymentInsights
+29 -1
View File
@@ -105,7 +105,31 @@ test('long review report preserves all proposals, original amounts and finance v
qualification: null,
opening: null,
award: null,
order: null,
order: {
id: 1,
number: 'OC-PARCELA-1',
currency: 'MZN',
total_minor: 4000,
},
orders: [
{
id: 1,
number: 'OC-PARCELA-1',
currency: 'MZN',
total_minor: 4000,
origins: [{ id: 42, number: 'REQ-SINTETICA-42' }],
},
{
id: 2,
number: 'OC-PARCELA-2',
currency: 'MZN',
total_minor: 6000,
origins: [
{ id: 42, number: 'REQ-SINTETICA-42' },
{ id: 43, number: 'REQ-SINTETICA-43' },
],
},
],
fulfilment: {
receipts: [],
finance_visible: false,
@@ -116,6 +140,10 @@ test('long review report preserves all proposals, original amounts and finance v
const html = render(ReviewReport, { report }, 'review');
for (const row of rows) expect(html).toContain(row.reference);
expect(html).toContain('report-fulfilment');
expect(html).toContain('OC-PARCELA-1');
expect(html).toContain('OC-PARCELA-2');
expect(html).toContain('REQ-SINTETICA-43');
expect(html).toContain('sem repartição neste relatório');
expect(html).not.toContain('QA-FACTURA-PRIVADA');
});
test('improvement report preserves details on every visible row without changing their disclosure state', () => {