import { describe, it, expect, vi, beforeEach } from 'vitest' import { render, screen, act } from '@testing-library/react' import StepperView from '../../../src/renderer/src/components/StepperView' import { useSessionStore } from '../../../src/renderer/src/stores/useSessionStore' let onSessionStatusChangedCb: ((status: string) => void) | undefined beforeEach(() => { vi.clearAllMocks() onSessionStatusChangedCb = undefined ;(window as unknown as { api: Record }).api = { notifySessionEnded: vi.fn(), onSessionStatusChanged: vi.fn((cb: (status: string) => void) => { onSessionStatusChangedCb = cb return () => {} }) } useSessionStore.getState().restart() }) describe('', () => { it('should render all 7 steps as pending when no status has been received yet', () => { render() expect(screen.getByText('Objectif')).toBeInTheDocument() expect(screen.getByText('Evaluation finale')).toBeInTheDocument() }) it('should update the active step when the main process relays a new session status', () => { render() act(() => onSessionStatusChangedCb?.('objective_validated')) const objectifStep = screen.getByText('Objectif').closest('li') expect(objectifStep).toHaveClass('step--done') const cartographieStep = screen.getByText('Cartographie').closest('li') expect(cartographieStep).toHaveClass('step--active') }) })