Files
geointel/frontend/src/components/map/LiveAnalysisJourney.test.tsx
T
Jens faeb58ef6d
GeoIntel release gates / Compile, test, contracts and builds (push) Successful in 1m49s
GeoIntel release gates / Python and npm vulnerability policy (push) Successful in 21s
GeoIntel release gates / Production AI image, SBOM and container scan (push) Successful in 5m39s
GeoIntel release gates / Deploy exact gated revision to Unraid (push) Failing after 58m43s
Initial public release
2026-08-31 21:56:53 +02:00

58 lines
2.1 KiB
TypeScript

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(
<LiveAnalysisJourney
{...baseState}
hasSelection
sourceReady
hasResult
verified
selectionLabel="Vrije kaartselectie"
sourceLabel="Gebouwen"
statusMessage="Analyse voltooid"
resultLabel="Kwaliteitsbewijs beschikbaar"
/>,
)
expect(screen.getAllByText('Kwaliteitsbewijs beschikbaar')).toHaveLength(2)
expect(screen.getByTestId('live-analysis-journey').getAttribute('data-stage')).toBe('controleer')
})
})