63 lines
2.3 KiB
TypeScript
63 lines
2.3 KiB
TypeScript
import { App } from '@inertiajs/react';
|
|
import type { Page } from '@inertiajs/core';
|
|
import { renderToString } from 'react-dom/server';
|
|
import { expect, test } from 'vitest';
|
|
import { ProcurementOperationalInsights } from '@/components/procurement-operational-insights';
|
|
import type { ProcurementInsights } from '@/components/procurement-operational-insights';
|
|
|
|
const base = {
|
|
component: 'reports/procurement',
|
|
url: '/relatorios',
|
|
version: 'insights',
|
|
props: { errors: {} },
|
|
clearHistory: false,
|
|
encryptHistory: true,
|
|
} satisfies Page;
|
|
|
|
test.each([0, 2])(
|
|
'procurement reading renders scope %i and source links with honest limitations',
|
|
(processes) => {
|
|
const data: ProcurementInsights = {
|
|
method: 'procurement_facts_v1',
|
|
generated_at: '2026-10-30T12:00:00Z',
|
|
processes,
|
|
pending: {
|
|
count: 1,
|
|
unknown_submission_age: 0,
|
|
oldest: [
|
|
{
|
|
id: 42,
|
|
number: 'REQ-42',
|
|
submitted_at: '2026-10-23T12:00:00Z',
|
|
days_since_submission: 7,
|
|
href: '/requisicoes/42/processo',
|
|
},
|
|
],
|
|
},
|
|
unapproved_past_needed_date: 1,
|
|
approved: {
|
|
count: 1,
|
|
without_registered_quotes: 0,
|
|
without_visible_order: 0,
|
|
},
|
|
};
|
|
function Screen() {
|
|
return <ProcurementOperationalInsights data={data} />;
|
|
}
|
|
const html = renderToString(
|
|
<App initialPage={base} initialComponent={Screen} />,
|
|
).replace(/<!--.*?-->/g, '');
|
|
expect(html).toContain(`${processes} requisições autorizadas`);
|
|
if (processes === 0) {
|
|
expect(html).toContain('Sem requisições neste âmbito');
|
|
expect(html).not.toContain('REQ-42');
|
|
} else {
|
|
expect(html).toContain('/requisicoes/42/processo');
|
|
expect(html).toContain('7 dias de calendário');
|
|
expect(html).toContain('não comprova atraso de entrega');
|
|
expect(html).toContain('não significam propostas válidas');
|
|
}
|
|
expect(html).not.toContain('<form');
|
|
},
|
|
);
|