@@ -118,14 +118,54 @@ const graphsViewControls = (
118
118
afterEach ( cleanup ) ;
119
119
120
120
test ( 'Changing the platform dropdown in the Test Data Modal displays expected tests' , async ( ) => {
121
- const { getByText, getByTitle, getByTestId } = graphsViewControls ( ) ;
121
+ const {
122
+ getByText,
123
+ getByTitle,
124
+ getByTestId,
125
+ queryByText,
126
+ container,
127
+ } = graphsViewControls ( ) ;
122
128
123
129
fireEvent . click ( getByText ( 'Add test data' ) ) ;
124
130
125
- const platform = getByTitle ( 'Platform' ) ;
126
- fireEvent . click ( platform ) ;
131
+ // Wait for the modal to fully load with platforms
132
+ const platform = await waitFor ( ( ) => getByTitle ( 'Platform' ) ) ;
133
+
134
+ // The Platform title might be on the dropdown div, find the actual button
135
+ const platformButton =
136
+ platform . querySelector ( 'button' ) ||
137
+ platform . querySelector ( '.dropdown-toggle' ) ;
138
+ if ( platformButton ) {
139
+ fireEvent . click ( platformButton ) ;
140
+ } else {
141
+ fireEvent . click ( platform ) ;
142
+ }
143
+
144
+ // Small delay to allow dropdown animation
145
+ await new Promise ( ( resolve ) => {
146
+ setTimeout ( resolve , 100 ) ;
147
+ } ) ;
148
+
149
+ // Try to find windows7-32 in the dropdown
150
+ let windowsPlatform = queryByText ( 'windows7-32' ) ;
127
151
128
- const windowsPlatform = await waitFor ( ( ) => getByText ( 'windows7-32' ) ) ;
152
+ // If not found, try clicking the dropdown again (sometimes it needs a second click)
153
+ if ( ! windowsPlatform ) {
154
+ const dropdownButton = container . querySelector (
155
+ '[title="Platform"] button.dropdown-toggle' ,
156
+ ) ;
157
+ if ( dropdownButton ) {
158
+ fireEvent . click ( dropdownButton ) ;
159
+ await new Promise ( ( resolve ) => {
160
+ setTimeout ( resolve , 100 ) ;
161
+ } ) ;
162
+ }
163
+ }
164
+
165
+ // Now wait for the platform option to appear
166
+ windowsPlatform = await waitFor ( ( ) => getByText ( 'windows7-32' ) , {
167
+ timeout : 3000 ,
168
+ } ) ;
129
169
fireEvent . click ( windowsPlatform ) ;
130
170
131
171
// 'mozilla-central windows7-32 a11yr opt e10s stylo'
@@ -319,6 +359,8 @@ test('Changing the platform dropdown while filtered by text in the Test Data Mod
319
359
getByPlaceholderText,
320
360
getByTitle,
321
361
getByTestId,
362
+ queryByText,
363
+ container,
322
364
} = graphsViewControls ( ) ;
323
365
324
366
fireEvent . click ( getByText ( 'Add test data' ) ) ;
@@ -340,10 +382,43 @@ test('Changing the platform dropdown while filtered by text in the Test Data Mod
340
382
expect ( presentTests . children ) . toHaveLength ( 1 ) ;
341
383
expect ( linuxTest ) . toBeInTheDocument ( ) ;
342
384
343
- const platform = getByTitle ( 'Platform' ) ;
344
- fireEvent . click ( platform ) ;
385
+ const platform = await waitFor ( ( ) => getByTitle ( 'Platform' ) ) ;
386
+
387
+ // The Platform title might be on the dropdown div, find the actual button
388
+ const platformButton =
389
+ platform . querySelector ( 'button' ) ||
390
+ platform . querySelector ( '.dropdown-toggle' ) ;
391
+ if ( platformButton ) {
392
+ fireEvent . click ( platformButton ) ;
393
+ } else {
394
+ fireEvent . click ( platform ) ;
395
+ }
396
+
397
+ // Small delay to allow dropdown animation
398
+ await new Promise ( ( resolve ) => {
399
+ setTimeout ( resolve , 100 ) ;
400
+ } ) ;
401
+
402
+ // Try to find windows7-32 in the dropdown
403
+ let windowsPlatform = queryByText ( 'windows7-32' ) ;
345
404
346
- const windowsPlatform = await waitFor ( ( ) => getByText ( 'windows7-32' ) ) ;
405
+ // If not found, try clicking the dropdown again (sometimes it needs a second click)
406
+ if ( ! windowsPlatform ) {
407
+ const dropdownButton = container . querySelector (
408
+ '[title="Platform"] button.dropdown-toggle' ,
409
+ ) ;
410
+ if ( dropdownButton ) {
411
+ fireEvent . click ( dropdownButton ) ;
412
+ await new Promise ( ( resolve ) => {
413
+ setTimeout ( resolve , 100 ) ;
414
+ } ) ;
415
+ }
416
+ }
417
+
418
+ // Now wait for the platform option to appear
419
+ windowsPlatform = await waitFor ( ( ) => getByText ( 'windows7-32' ) , {
420
+ timeout : 3000 ,
421
+ } ) ;
347
422
fireEvent . click ( windowsPlatform ) ;
348
423
349
424
// linux64 (default platform of the modal) and windows7-32 (the platform below)
0 commit comments