Skip to content

Commit 0e0abf1

Browse files
refactor(QuizWidget.stories): internationalize checks for All Correct story play
1 parent 8c8525f commit 0e0abf1

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/components/Quiz/QuizWidget/QuizWidget.stories.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { getI18n, useTranslation } from "react-i18next"
12
import type { Meta, StoryObj } from "@storybook/react"
23
import { expect, userEvent, waitFor, within } from "@storybook/test"
34

@@ -41,15 +42,20 @@ export const QuizWidgetAllCorrect: StoryObj<typeof meta> = {
4142
},
4243
render: (args) => <StandaloneQuizWidget {...args} />,
4344

44-
play: async ({ canvasElement, step }) => {
45+
play: async ({ canvasElement, step, args }) => {
46+
const { t } = getI18n()
47+
48+
const translatedQuizKey = t(args.quizKey, { ns: "common" })
49+
const translatedPassedQuiz = t("passed", { ns: "learn-quizzes" })
50+
4551
const canvas = within(canvasElement)
4652

4753
const quizWidget = canvas.getByTestId("quiz-widget")
4854
await expect(quizWidget).toBeInTheDocument()
4955

5056
await waitFor(() =>
5157
expect(canvas.getByTestId("answer-status-null")).toHaveTextContent(
52-
"Layer 2"
58+
translatedQuizKey
5359
)
5460
)
5561

@@ -84,7 +90,7 @@ export const QuizWidgetAllCorrect: StoryObj<typeof meta> = {
8490
})
8591

8692
await step("Check for successful results page", async () => {
87-
await expect(canvasElement).toHaveTextContent("You passed the quiz!")
93+
await expect(canvasElement).toHaveTextContent(translatedPassedQuiz)
8894
})
8995
},
9096
}

0 commit comments

Comments
 (0)