@@ -108,22 +108,24 @@ describe('Test Run when not signed in', () => {
108
108
} ) ;
109
109
110
110
describe ( 'Test Run when signed in as tester' , ( ) => {
111
- const assignSelfAndNavigateToRun = async page => {
112
- const modalDialogSectionButtonSelector =
113
- 'button#disclosure-btn-modal-dialog-0' ;
114
- const modalDialogTableSelector =
115
- 'table[aria-label="Reports for Modal Dialog Example V24.06.07 in draft phase"]' ;
111
+ const assignSelfAndNavigateToRun = async (
112
+ page ,
113
+ {
114
+ testPlanSectionButtonSelector = 'button#disclosure-btn-modal-dialog-0' ,
115
+ testPlanTableSelector = 'table[aria-label="Reports for Modal Dialog Example V24.06.07 in draft phase"]'
116
+ } = { }
117
+ ) => {
116
118
const startTestingButtonSelector =
117
119
'a[role="button"] ::-p-text(Start Testing)' ;
118
120
119
121
// Expand Modal Dialog's V24.06.07 section
120
- await page . waitForSelector ( modalDialogSectionButtonSelector ) ;
121
- await page . click ( modalDialogSectionButtonSelector ) ;
122
+ await page . waitForSelector ( testPlanSectionButtonSelector ) ;
123
+ await page . click ( testPlanSectionButtonSelector ) ;
122
124
123
125
// Wait for the table to render
124
- await page . waitForSelector ( modalDialogTableSelector ) ;
126
+ await page . waitForSelector ( testPlanTableSelector ) ;
125
127
126
- await page . $eval ( modalDialogTableSelector , el => {
128
+ await page . $eval ( testPlanTableSelector , el => {
127
129
// First button found on table would be 'Assign Yourself'
128
130
el . querySelector ( 'button' ) . click ( ) ;
129
131
} ) ;
@@ -161,6 +163,72 @@ describe('Test Run when signed in as tester', () => {
161
163
await page . waitForNetworkIdle ( ) ;
162
164
} ;
163
165
166
+ const handlePageSubmit = async ( page , { expectConflicts = true } = { } ) => {
167
+ await page . waitForSelector ( 'h1 ::-p-text(Test 1)' ) ;
168
+
169
+ // Confirm that submission cannot happen with empty form
170
+ // Specificity with selector because there's a 2nd 'hidden' button coming
171
+ // from the harness which is what is actually called for the submit event
172
+ const submitResultsButtonSelector =
173
+ 'button[class="btn btn-primary"] ::-p-text(Submit Results)' ;
174
+ await page . waitForSelector ( submitResultsButtonSelector ) ;
175
+ await page . click ( submitResultsButtonSelector ) ;
176
+ await page . waitForNetworkIdle ( ) ;
177
+ await page . waitForSelector ( '::-p-text((required))' ) ;
178
+
179
+ // Should refocus on topmost output textarea on page
180
+ const activeElementAfterEmptySubmit = await page . evaluate ( ( ) => {
181
+ return {
182
+ id : document . activeElement . id ,
183
+ nodeName : document . activeElement . nodeName . toLowerCase ( )
184
+ } ;
185
+ } ) ;
186
+
187
+ // Input output for valid submission
188
+ await page . evaluate ( ( ) => {
189
+ const yesRadios = document . querySelectorAll (
190
+ 'input[data-testid^="radio-yes-"]'
191
+ ) ;
192
+ const noRadios = document . querySelectorAll (
193
+ 'input[data-testid^="radio-no-"]'
194
+ ) ;
195
+ const noUndesiredRadios = document . querySelectorAll (
196
+ 'input[id^="problem-"][id$="-true"]'
197
+ ) ;
198
+ const noOutputCheckboxes = document . querySelectorAll (
199
+ 'input[id^="no-output-checkbox"]'
200
+ ) ;
201
+
202
+ yesRadios . forEach ( ( radio , index ) => {
203
+ if ( index % 2 === 0 ) {
204
+ radio . click ( ) ;
205
+ } else {
206
+ noRadios [ index ] . click ( ) ;
207
+ }
208
+ } ) ;
209
+
210
+ noUndesiredRadios . forEach ( radio => {
211
+ radio . click ( ) ;
212
+ } ) ;
213
+
214
+ noOutputCheckboxes . forEach ( checkbox => {
215
+ checkbox . click ( ) ;
216
+ } ) ;
217
+ } ) ;
218
+ // Submit valid form
219
+ await page . click ( submitResultsButtonSelector ) ;
220
+ await page . waitForNetworkIdle ( ) ;
221
+ if ( expectConflicts )
222
+ await page . waitForSelector (
223
+ '::-p-text(This test has conflicting results)'
224
+ ) ;
225
+ await page . waitForSelector ( 'h2 ::-p-text(Test Results)' ) ;
226
+ await page . waitForSelector ( 'button ::-p-text(Edit Results)' ) ;
227
+
228
+ expect ( activeElementAfterEmptySubmit . id ) . toBe ( 'speechoutput-0' ) ;
229
+ expect ( activeElementAfterEmptySubmit . nodeName ) . toBe ( 'textarea' ) ;
230
+ } ;
231
+
164
232
it ( 'self assigns tester on Test Queue page and opens test run' , async ( ) => {
165
233
await getPage ( { role : 'tester' , url : '/test-queue' } , async page => {
166
234
await assignSelfAndNavigateToRun ( page ) ;
@@ -324,72 +392,25 @@ describe('Test Run when signed in as tester', () => {
324
392
} ) ;
325
393
326
394
it ( 'inputs results and successfully submits' , async ( ) => {
327
- await getPage ( { role : 'tester' , url : '/test-queue' } , async page => {
328
- await assignSelfAndNavigateToRun ( page ) ;
329
-
330
- await page . waitForSelector ( 'h1 ::-p-text(Test 1)' ) ;
331
-
332
- // Confirm that submission cannot happen with empty form
333
- // Specificity with selector because there's a 2nd 'hidden' button coming
334
- // from the harness which is what is actually called for the submit event
335
- const submitResultsButtonSelector =
336
- 'button[class="btn btn-primary"] ::-p-text(Submit Results)' ;
337
- await page . waitForSelector ( submitResultsButtonSelector ) ;
338
- await page . click ( submitResultsButtonSelector ) ;
339
- await page . waitForNetworkIdle ( ) ;
340
- await page . waitForSelector ( '::-p-text((required))' ) ;
341
-
342
- // Should refocus on topmost output textarea on page
343
- const activeElementAfterEmptySubmit = await page . evaluate ( ( ) => {
344
- return {
345
- id : document . activeElement . id ,
346
- nodeName : document . activeElement . nodeName . toLowerCase ( )
347
- } ;
348
- } ) ;
349
-
350
- // Input output for valid submission
351
- await page . evaluate ( ( ) => {
352
- const yesRadios = document . querySelectorAll (
353
- 'input[data-testid^="radio-yes-"]'
354
- ) ;
355
- const noRadios = document . querySelectorAll (
356
- 'input[data-testid^="radio-no-"]'
357
- ) ;
358
- const noUndesiredRadios = document . querySelectorAll (
359
- 'input[id^="problem-"][id$="-true"]'
360
- ) ;
361
- const noOutputCheckboxes = document . querySelectorAll (
362
- 'input[id^="no-output-checkbox"]'
363
- ) ;
364
-
365
- yesRadios . forEach ( ( radio , index ) => {
366
- if ( index % 2 === 0 ) {
367
- radio . click ( ) ;
368
- } else {
369
- noRadios [ index ] . click ( ) ;
370
- }
371
- } ) ;
372
-
373
- noUndesiredRadios . forEach ( radio => {
374
- radio . click ( ) ;
375
- } ) ;
376
-
377
- noOutputCheckboxes . forEach ( checkbox => {
378
- checkbox . click ( ) ;
395
+ await getPage (
396
+ { role : 'tester' , url : '/test-queue' } ,
397
+ async ( page , { baseUrl } ) => {
398
+ await assignSelfAndNavigateToRun ( page ) ;
399
+ await handlePageSubmit ( page ) ;
400
+
401
+ // Do the same for Color Viewer Slider which has specially handled
402
+ // exclusions;
403
+ // Excluded in tests.csv and re-included in *-commands.csv
404
+ await page . goto ( `${ baseUrl } /test-queue` ) ;
405
+ await assignSelfAndNavigateToRun ( page , {
406
+ testPlanSectionButtonSelector :
407
+ 'button#disclosure-btn-horizontal-slider-0' ,
408
+ testPlanTableSelector :
409
+ 'table[aria-label="Reports for Color Viewer Slider V24.06.26 in draft phase"]'
379
410
} ) ;
380
- } ) ;
381
- // Submit valid form
382
- await page . click ( submitResultsButtonSelector ) ;
383
- await page . waitForNetworkIdle ( ) ;
384
- await page . waitForSelector (
385
- '::-p-text(This test has conflicting results)'
386
- ) ;
387
- await page . waitForSelector ( 'h2 ::-p-text(Test Results)' ) ;
388
- await page . waitForSelector ( 'button ::-p-text(Edit Results)' ) ;
389
-
390
- expect ( activeElementAfterEmptySubmit . id ) . toBe ( 'speechoutput-0' ) ;
391
- expect ( activeElementAfterEmptySubmit . nodeName ) . toBe ( 'textarea' ) ;
392
- } ) ;
411
+ await handlePageSubmit ( page , { expectConflicts : false } ) ;
412
+ }
413
+ ) ;
393
414
} ) ;
394
415
395
416
it ( 'opens popup with content after clicking "Open Test Page" button' , async ( ) => {
0 commit comments