import { App, router } from '@inertiajs/react'; import { renderToStaticMarkup } from 'react-dom/server'; import { afterEach, expect, test, vi } from 'vitest'; import Invoices from '@/pages/invoices/index'; afterEach(() => vi.restoreAllMocks()); function render(actorId = 7) { return renderToStaticMarkup( , ); } test('returning from explicit commitment amendment restores invoice fields and MZN parcels within the same actor context', () => { vi.spyOn(router, 'restore').mockImplementation((key) => key === 'invoice-preparation:3:7:2:data' ? { number: 'QA-UNSAVED', issued_on: '2026-11-22', subtotal: '60.00', tax: '0.00', total: '60.00', reason: 'Imputação sintética ainda em preparação.', items: [ { purchase_order_item_id: 5, quantity: '0.600', unit: 'cx', unit_price: '100.00', tax_rate: '0', }, ], budget_distribution_preparation: [ { allocation_key: 'qa-a', line_id: 12, centre_id: 4, subtotal: '30.00', total: '30.00', }, ], } : undefined, ); const html = render(); expect(html).toContain('value="QA-UNSAVED"'); expect(html).toContain('value="0.600"'); expect(html).toContain('value="30.00"'); expect(html).toContain('/ordens/2/reafectacao'); expect(render(8)).not.toContain('value="QA-UNSAVED"'); });