@@ -0,0 +1,74 @@
|
||||
import { App } from '@inertiajs/react';
|
||||
import type { ComponentProps } from 'react';
|
||||
import { renderToStaticMarkup } from 'react-dom/server';
|
||||
import { expect, test } from 'vitest';
|
||||
import RequisitionShow from '@/pages/requisitions/show';
|
||||
|
||||
test.each([false, true])(
|
||||
'draft review keeps advisory submission and exposes audit navigation only with its explicit capability (%s)',
|
||||
(canReadAuditMetadata) => {
|
||||
const props: ComponentProps<typeof RequisitionShow> = {
|
||||
requisition: {
|
||||
id: 1,
|
||||
number: 'REQ-QA-1',
|
||||
status: 'draft',
|
||||
priority: 'normal',
|
||||
needed_by: '2026-12-01',
|
||||
justification: 'Somente dados sintéticos',
|
||||
cost_center_id: 1,
|
||||
subtotal_minor: 10000,
|
||||
tax_minor: 0,
|
||||
total_minor: 10000,
|
||||
created_at: '2026-11-27T10:00:00Z',
|
||||
items: [],
|
||||
steps: [],
|
||||
},
|
||||
comparisonPolicy: {
|
||||
revision: 1,
|
||||
configured: false,
|
||||
minimum_proposals: 3,
|
||||
minimum_evaluators: 1,
|
||||
weights: {
|
||||
price: 40,
|
||||
quality: 20,
|
||||
delivery: 20,
|
||||
history: 10,
|
||||
payment: 10,
|
||||
},
|
||||
},
|
||||
canEdit: true,
|
||||
canReadAuditMetadata,
|
||||
canDecide: false,
|
||||
conflictBlocked: false,
|
||||
audit: [],
|
||||
duplicateHints: {
|
||||
matches: [{ id: 2, number: 'REQ-QA-2', status: 'pending' }],
|
||||
complete: false,
|
||||
},
|
||||
};
|
||||
function Screen() {
|
||||
return <RequisitionShow {...props} />;
|
||||
}
|
||||
const html = renderToStaticMarkup(
|
||||
<App
|
||||
initialComponent={Screen}
|
||||
initialPage={{
|
||||
component: 'requisitions/show',
|
||||
url: '/requisicoes/1',
|
||||
version: 'qa',
|
||||
clearHistory: false,
|
||||
encryptHistory: true,
|
||||
props: { errors: {} },
|
||||
}}
|
||||
/>,
|
||||
);
|
||||
expect(html).toContain('Conferir possíveis pedidos repetidos');
|
||||
expect(html).toContain('href="/requisicoes/2"');
|
||||
expect(html).toContain('não bloqueia a submissão');
|
||||
expect(html).toContain('100 candidatos');
|
||||
expect(html).toContain('Submeter');
|
||||
expect(
|
||||
html.includes('/auditoria/eventos?request_reference=REQ-QA-1'),
|
||||
).toBe(canReadAuditMetadata);
|
||||
},
|
||||
);
|
||||
Reference in New Issue
Block a user