@@ -90,3 +90,51 @@ export const QuizWidgetAllCorrect: StoryObj<typeof meta> = {
90
90
} )
91
91
} ,
92
92
}
93
+
94
+ export const QuizWidgetAllIncorrect : StoryObj < typeof meta > = {
95
+ args : {
96
+ quizKey : "layer-2" ,
97
+ } ,
98
+ render : ( args ) => < StandaloneQuizWidget { ...args } /> ,
99
+
100
+ play : async ( { canvasElement, step } ) => {
101
+ const canvas = within ( canvasElement )
102
+
103
+ const quizWidget = canvas . getByTestId ( "quiz-widget" )
104
+ await expect ( quizWidget ) . toBeInTheDocument ( )
105
+
106
+ await waitFor ( ( ) =>
107
+ expect ( canvas . getByTestId ( "check-answer-button" ) ) . toBeDisabled ( )
108
+ )
109
+
110
+ await step ( "Answer some questions incorrectly" , async ( ) => {
111
+ for ( let i = 0 ; i < layer2QuestionBank . length ; i ++ ) {
112
+ const questionGroupId = canvas . getByTestId ( "question-group" ) . id
113
+ const questionAnswers = canvas . getAllByTestId ( "quiz-question-answer" )
114
+ const currentQuestionBank = layer2QuestionBank . find (
115
+ ( { id } ) => id === questionGroupId
116
+ ) !
117
+ await userEvent . click (
118
+ questionAnswers . find (
119
+ ( answer ) => answer . id !== currentQuestionBank . correctAnswer
120
+ ) !
121
+ )
122
+
123
+ await userEvent . click ( canvas . getByTestId ( "check-answer-button" ) )
124
+ await expect (
125
+ canvas . getByTestId ( "answer-status-incorrect" )
126
+ ) . toBeInTheDocument ( )
127
+
128
+ if ( i === layer2QuestionBank . length - 1 ) {
129
+ await userEvent . click ( canvas . getByTestId ( "see-results-button" ) )
130
+ } else {
131
+ await userEvent . click ( canvas . getByTestId ( "next-question-button" ) )
132
+ }
133
+ }
134
+ } )
135
+
136
+ await step ( "Check for failed results page" , async ( ) => {
137
+ await expect ( canvasElement ) . toHaveTextContent ( "Your results" )
138
+ } )
139
+ } ,
140
+ }
0 commit comments