Remove obsolete article and scrape-job screens and APIs, preserve reports, and clear legacy API caches from the service worker. Refs #8 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
36 lines
1.3 KiB
TypeScript
36 lines
1.3 KiB
TypeScript
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(<Reports />)
|
|
|
|
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()
|
|
})
|