@@ -27,7 +27,7 @@ const order = {
|
||||
};
|
||||
|
||||
function render(
|
||||
component: typeof Orders | typeof Show,
|
||||
component: Parameters<typeof App>[0]['initialComponent'],
|
||||
props: Record<string, unknown>,
|
||||
) {
|
||||
return renderToStaticMarkup(
|
||||
@@ -64,3 +64,117 @@ test('incomplete detail identifies the missing original and preserves documented
|
||||
expect(html).toContain('/ordens/1/imprimir');
|
||||
expect(html).not.toContain('Aprovações do valor final');
|
||||
});
|
||||
|
||||
test.each([
|
||||
{
|
||||
state: 'issued',
|
||||
enabled: true,
|
||||
canRequest: true,
|
||||
form: true,
|
||||
text: 'Ordem emitida.',
|
||||
},
|
||||
{
|
||||
state: 'issued',
|
||||
enabled: true,
|
||||
canRequest: false,
|
||||
form: false,
|
||||
text: 'Ordem emitida.',
|
||||
},
|
||||
{
|
||||
state: 'cancellation_pending',
|
||||
enabled: false,
|
||||
canRequest: false,
|
||||
form: false,
|
||||
text: 'Cancelamento pendente.',
|
||||
},
|
||||
{
|
||||
state: 'cancelled',
|
||||
enabled: true,
|
||||
canRequest: false,
|
||||
form: false,
|
||||
text: 'Ordem cancelada.',
|
||||
},
|
||||
])(
|
||||
'legacy detail preserves operational cancellation status and server authority ($state/$canRequest)',
|
||||
({ state, enabled, canRequest, form, text }) => {
|
||||
const html = render(Show, {
|
||||
order,
|
||||
history: [],
|
||||
snapshotComplete: false,
|
||||
orderCancellation: { state, enabled, canRequest },
|
||||
});
|
||||
expect(html).toContain('Estado operacional e cancelamento');
|
||||
expect(html).toContain(text);
|
||||
expect(html.includes('Pedir cancelamento integral')).toBe(form);
|
||||
expect(html).toContain('Documento original incompleto');
|
||||
expect(html).toContain('Artigo preservado');
|
||||
expect(html).toContain('100,00');
|
||||
expect(html).not.toContain('Aprovações do valor final');
|
||||
},
|
||||
);
|
||||
|
||||
test.each([false, true])(
|
||||
'existing order documents expose only server-authorised related destinations (%s)',
|
||||
(finance) => {
|
||||
const html = render(Show, {
|
||||
order,
|
||||
history: [],
|
||||
snapshotComplete: false,
|
||||
financialDocumentsHref: finance
|
||||
? '/facturas?purchase_order_id=1'
|
||||
: null,
|
||||
relatedProcesses: [
|
||||
{ id: 4, number: 'REQ<QA>', href: '/requisicoes/4/processo' },
|
||||
{
|
||||
id: 7,
|
||||
number: 'REQ-SECOND-QA',
|
||||
href: '/requisicoes/7/processo',
|
||||
},
|
||||
],
|
||||
});
|
||||
expect(html).toContain('Documentos relacionados da ordem');
|
||||
expect(html).toContain('href="/requisicoes/4/processo"');
|
||||
expect(html).toContain('href="/requisicoes/7/processo"');
|
||||
expect(html).toContain('REQ<QA>');
|
||||
expect(html.includes('/facturas?purchase_order_id=1')).toBe(finance);
|
||||
expect(html).toContain('Artigo preservado');
|
||||
},
|
||||
);
|
||||
import ReceiptShow from '@/pages/receipts/show';
|
||||
|
||||
test.each([false, true])(
|
||||
'receipt detail retains the original and only offers the financial link supplied by the server (%s)',
|
||||
(finance) => {
|
||||
const html = render(ReceiptShow, {
|
||||
receipt: {
|
||||
id: 8,
|
||||
number: 'REC-QA',
|
||||
purchase_order_id: 1,
|
||||
delivery_note: 'GUIA-QA',
|
||||
received_on: '2026-11-28',
|
||||
confirmed_at: '2026-11-28T12:00:00Z',
|
||||
status: 'complete',
|
||||
snapshot: {
|
||||
order: { id: 1, number: 'OC-QA' },
|
||||
supplier: { name: 'Fornecedor QA' },
|
||||
receiver: { name: 'Armazém QA' },
|
||||
warehouse: null,
|
||||
},
|
||||
items: [],
|
||||
},
|
||||
movements: [],
|
||||
financialDocumentsHref: finance
|
||||
? '/facturas?purchase_order_id=1#invoice-documents'
|
||||
: null,
|
||||
});
|
||||
expect(
|
||||
html.includes(
|
||||
'href="/facturas?purchase_order_id=1#invoice-documents"',
|
||||
),
|
||||
).toBe(finance);
|
||||
expect(html).toContain('GUIA-QA');
|
||||
expect(html).toContain('Recepção total aceite');
|
||||
expect(html).toContain('/recepcoes/8/imprimir');
|
||||
expect(html).toContain('/ordens/1/recepcoes');
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user