1
0
Fork 0
mirror of https://github.com/betagouv/mon-entreprise synced 2025-03-13 05:05:05 +00:00

feat(économie-collaborative): ne pas afficher le bloc de questions si aucune question à poser

This commit is contained in:
Jalil Arfaoui 2025-02-05 23:12:24 +01:00
parent 8c177d38ed
commit 484ff26217
3 changed files with 60 additions and 1 deletions

View file

@ -10,6 +10,7 @@ import ShareOrSaveSimulationBanner, {
import { Button } from '@/design-system/buttons'
import { Grid, Spacing } from '@/design-system/layout'
import { H3 } from '@/design-system/typography/heading'
import { ilYADesQuestionsSelector } from '@/store/selectors/ilYADesQuestions.selector'
import { firstStepCompletedSelector } from '@/store/selectors/simulationSelectors'
import { TrackPage } from '../ATInternetTracking'
@ -63,6 +64,7 @@ export default function Simulation({
entrepriseSelection = true,
}: SimulationProps) {
const firstStepCompleted = useSelector(firstStepCompletedSelector)
const ilYADesQuestions = useSelector(ilYADesQuestionsSelector)
const shouldShowFeedback = getShouldAskFeedback(useLocation().pathname)
return (
@ -79,7 +81,9 @@ export default function Simulation({
<div className="print-hidden">
<FromTop>{results}</FromTop>
</div>
<Questions customEndMessages={customEndMessages} />
{ilYADesQuestions && (
<Questions customEndMessages={customEndMessages} />
)}
</>
)}
<Spacing md />

View file

@ -0,0 +1,38 @@
import { describe, expect, it } from 'vitest'
import { RootState } from '@/store/reducers/rootReducer'
import { ilYADesQuestionsSelector } from '@/store/selectors/ilYADesQuestions.selector'
describe('sélecteur ilYADesQuestions', () => {
it('retourne true si une question est en cours', () => {
expect(
ilYADesQuestionsSelector({
simulation: {
currentQuestion: 'a',
questionsSuivantes: [],
},
} as unknown as RootState)
).toEqual(true)
})
it('retourne true si au moins une question en attente', () => {
expect(
ilYADesQuestionsSelector({
simulation: {
currentQuestion: undefined,
questionsSuivantes: ['a'],
},
} as unknown as RootState)
).toEqual(true)
})
it('retourne true si au moins une question répondue', () => {
expect(
ilYADesQuestionsSelector({
simulation: {
currentQuestion: undefined,
questionsSuivantes: [],
questionsRépondues: ['a'],
},
} as unknown as RootState)
).toEqual(true)
})
})

View file

@ -0,0 +1,17 @@
import { createSelector } from 'reselect'
import { currentQuestionSelector } from '@/store/selectors/currentQuestion.selector'
import { questionsRéponduesSelector } from '@/store/selectors/questionsRépondues.selector'
import { questionsSuivantesSelector } from '@/store/selectors/questionsSuivantes.selector'
export const ilYADesQuestionsSelector = createSelector(
[
currentQuestionSelector,
questionsSuivantesSelector,
questionsRéponduesSelector,
],
(questionEnCours, questionsSuivantes, questionsRépondues) =>
!!questionEnCours ||
!!questionsSuivantes.length ||
!!questionsRépondues.length
)