diff --git a/src/features/culturalSurvey/pages/CulturalSurveyQuestions.native.test.tsx b/src/features/culturalSurvey/pages/CulturalSurveyQuestions.native.test.tsx index d15b4e07834..4b19bd6bc90 100644 --- a/src/features/culturalSurvey/pages/CulturalSurveyQuestions.native.test.tsx +++ b/src/features/culturalSurvey/pages/CulturalSurveyQuestions.native.test.tsx @@ -120,7 +120,7 @@ describe('CulturalSurveyQuestions page', () => { const GoBackButton = screen.getByTestId('Revenir en arrière') fireEvent.press(GoBackButton) - expect(dispatch).toHaveBeenCalledWith({ + expect(dispatch).toHaveBeenNthCalledWith(1, { type: 'SET_ANSWERS', payload: { questionId: navigationProps.route.params.question, @@ -129,6 +129,22 @@ describe('CulturalSurveyQuestions page', () => { }) }) + it('should dispatch default questions on go back when current question is "sorties"', () => { + render() + + const GoBackButton = screen.getByTestId('Revenir en arrière') + fireEvent.press(GoBackButton) + + expect(dispatch).toHaveBeenNthCalledWith(2, { + type: 'SET_QUESTIONS', + payload: [ + CulturalSurveyQuestionEnum.SORTIES, + CulturalSurveyQuestionEnum.ACTIVITES, + CulturalSurveyQuestionEnum.PROJECTIONS, + ], + }) + }) + it('should updateQuestionsToDisplay on checkbox press if answer pressed has sub_question', () => { render() diff --git a/src/features/culturalSurvey/pages/CulturalSurveyQuestions.tsx b/src/features/culturalSurvey/pages/CulturalSurveyQuestions.tsx index 365f9325f3c..fcefa040d6b 100644 --- a/src/features/culturalSurvey/pages/CulturalSurveyQuestions.tsx +++ b/src/features/culturalSurvey/pages/CulturalSurveyQuestions.tsx @@ -155,6 +155,19 @@ export function CulturalSurveyQuestions({ route }: CulturalSurveyQuestionsProps) answers: [], }, }) + + if (currentQuestion === CulturalSurveyQuestionEnum.SORTIES) { + const INITIAL_CULTURAL_SURVEY_QUESTIONS = [ + CulturalSurveyQuestionEnum.SORTIES, + CulturalSurveyQuestionEnum.ACTIVITES, + CulturalSurveyQuestionEnum.PROJECTIONS, + ] + + dispatch({ + type: 'SET_QUESTIONS', + payload: INITIAL_CULTURAL_SURVEY_QUESTIONS, + }) + } } function onScroll({ nativeEvent }: { nativeEvent: NativeScrollEvent }) {