import { cleanup, render, screen } from '@testing-library/react' import { afterEach, beforeEach, expect, it, vi } from 'vitest' import { Reports } from '../src/pages/Reports' const { listReports, listMessages } = vi.hoisted(() => ({ listReports: vi.fn(), listMessages: vi.fn() })) vi.mock('@/api/reports', () => ({ reportsApi: { list: listReports, listMessages, delete: vi.fn(), createMessage: vi.fn() }, })) beforeEach(() => { listReports.mockResolvedValue([{ id: 'historical-report-1', user_id: 'user-1', summary_id: 'historical-summary-1', context_excerpt: 'Extrait issu de la synthèse historique.', question: 'Que signifiait ce mouvement ?', answer: 'La réponse historique reste disponible.', status: 'done', error_msg: '', created_at: '2026-11-19T10:00:00.000Z', }]) listMessages.mockResolvedValue([]) }) afterEach(cleanup) it('conserve et affiche les rapports historiques avec leur synthèse et leur réponse', async () => { render() expect(await screen.findByText('Que signifiait ce mouvement ?')).toBeInTheDocument() expect(screen.getByText(/Extrait issu de la synthèse historique/)).toBeInTheDocument() expect(screen.getByText('La réponse historique reste disponible.')).toBeInTheDocument() expect(listReports).toHaveBeenCalledOnce() })