fix(rapport,eo): conclusion ScoreHero 3 états + persistance simulation_id pour resume EO

This commit is contained in:
Hermann_Kitio 2026-04-25 21:10:39 +03:00
parent 5188714235
commit 822b02a2d1
4 changed files with 76 additions and 2 deletions

View file

@ -22,6 +22,7 @@ const NCLC_MIN_SCORE: Record<number, number> = { 9: 14, 10: 16 }
export function ScoreHero({ score, nclc, nclcCible }: Props) {
const { points, atteint } = ecartVsCible(score, nclcCible)
const depasse = atteint && nclc > nclcCible
const seuilCible = NCLC_MIN_SCORE[nclcCible] ?? 14
const percent = Math.max(0, Math.min(100, (score / 20) * 100))
const seuilPercent = (seuilCible / 20) * 100
@ -88,7 +89,11 @@ export function ScoreHero({ score, nclc, nclcCible }: Props) {
</div>
{/* Encart d'écart */}
{atteint ? (
{depasse ? (
<p className="rounded-md border border-success/30 bg-success-soft px-3 py-2 text-sm text-success">
Objectif dépassé continuez vers NCLC {nclc + 1}.
</p>
) : atteint ? (
<p className="rounded-md border border-success/30 bg-success-soft px-3 py-2 text-sm text-success">
Objectif NCLC {nclcCible} atteint.
</p>

View file

@ -0,0 +1,33 @@
/**
* Tests ScoreHero (Sprint 4.5).
*
* Couvre les 3 états de l'encart de conclusion :
* - NCLC atteint < NCLC cible : message « X points avant NCLC »
* - NCLC atteint = NCLC cible : message « Objectif NCLC atteint. »
* - NCLC atteint > NCLC cible : message « Objectif dépassé continuez vers NCLC {nclc+1}. »
*/
import { describe, it, expect } from 'vitest'
import { render, screen, cleanup } from '@testing-library/react'
import { afterEach } from 'vitest'
import { ScoreHero } from '../ScoreHero'
afterEach(cleanup)
describe('ScoreHero — encart de conclusion', () => {
it('NCLC atteint < cible : affiche « X points avant NCLC {cible}+ »', () => {
render(<ScoreHero score={12} nclc={8} nclcCible={9} />)
expect(screen.getByText(/2 points avant NCLC/i)).toBeInTheDocument()
expect(screen.getByText(/9\+/)).toBeInTheDocument()
})
it('NCLC atteint = cible : affiche « Objectif NCLC {cible} atteint. »', () => {
render(<ScoreHero score={14} nclc={9} nclcCible={9} />)
expect(screen.getByText('Objectif NCLC 9 atteint.')).toBeInTheDocument()
})
it('NCLC atteint > cible : affiche « Objectif dépassé — continuez vers NCLC {nclc+1}. »', () => {
render(<ScoreHero score={17} nclc={10} nclcCible={9} />)
expect(screen.getByText('Objectif dépassé — continuez vers NCLC 11.')).toBeInTheDocument()
})
})