import { App } from '@inertiajs/react'; import type { Page } from '@inertiajs/core'; import { renderToString } from 'react-dom/server'; import { expect, test } from 'vitest'; import RequisitionForm from '@/pages/requisitions/form'; import Catalogue from '@/pages/stock/catalogue'; const page = { component: 'requisitions/form', url: '/requisicoes/1/editar', version: 'catalogue', props: { errors: {} }, clearHistory: false, encryptHistory: true, } satisfies Page; test('saved article version remains selected when the published source has changed', () => { const initialPage = { ...page, props: { ...page.props, costCenters: [], requisition: { id: 1, cost_center_id: 1, priority: 'normal', needed_by: '2026-11-10', justification: 'Pedido', items: [ { id: 4, catalogue_entry_id: 7, catalogue_snapshot: { version: 1, code: 'ART-7' }, description: 'Nome original', category: 'Material', purchase_type: 'consumable', quantity: '2', unit: 'cx', unit_price_minor: 1000, tax_rate: '16', }, ], }, catalogue: { ready: true, search: '', more: false, items: [ { id: 7, version: 2, stock_item_id: 3, code: 'ART-7', description: 'Nome actualizado', unit: 'cx', category: 'Material', purchase_type: 'consumable', }, ], }, }, }; const html = renderToString( , ); expect(html).toMatch(/