From 0db62191663394145db0b0aba478d14a731c04e7 Mon Sep 17 00:00:00 2001
From: tylerapfledderer <tyler.pfledderer@gmail.com>
Date: Thu, 15 Aug 2024 00:37:12 -0400
Subject: [PATCH] fix(useQuizWidget): run chromatic check for shuffling
 question set

---
 src/components/Quiz/QuizWidget/useQuizWidget.tsx | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/components/Quiz/QuizWidget/useQuizWidget.tsx b/src/components/Quiz/QuizWidget/useQuizWidget.tsx
index 2a63a8004c2..9b7e1900db8 100644
--- a/src/components/Quiz/QuizWidget/useQuizWidget.tsx
+++ b/src/components/Quiz/QuizWidget/useQuizWidget.tsx
@@ -1,4 +1,5 @@
 import { useEffect, useMemo, useState } from "react"
+import isChromatic from "chromatic"
 import shuffle from "lodash/shuffle"
 import { useTranslation } from "next-i18next"
 
@@ -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,