@@ -0,0 +1,66 @@
|
||||
import { App } from '@inertiajs/react';
|
||||
import type { ComponentProps } from 'react';
|
||||
import { renderToStaticMarkup } from 'react-dom/server';
|
||||
import { expect, test } from 'vitest';
|
||||
import ApprovalTimeouts from '@/pages/organization/approval-timeouts';
|
||||
|
||||
test('optional urgent timing has no default values and keeps explicit recipients visible for urgent-only escalation', () => {
|
||||
const props: ComponentProps<typeof ApprovalTimeouts> = {
|
||||
actorId: 1,
|
||||
tenantId: 1,
|
||||
roles: { department_head: 'Chefia' },
|
||||
profiles: [{ id: 2, name: 'Perfil sintético' }],
|
||||
history: { data: [], prev_page_url: null, next_page_url: null },
|
||||
current: {
|
||||
id: 3,
|
||||
version: 1,
|
||||
state: 'active',
|
||||
reason: 'Política sintética',
|
||||
data: {
|
||||
enabled: true,
|
||||
levels: [
|
||||
{
|
||||
role: 'department_head',
|
||||
expire_minutes: 30,
|
||||
reminder_minutes: 10,
|
||||
escalation_minutes: null,
|
||||
profile_ids: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
};
|
||||
function render() {
|
||||
function Screen() {
|
||||
return <ApprovalTimeouts {...props} />;
|
||||
}
|
||||
return renderToStaticMarkup(
|
||||
<App
|
||||
initialComponent={Screen}
|
||||
initialPage={{
|
||||
component: 'organization/approval-timeouts',
|
||||
url: '/administracao/prazos-aprovacao',
|
||||
version: 'qa',
|
||||
clearHistory: false,
|
||||
encryptHistory: true,
|
||||
props: { errors: {} },
|
||||
}}
|
||||
/>,
|
||||
);
|
||||
}
|
||||
const unconfigured = render();
|
||||
expect(unconfigured).toContain('Prazos reduzidos para urgências');
|
||||
expect(unconfigured).not.toMatch(/<details[^>]*open=/);
|
||||
expect(unconfigured).not.toContain('Perfis destinatários do escalamento');
|
||||
props.current!.data.levels[0] = {
|
||||
...props.current!.data.levels[0],
|
||||
urgent_expire_minutes: 5,
|
||||
urgent_reminder_minutes: 1,
|
||||
urgent_escalation_minutes: 2,
|
||||
profile_ids: [2],
|
||||
};
|
||||
const configured = render();
|
||||
expect(configured).toMatch(/<details[^>]*open=/);
|
||||
expect(configured).toContain('Perfis destinatários do escalamento');
|
||||
expect(configured).toContain('Perfil sintético');
|
||||
});
|
||||
Reference in New Issue
Block a user