import { App, router } from '@inertiajs/react'; import { renderToStaticMarkup } from 'react-dom/server'; import { afterEach, expect, test, vi } from 'vitest'; import History from '@/pages/supply/history'; import Suggestions from '@/pages/supply/suggestions'; afterEach(() => vi.restoreAllMocks()); const historyProps = { ready: true, actorId: 7, canPrepare: true, canReview: true, records: [], history: {}, items: [], warehouses: [], defaultPeriod: { from: '2026-10-01', until: '2026-10-31' }, }; const suggestionProps = { ready: true, actorId: 7, canPrepare: true, canReview: true, canConvert: true, records: [], policies: [ { key: 'policy-qa', version: 2, label: 'Synthetic policy', issue: null, unit_price: '12.50', tax_rate: '0.00', }, ], excess: {}, costCenters: [], requestLinks: {}, history: {}, }; function render( kind: 'history' | 'suggestions', overrides = {}, actor = 7, tenant = 4, ) { return renderToStaticMarkup( , ); } test('consumption evidence and its explicit period restore without calculating or approving', () => { vi.spyOn(router, 'restore').mockImplementation((key) => key === 'supply-history:4:7:true:true:true:new:0:new:prepare:data' ? { operation_key: 'synthetic-history', version: 0, action: 'save', reason: 'HISTORY-EVIDENCE-QA', data: { stock_item_id: '', warehouse_id: '', purpose: 'internal', period_from: '2026-09-01', period_until: '2026-09-30', quality: 'incomplete', pattern: 'seasonal', }, } : undefined, ); const post = vi.spyOn(router, 'post'); const html = render('history'); expect(html).toContain('HISTORY-EVIDENCE-QA'); expect(html).toContain('value="2026-09-01"'); expect(html).toContain('