@@ -0,0 +1,48 @@
|
||||
import { renderToStaticMarkup } from 'react-dom/server';
|
||||
import { expect, test } from 'vitest';
|
||||
import {
|
||||
RequisitionCategoryFields,
|
||||
requisitionCategoryLabels,
|
||||
} from '@/components/requisition-category-fields';
|
||||
|
||||
test('classification fields explain the native controls and preserve the explicit investment reason', () => {
|
||||
const html = renderToStaticMarkup(
|
||||
<RequisitionCategoryFields
|
||||
index={2}
|
||||
category="capital_equipment"
|
||||
reason="Investimento deliberado"
|
||||
options={requisitionCategoryLabels}
|
||||
onChange={() => {}}
|
||||
/>,
|
||||
);
|
||||
expect(html).toContain('Justificação do investimento');
|
||||
expect(html).toContain('Investimento deliberado');
|
||||
expect(html).toContain('orçamento de investimento');
|
||||
expect(html).toContain('aria-describedby="rq-category-2-help"');
|
||||
expect(html).toContain('Peças sobressalentes');
|
||||
});
|
||||
|
||||
test('legacy classification stays unselected and production guidance requires the published stock catalogue', () => {
|
||||
const legacy = renderToStaticMarkup(
|
||||
<RequisitionCategoryFields
|
||||
index={0}
|
||||
category=""
|
||||
reason=""
|
||||
options={requisitionCategoryLabels}
|
||||
onChange={() => {}}
|
||||
/>,
|
||||
);
|
||||
expect(legacy).toContain('Sem classificação adicional');
|
||||
expect(legacy).toContain('não é inferida');
|
||||
expect(legacy).not.toContain('<textarea');
|
||||
const production = renderToStaticMarkup(
|
||||
<RequisitionCategoryFields
|
||||
index={1}
|
||||
category="production_input"
|
||||
reason=""
|
||||
options={requisitionCategoryLabels}
|
||||
onChange={() => {}}
|
||||
/>,
|
||||
);
|
||||
expect(production).toContain('material de stock no catálogo publicado');
|
||||
});
|
||||
Reference in New Issue
Block a user