84 lines
3.2 KiB
TypeScript
84 lines
3.2 KiB
TypeScript
import { App } from '@inertiajs/react';
|
|
import { renderToStaticMarkup } from 'react-dom/server';
|
|
import { expect, test } from 'vitest';
|
|
import ProcurementReports from '@/pages/reports/procurement';
|
|
|
|
test.each([false, true])(
|
|
'report shortcuts have matching sections and preserve the filtered report without exposing absent financial sections (%s)',
|
|
(operational) => {
|
|
const Screen = () => (
|
|
<ProcurementReports
|
|
records={{
|
|
data: [],
|
|
total: 0,
|
|
current_page: 1,
|
|
last_page: 1,
|
|
prev_page_url: null,
|
|
next_page_url: null,
|
|
}}
|
|
counts={{}}
|
|
filters={{ status: 'pending', department_id: 7 }}
|
|
departments={[]}
|
|
generatedAt="2026-11-28T12:00:00Z"
|
|
insights={
|
|
operational
|
|
? {
|
|
method: 'procurement_facts_v1',
|
|
generated_at: '2026-11-28T12:00:00Z',
|
|
processes: 0,
|
|
pending: {
|
|
count: 0,
|
|
unknown_submission_age: 0,
|
|
oldest: [],
|
|
},
|
|
unapproved_past_needed_date: 0,
|
|
approved: {
|
|
count: 0,
|
|
without_registered_quotes: 0,
|
|
without_visible_order: 0,
|
|
},
|
|
}
|
|
: undefined
|
|
}
|
|
/>
|
|
);
|
|
const html = renderToStaticMarkup(
|
|
<App
|
|
initialComponent={Screen}
|
|
initialPage={{
|
|
component: 'reports/procurement',
|
|
url: '/relatorios?status=pending&department_id=7',
|
|
version: null,
|
|
clearHistory: false,
|
|
encryptHistory: true,
|
|
props: { errors: {} },
|
|
}}
|
|
/>,
|
|
);
|
|
expect(html).toContain('aria-label="Secções dos relatórios"');
|
|
expect(html).toContain('href="#report-filters"');
|
|
expect(html).toContain('id="report-filters"');
|
|
// The sticky workspace header previously covered anchor destinations.
|
|
for (const target of html.matchAll(
|
|
/<section\b[^>]*id="report-[^"]+"[^>]*>/g,
|
|
)) {
|
|
expect(target[0]).toContain('tabindex="-1"');
|
|
expect(target[0]).toContain('scroll-mt-24 lg:scroll-mt-72');
|
|
}
|
|
expect(html.includes('href="#report-operational"')).toBe(operational);
|
|
expect(html.includes('id="report-operational"')).toBe(operational);
|
|
for (const absent of [
|
|
'payables',
|
|
'deliveries',
|
|
'payments',
|
|
'contracts',
|
|
]) {
|
|
expect(html).not.toContain(`href="#report-${absent}"`);
|
|
expect(html).not.toContain(`id="report-${absent}"`);
|
|
}
|
|
expect(html).toContain(
|
|
'/relatorios/compras.csv?status=pending&department_id=7',
|
|
);
|
|
},
|
|
);
|