Files
compras/tests/frontend/procurement-payment-insights.test.tsx
T
nala d58b75c87a
tests / ci (push) Waiting to run
commit compras5 2711
2026-11-27 20:19:21 +02:00

89 lines
3.4 KiB
TypeScript

import { renderToStaticMarkup } from 'react-dom/server';
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
data={{
from: '2026-11-01',
to: '2026-11-27',
coverage: {
invoices: 3,
indeterminate: 1,
confirmed_payments: 2,
},
currencies: [
{
currency: 'MZN',
count: 1,
amount_minor: '9007199254740993',
},
{ currency: 'USD', count: 1, amount_minor: '1200' },
],
}}
/>,
);
expect(html).toContain('90071992547409,93 MZN');
expect(html).toContain('12,00 USD');
expect(html).toContain('valores apresentados são parciais');
expect(html).toContain('pela data de confirmação');
});
it('does not describe undetermined history as a zero expense', () => {
const html = renderToStaticMarkup(
<ProcurementPaymentInsights
data={{
from: null,
to: null,
coverage: {
invoices: 1,
indeterminate: 1,
confirmed_payments: 0,
},
currencies: [],
}}
/>,
);
expect(html).toContain('histórico indeterminado');
expect(html).not.toContain('0,00');
});
});