import { render, screen } from '@testing-library/react' import { describe, expect, it } from 'vitest' import { LiveAnalysisJourney, resolveLiveAnalysisJourney } from './LiveAnalysisJourney' const baseState = { selectionMode: false, hasSelection: false, sourceLoading: false, sourceReady: false, processing: false, validating: false, hasResult: false, verified: false, error: null, } describe('resolveLiveAnalysisJourney', () => { it('follows real workflow state without assuming completion', () => { expect(resolveLiveAnalysisJourney(baseState).currentLabel).toBe('Selecteer') expect(resolveLiveAnalysisJourney({ ...baseState, hasSelection: true, sourceLoading: true }).currentLabel).toBe('Bronnen') expect(resolveLiveAnalysisJourney({ ...baseState, hasSelection: true, sourceReady: true, processing: true }).currentLabel).toBe('Verwerk') expect(resolveLiveAnalysisJourney({ ...baseState, hasSelection: true, sourceReady: true, hasResult: true }).currentLabel).toBe('Controleer') expect(resolveLiveAnalysisJourney({ ...baseState, hasSelection: true, sourceReady: true, hasResult: true, verified: true }).status).toBe('complete') }) it('marks the reached stage as failed', () => { const view = resolveLiveAnalysisJourney({ ...baseState, hasSelection: true, sourceReady: true, processing: true, error: 'Bron tijdelijk niet beschikbaar.', }) expect(view.status).toBe('error') expect(view.steps[2]).toBe('error') }) }) describe('LiveAnalysisJourney', () => { it('announces verified evidence only when verification exists', () => { render( , ) expect(screen.getAllByText('Kwaliteitsbewijs beschikbaar')).toHaveLength(2) expect(screen.getByTestId('live-analysis-journey').getAttribute('data-stage')).toBe('controleer') }) })