136 lines
6.0 KiB
TypeScript
136 lines
6.0 KiB
TypeScript
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(
|
|
<App
|
|
initialPage={{
|
|
component: 'supply/agreement-followup',
|
|
url: '/compras/acordos/vigencia?kind=contract',
|
|
version: null,
|
|
props: {
|
|
kind: 'contract',
|
|
asOf: '2026-11-22',
|
|
filters: {
|
|
search: '',
|
|
validity: 'current',
|
|
expires_by: '',
|
|
},
|
|
records: {
|
|
total: 1,
|
|
current_page: 1,
|
|
last_page: 1,
|
|
prev_page_url: null,
|
|
next_page_url: null,
|
|
data: [
|
|
{
|
|
id: 1,
|
|
record_key: 'header',
|
|
version: 2,
|
|
reference: 'CONTRATO-QA',
|
|
supplier: 'Fornecedor sintético',
|
|
currency: 'MZN',
|
|
max_order_value_minor: limit,
|
|
periodicity_days: null,
|
|
approved_articles: 2,
|
|
valid_from: '2026-11-22',
|
|
valid_until: '2026-12-22',
|
|
validity: 'current',
|
|
approved_policies: 0,
|
|
item_code: null,
|
|
item: null,
|
|
warehouse: null,
|
|
href: '/compras/fornecimento?view=contracts&record_id=1',
|
|
articles_href:
|
|
'/compras/fornecimento?view=agreements&linked_contract_key=header',
|
|
policies_href: '/unused',
|
|
},
|
|
],
|
|
},
|
|
},
|
|
clearHistory: false,
|
|
encryptHistory: true,
|
|
}}
|
|
initialComponent={AgreementFollowup}
|
|
/>,
|
|
);
|
|
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(
|
|
<App
|
|
initialPage={{
|
|
component: 'supply/agreement-followup',
|
|
url: '/compras/acordos/vigencia',
|
|
version: null,
|
|
props: {
|
|
asOf: '2026-11-21',
|
|
filters: {
|
|
search: 'FROZEN',
|
|
validity: 'expired',
|
|
expires_by: '2026-11-30',
|
|
},
|
|
records: {
|
|
total: 27,
|
|
current_page: 2,
|
|
last_page: 2,
|
|
prev_page_url:
|
|
'/compras/acordos/vigencia?page=1&search=FROZEN',
|
|
next_page_url: null,
|
|
data: [
|
|
{
|
|
id: 4,
|
|
record_key: 'synthetic',
|
|
version: 2,
|
|
reference: '<unsafe>',
|
|
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('<unsafe>');
|
|
expect(html).toContain('linked_agreement_key=synthetic');
|
|
});
|