import { App } from '@inertiajs/react';
import { renderToStaticMarkup } from 'react-dom/server';
import { expect, test } from 'vitest';
import AgreementFollowup from '@/pages/supply/agreement-followup';
test.each([null, 0])(
'global contract report keeps its scope and distinguishes absent limit from %s',
(limit) => {
const html = renderToStaticMarkup(
,
);
expect(html).toContain('Vigência dos contratos globais');
expect(html).toContain('kind=contract');
expect(html).toContain('2 artigo(s) aprovado(s) ligado(s)');
expect(html).toContain('Consultar artigos ligados');
expect(html).toContain('linked_contract_key=header');
expect(html).toContain('Cada ordem pode usar o limite completo');
expect(html).toContain('Não gera ordens automáticas');
expect(html).not.toContain('Código não disponível');
expect(html).not.toContain('href="/unused"');
expect(html.includes('Limite global por ordem: Não definido')).toBe(
limit === null,
);
},
);
test('agreement followup keeps explicit filters in the csv and distinguishes documentary vigency from purchase authority', () => {
const html = renderToStaticMarkup(
',
supplier: 'Fornecedor sintético',
item_code: 'TEST-ITEM',
item: 'Artigo',
warehouse: 'Armazém',
valid_from: null,
valid_until: null,
validity: 'unknown',
approved_policies: 2,
href: '/compras/fornecimento?view=agreements&record_id=4',
policies_href:
'/compras/fornecimento?view=calendar&linked_agreement_key=synthetic',
},
],
},
errors: {},
},
clearHistory: false,
encryptHistory: true,
}}
initialComponent={AgreementFollowup}
/>,
);
expect(html).toContain('Vigência dos acordos');
expect(html).toContain('não renova acordos');
expect(html).toContain('search=FROZEN');
expect(html).toContain('expires_by=2026-11-30');
expect(html).toContain('política(s) aprovada(s) ligada(s)');
expect(html).toContain('Datas indeterminadas');
expect(html).toContain('Início: Não disponível');
expect(html).toContain('<unsafe>');
expect(html).not.toContain('');
expect(html).toContain('linked_agreement_key=synthetic');
});