@@ -159,6 +159,34 @@ describe("image-button-response", () => {
159
159
expect ( btns [ i ] . hasAttribute ( "disabled" ) ) . toBe ( false ) ;
160
160
}
161
161
} ) ;
162
+
163
+ test ( "buttons should be disabled and re-enabled with enable_button_after parameter" , async ( ) => {
164
+ const { displayElement } = await startTimeline ( [
165
+ {
166
+ type : imageButtonResponse ,
167
+ stimulus : "../media/blue.png" ,
168
+ choices : [ "Choice A" , "Choice B" ] ,
169
+ enable_button_after : 1000 ,
170
+ render_on_canvas : false ,
171
+ } ,
172
+ ] ) ;
173
+
174
+ const buttons = displayElement . querySelectorAll ( "button" ) ;
175
+
176
+ // All buttons should be disabled initially
177
+ buttons . forEach ( ( button ) => {
178
+ expect ( button . hasAttribute ( "disabled" ) ) . toBe ( true ) ;
179
+ expect ( button . getAttribute ( "disabled" ) ) . toBe ( "disabled" ) ;
180
+ } ) ;
181
+
182
+ // Advance time by 1000ms
183
+ jest . advanceTimersByTime ( 1000 ) ;
184
+
185
+ // All buttons should be enabled after the delay
186
+ buttons . forEach ( ( button ) => {
187
+ expect ( button . hasAttribute ( "disabled" ) ) . toBe ( false ) ;
188
+ } ) ;
189
+ } ) ;
162
190
} ) ;
163
191
164
192
describe ( "image-button-response simulation" , ( ) => {
@@ -199,10 +227,7 @@ describe("image-button-response simulation", () => {
199
227
} ,
200
228
] ;
201
229
202
- const { expectFinished, expectRunning, getData } = await simulateTimeline (
203
- timeline ,
204
- "visual"
205
- ) ;
230
+ const { expectFinished, expectRunning, getData } = await simulateTimeline ( timeline , "visual" ) ;
206
231
207
232
await expectRunning ( ) ;
208
233
0 commit comments