68 lines
2.6 KiB
TypeScript
68 lines
2.6 KiB
TypeScript
import { App } from '@inertiajs/react';
|
|
import { renderToStaticMarkup } from 'react-dom/server';
|
|
import { expect, test } from 'vitest';
|
|
import RequisitionForm from '@/pages/requisitions/form';
|
|
import { money, date } from '@/types/procurement';
|
|
|
|
test('incomplete draft restores the supplied line and missing amounts without inventing zero prices', () => {
|
|
const html = renderToStaticMarkup(
|
|
<App
|
|
initialComponent={RequisitionForm}
|
|
initialPage={{
|
|
component: 'requisitions/form',
|
|
url: '/requisicoes/9/editar',
|
|
version: null,
|
|
clearHistory: false,
|
|
encryptHistory: true,
|
|
props: {
|
|
errors: {},
|
|
internalRequisitionReady: true,
|
|
incompleteDraftsAvailable: true,
|
|
costCenters: [],
|
|
requisition: {
|
|
id: 9,
|
|
process_version: 1,
|
|
number: 'QA-DRAFT-9',
|
|
status: 'draft',
|
|
priority: 'normal',
|
|
needed_by: null,
|
|
justification: 'Ini',
|
|
cost_center_id: null,
|
|
subtotal_minor: null,
|
|
tax_minor: null,
|
|
total_minor: null,
|
|
created_at: '2026-11-22',
|
|
items: [],
|
|
steps: [],
|
|
draft_input: {
|
|
incomplete: true,
|
|
values: {
|
|
justification: 'Ini',
|
|
items: [
|
|
{
|
|
description: 'Preparação recuperada',
|
|
quantity: null,
|
|
unit_price: null,
|
|
tax_rate: '16.00',
|
|
},
|
|
],
|
|
},
|
|
},
|
|
},
|
|
},
|
|
}}
|
|
/>,
|
|
);
|
|
expect(html).toContain('Preparação recuperada');
|
|
expect(html).toMatch(/novalidate=""/i);
|
|
expect(html).toContain('Por completar');
|
|
expect(html).not.toContain('value="null"');
|
|
expect(html).not.toContain('value="0.00"');
|
|
});
|
|
|
|
test('unknown money and dates are distinguishable from a genuine zero value', () => {
|
|
expect(money(null)).toBe('Por completar');
|
|
expect(date(null)).toBe('Por completar');
|
|
expect(money(0)).not.toBe('Por completar');
|
|
});
|