fix(rapport,eo): conclusion ScoreHero 3 états + persistance simulation_id pour resume EO
This commit is contained in:
parent
5188714235
commit
822b02a2d1
4 changed files with 76 additions and 2 deletions
|
|
@ -105,6 +105,15 @@ export function SimulationFlowProvider({ children }: { children: ReactNode }) {
|
|||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [])
|
||||
|
||||
// Persiste l'ID de simulation dès qu'une production est active.
|
||||
// Permet le resume au refresh pour TOUS les flows (EE + EO_T1 + EO_T3),
|
||||
// indépendamment du composant qui rend le formulaire.
|
||||
useEffect(() => {
|
||||
if (production?.id) {
|
||||
localStorage.setItem(LS_SIMULATION_ID_KEY, production.id)
|
||||
}
|
||||
}, [production?.id])
|
||||
|
||||
const createMutation = useMutation({
|
||||
mutationFn: createSimulation,
|
||||
onSuccess: (data) => {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
*/
|
||||
|
||||
import React from 'react'
|
||||
import { renderHook, act } from '@testing-library/react'
|
||||
import { renderHook, act, waitFor } from '@testing-library/react'
|
||||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
||||
import { MemoryRouter } from 'react-router-dom'
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest'
|
||||
|
|
@ -78,6 +78,33 @@ describe('SimulationFlowProvider T1 — Sprint 4c-2', () => {
|
|||
expect(result.current.presentationT1).toBe('présentation persistée')
|
||||
})
|
||||
|
||||
it('hydrate la simulation EO_T1 + présentation depuis localStorage au refresh', async () => {
|
||||
localStorage.setItem('expria_simulation_id', 'sim-eo-t1-42')
|
||||
localStorage.setItem(LS_KEY, 'présentation persistée')
|
||||
mockGetState.mockResolvedValueOnce({
|
||||
simulation_id: 'sim-eo-t1-42',
|
||||
tache: 'EO_T1',
|
||||
mode: 'entrainement',
|
||||
created_at: '2026-04-25T10:00:00.000Z',
|
||||
sujet: null,
|
||||
contenu: null,
|
||||
rapport: null,
|
||||
nclc_cible: 9,
|
||||
exercices: null,
|
||||
exercices_status: 'pending',
|
||||
modele: null,
|
||||
modele_status: 'pending',
|
||||
})
|
||||
|
||||
const { result } = renderHook(() => useSimulationFlow(), { wrapper: createWrapper() })
|
||||
|
||||
await waitFor(() => {
|
||||
expect(result.current.production?.id).toBe('sim-eo-t1-42')
|
||||
})
|
||||
expect(result.current.presentationT1).toBe('présentation persistée')
|
||||
expect(result.current.step).toBe('task-selected')
|
||||
})
|
||||
|
||||
it('reset() remet presentationT1 à null et nettoie localStorage', () => {
|
||||
const { result } = renderHook(() => useSimulationFlow(), { wrapper: createWrapper() })
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue