|
| 1 | +import { getI18n, useTranslation } from "react-i18next" |
1 | 2 | import type { Meta, StoryObj } from "@storybook/react"
|
2 | 3 | import { expect, userEvent, waitFor, within } from "@storybook/test"
|
3 | 4 |
|
@@ -41,15 +42,20 @@ export const QuizWidgetAllCorrect: StoryObj<typeof meta> = {
|
41 | 42 | },
|
42 | 43 | render: (args) => <StandaloneQuizWidget {...args} />,
|
43 | 44 |
|
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 | + |
45 | 51 | const canvas = within(canvasElement)
|
46 | 52 |
|
47 | 53 | const quizWidget = canvas.getByTestId("quiz-widget")
|
48 | 54 | await expect(quizWidget).toBeInTheDocument()
|
49 | 55 |
|
50 | 56 | await waitFor(() =>
|
51 | 57 | expect(canvas.getByTestId("answer-status-null")).toHaveTextContent(
|
52 |
| - "Layer 2" |
| 58 | + translatedQuizKey |
53 | 59 | )
|
54 | 60 | )
|
55 | 61 |
|
@@ -84,7 +90,7 @@ export const QuizWidgetAllCorrect: StoryObj<typeof meta> = {
|
84 | 90 | })
|
85 | 91 |
|
86 | 92 | await step("Check for successful results page", async () => {
|
87 |
| - await expect(canvasElement).toHaveTextContent("You passed the quiz!") |
| 93 | + await expect(canvasElement).toHaveTextContent(translatedPassedQuiz) |
88 | 94 | })
|
89 | 95 | },
|
90 | 96 | }
|
|
0 commit comments