diff --git a/__tests__/pages/exercises/[lessonSlug].test.js b/__tests__/pages/exercises/[lessonSlug].test.js index e7a17d734..79b043521 100644 --- a/__tests__/pages/exercises/[lessonSlug].test.js +++ b/__tests__/pages/exercises/[lessonSlug].test.js @@ -216,6 +216,40 @@ describe('Exercises page', () => { expect(incorrectExercisePreviews).toHaveLength(1) }) + test('Renders a finished all exercises message when the user finished all the exercises', async () => { + const mocks = [ + { + request: { query: GET_EXERCISES }, + result: { + data: { + ...getExercisesData, + // Make it so the user answered all of the exercises correctly + exerciseSubmissions: getExercisesData.exercises.map(exercise => ({ + exerciseId: exercise.id, + userAnswer: exercise.answer + })) + } + } + } + ] + + const { findByLabelText, findAllByText, findByText } = render( + + + + ) + + const exercisePreviews = await findAllByText('Problem') + expect(exercisePreviews).toHaveLength(3) + + const checkbox = await findByLabelText('Show incomplete exercises only') + fireEvent.click(checkbox) + + await findByText( + '🎉 Congratulations! You finished all the exercises for this lesson! 🥳' + ) + }) + test('Should not render lessons nav card tab if lesson docUrl is null', async () => { const mocks = [ { diff --git a/pages/exercises/[lessonSlug].tsx b/pages/exercises/[lessonSlug].tsx index ec23bef3b..81260bad5 100644 --- a/pages/exercises/[lessonSlug].tsx +++ b/pages/exercises/[lessonSlug].tsx @@ -281,18 +281,24 @@ const ExerciseList = ({ )} -
- {exercises.map((exercise, i) => ( - - ))} -
-
-
+ {exercises.length > 0 ? ( +
+ {exercises.map((exercise, i) => ( + + ))} +
+
+
+ ) : ( +

+ 🎉 Congratulations! You finished all the exercises for this lesson! 🥳 +

+ )} ) }