67 lines
2.6 KiB
TypeScript
67 lines
2.6 KiB
TypeScript
import { App } from '@inertiajs/react';
|
|
import { renderToStaticMarkup } from 'react-dom/server';
|
|
import { expect, test } from 'vitest';
|
|
import Availability from '@/pages/stock/availability';
|
|
|
|
test.each([true, false])(
|
|
'availability explains the actual reservation capability and preserves unknown balances (%s)',
|
|
(ready) => {
|
|
const Screen = () => (
|
|
<Availability
|
|
filters={{ warehouse_id: 1 }}
|
|
warehouses={[]}
|
|
warehouse={{ name: 'Armazém QA' }}
|
|
checkedAt="2026-11-28T12:00:00Z"
|
|
planningVisible={false}
|
|
reservationsAvailable={ready}
|
|
rows={{
|
|
total: 1,
|
|
prev_page_url: null,
|
|
next_page_url: null,
|
|
data: [
|
|
{
|
|
id: 1,
|
|
code: 'QA-1',
|
|
name: 'Material sintético',
|
|
unit: 'un',
|
|
physical_milli: 10000,
|
|
usable_milli: 10000,
|
|
blocked_milli: null,
|
|
lot_control: false,
|
|
reconciled: true,
|
|
planned_milli: null,
|
|
minimum_milli: null,
|
|
at_minimum: false,
|
|
physical_commitment_milli: ready ? 3000 : null,
|
|
free_milli: ready ? 7000 : null,
|
|
},
|
|
],
|
|
}}
|
|
/>
|
|
);
|
|
const html = renderToStaticMarkup(
|
|
<App
|
|
initialComponent={Screen}
|
|
initialPage={{
|
|
component: 'stock/availability',
|
|
url: '/stock/disponibilidade?warehouse_id=1',
|
|
version: null,
|
|
props: { errors: {} },
|
|
}}
|
|
/>,
|
|
).replace(/\s+/g, ' ');
|
|
expect(html).toContain('data-query-form="true"');
|
|
expect(html).not.toContain('ainda não estão implementados');
|
|
if (ready) {
|
|
expect(html).toContain('menos as reservas físicas registadas');
|
|
expect(html).not.toContain('Saldo livre por determinar');
|
|
} else {
|
|
expect(html).toContain(
|
|
'reservas físicas não estão disponíveis nesta consulta',
|
|
);
|
|
expect(html).toContain('Saldo livre por determinar');
|
|
}
|
|
expect(html).toContain('Sem acesso ao planeamento');
|
|
},
|
|
);
|