fix(lint): 4 erreurs ESLint corrigées — split SimulationFlowProvider, hook conditionnel, ref render, setState effect
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
de69b3ff16
commit
79bbbdc4e8
10 changed files with 82 additions and 50 deletions
|
|
@ -33,11 +33,14 @@ function gaugeColor(score: number): string {
|
|||
}
|
||||
|
||||
export function MonProfilPreparation({ plan }: Props) {
|
||||
// Garde explicite (cohérent avec la logique du hook qui a déjà `enabled`).
|
||||
if (!hasAccess(plan, 'pattern_analysis')) return null
|
||||
|
||||
// Hook appelé inconditionnellement (règle React). Il court-circuite la
|
||||
// requête backend via `enabled: hasAccess(plan, 'pattern_analysis')`,
|
||||
// donc aucun appel parasite pour Free/Standard.
|
||||
const { data, isLoading, isError } = usePatterns(plan)
|
||||
|
||||
// Garde explicite après le hook pour éviter un flash de contenu.
|
||||
if (!hasAccess(plan, 'pattern_analysis')) return null
|
||||
|
||||
if (isLoading || isError || !data) {
|
||||
return (
|
||||
<Card variant="default" className="p-4">
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
* Le hook `usePatterns` est mocké pour isoler la présentation.
|
||||
*/
|
||||
|
||||
import { describe, it, expect, vi, afterEach } from 'vitest'
|
||||
import { describe, it, expect, vi, afterEach, beforeEach } from 'vitest'
|
||||
import { render, screen, cleanup } from '@testing-library/react'
|
||||
import { MemoryRouter } from 'react-router-dom'
|
||||
|
||||
|
|
@ -16,6 +16,16 @@ vi.mock('@/features/progression/hooks/usePatterns', () => ({
|
|||
import { usePatterns } from '@/features/progression/hooks/usePatterns'
|
||||
import { MonProfilPreparation } from '../MonProfilPreparation'
|
||||
|
||||
beforeEach(() => {
|
||||
// Mock par défaut — usePatterns est appelé inconditionnellement depuis le
|
||||
// composant (Règle des hooks). Les tests Premium surchargent ce mock.
|
||||
vi.mocked(usePatterns).mockReturnValue({
|
||||
data: undefined,
|
||||
isLoading: false,
|
||||
isError: false,
|
||||
} as unknown as ReturnType<typeof usePatterns>)
|
||||
})
|
||||
|
||||
afterEach(cleanup)
|
||||
|
||||
function renderWithRouter(ui: React.ReactNode) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue