Skip to content

Commit

Permalink
Merge pull request #13643 from TylerAPfledderer/fix/quiz-modal-story-…
Browse files Browse the repository at this point in the history
…no-question-shuffle

[Storybook] fix(useQuizWidget): run chromatic check for shuffling question set
  • Loading branch information
pettinarip authored Aug 15, 2024
2 parents acc8756 + 0db6219 commit 710c864
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/components/Quiz/QuizWidget/useQuizWidget.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useEffect, useMemo, useState } from "react"
import isChromatic from "chromatic"
import shuffle from "lodash/shuffle"
import { useTranslation } from "next-i18next"

Expand Down Expand Up @@ -51,7 +52,9 @@ export const useQuizWidget = ({
const rawQuestion: RawQuestion = questionBank[id]
return { id, ...rawQuestion }
})
const shuffledQuestions = shuffle(questions)

// ! Do not shuffle questions in Chromatic to keep the modal story snapshot stable
const shuffledQuestions = isChromatic() ? questions : shuffle(questions)
const quiz: Quiz = {
title: t(rawQuiz.title),
questions: shuffledQuestions,
Expand Down

0 comments on commit 710c864

Please sign in to comment.