Skip to content

Commit 710c864

Browse files
authored
Merge pull request #13643 from TylerAPfledderer/fix/quiz-modal-story-no-question-shuffle
[Storybook] fix(useQuizWidget): run chromatic check for shuffling question set
2 parents acc8756 + 0db6219 commit 710c864

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/components/Quiz/QuizWidget/useQuizWidget.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { useEffect, useMemo, useState } from "react"
2+
import isChromatic from "chromatic"
23
import shuffle from "lodash/shuffle"
34
import { useTranslation } from "next-i18next"
45

@@ -51,7 +52,9 @@ export const useQuizWidget = ({
5152
const rawQuestion: RawQuestion = questionBank[id]
5253
return { id, ...rawQuestion }
5354
})
54-
const shuffledQuestions = shuffle(questions)
55+
56+
// ! Do not shuffle questions in Chromatic to keep the modal story snapshot stable
57+
const shuffledQuestions = isChromatic() ? questions : shuffle(questions)
5558
const quiz: Quiz = {
5659
title: t(rawQuiz.title),
5760
questions: shuffledQuestions,

0 commit comments

Comments
 (0)