commit melhorias compras4
tests / ci (push) Canceled after 0s

This commit is contained in:
2026-11-22 16:28:03 +02:00
parent efd97e265b
commit 36dcfdf00c
118 changed files with 6042 additions and 92 deletions
@@ -0,0 +1,82 @@
import { App } from '@inertiajs/react';
import { renderToStaticMarkup } from 'react-dom/server';
import { expect, test } from 'vitest';
import { RequisitionApprovalSettings } from '@/components/requisition-approval-settings';
import { procurementNavigation } from '@/lib/procurement-navigation';
function render(ready: boolean) {
return renderToStaticMarkup(
<App
initialComponent={RequisitionApprovalSettings}
initialPage={{
component: 'company/parameters',
url: '/administracao/parametrizacao',
version: null,
clearHistory: false,
encryptHistory: true,
props: {
errors: {},
ready,
version: 4,
profiles: [
{
id: 7,
name: 'Direcção QA',
permissions: ['requisition_approve'],
},
{
id: 8,
name: 'Consulta revogada QA',
permissions: ['requester'],
},
],
costCenters: [{ id: 1, code: 'QA', name: 'Centro QA' }],
plan: {
revision: 2,
enabled: true,
quorum: 'one_eligible',
levels: [
{
name: 'Conferência <QA>',
profile_ids: [7, 8],
scope: 'company',
min_minor: 11601,
categories: ['Material'],
cost_center_ids: [1],
},
],
},
},
}}
/>,
);
}
test('approval settings retain exact threshold and selected revoked profiles so the administrator can reconcile the plan', () => {
const html = render(true);
expect(html).toContain('116.01');
expect(html).toContain('Conferência &lt;QA&gt;');
expect(html).toContain('Direcção QA');
expect(html).toContain('Consulta revogada QA');
expect(html).toContain('Sem competência de aprovação actualmente');
expect(html).toContain('basta um aprovador');
expect(html).toContain('apenas a novas submissões');
});
test('unavailable capability explains the existing circuit without offering a nonfunctional plan form', () => {
const html = render(false);
expect(html).toContain('O circuito actual permanece em vigor');
expect(html).not.toContain('<form');
});
test('a configured approver gets approval navigation without supplier or finance access links', () => {
const entries = procurementNavigation(
['requisition_approve'],
false,
).flatMap((group) => group.entries);
expect(
entries.some((entry) => entry.path === '/requisicoes?view=approvals'),
).toBe(true);
expect(entries.some((entry) => entry.path === '/facturas')).toBe(false);
expect(entries.some((entry) => entry.path === '/fornecedores')).toBe(false);
});