@@ -0,0 +1,76 @@
|
||||
import { renderToStaticMarkup } from 'react-dom/server';
|
||||
import { expect, test } from 'vitest';
|
||||
import {
|
||||
ProcurementDeliveryInsights,
|
||||
type DeliveryInsights,
|
||||
} from '@/components/procurement-delivery-insights';
|
||||
|
||||
test('delivery review preserves unknown dates, native quantities and independent filters', () => {
|
||||
const data: DeliveryInsights = {
|
||||
view: 'attention',
|
||||
coverage: { unknown: 1 },
|
||||
pending_lines: 1,
|
||||
unknown_lines: 1,
|
||||
unverified_receipt_lines: 1,
|
||||
records: {
|
||||
current_page: 2,
|
||||
last_page: 3,
|
||||
total: 41,
|
||||
data: [
|
||||
{
|
||||
id: 4,
|
||||
number: 'OC-QA-4',
|
||||
state: 'unknown',
|
||||
pending_lines: 1,
|
||||
unknown_lines: 1,
|
||||
unverified_receipt_lines: 1,
|
||||
late_days: null,
|
||||
quality_pending: false,
|
||||
href: '/ordens/4',
|
||||
late_lines: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
const html = renderToStaticMarkup(
|
||||
<ProcurementDeliveryInsights
|
||||
data={data}
|
||||
pageHref="/relatorios?status=approved&supplier_page=2"
|
||||
exportHref="/relatorios/entregas.csv?status=approved"
|
||||
/>,
|
||||
);
|
||||
expect(html).toContain('Maior atraso documentado: por determinar');
|
||||
expect(html).not.toContain('0 dia(s)');
|
||||
expect(html).toContain('datas de recepção');
|
||||
expect(html).toContain(
|
||||
'status=approved&supplier_page=2&delivery_state=attention&delivery_page=3',
|
||||
);
|
||||
expect(html).toContain('/relatorios/entregas.csv?status=approved');
|
||||
data.records.data[0] = {
|
||||
...data.records.data[0],
|
||||
state: 'completed_late',
|
||||
late_days: 2,
|
||||
quality_pending: true,
|
||||
late_lines: [
|
||||
{
|
||||
id: 8,
|
||||
description: 'Peça & suporte',
|
||||
unit: 'kg',
|
||||
promised_on: '2026-11-20',
|
||||
completed_on: '2026-11-22',
|
||||
pending_quantity: '0.000',
|
||||
},
|
||||
],
|
||||
};
|
||||
const completed = renderToStaticMarkup(
|
||||
<ProcurementDeliveryInsights
|
||||
data={data}
|
||||
pageHref="/relatorios"
|
||||
exportHref="/relatorios/entregas.csv"
|
||||
/>,
|
||||
);
|
||||
expect(completed).toContain('2 dia(s)');
|
||||
expect(completed).toContain('qualidade ou aceitação permanece pendente');
|
||||
expect(completed).toContain('0.000 kg');
|
||||
expect(completed).toContain('Peça & suporte');
|
||||
});
|
||||
Reference in New Issue
Block a user