@@ -36,6 +36,7 @@ const resultCardsSelector =
36
36
'section#top div[class*=SpaceVertical] div[class*=Card]'
37
37
const baseInputSelector = 'input#listbox-input-base'
38
38
const compInputSelector = 'input#listbox-input-compare'
39
+ const compOptionsInputSelector = 'input#listbox-input-options'
39
40
const globalOptionsSelector = '#modal-root [role=option] span'
40
41
const switchButtonSelector = '.switch-button'
41
42
@@ -225,7 +226,9 @@ describe('Diff Scene', () => {
225
226
// Check the URL
226
227
// Would like to do this earlier, but not sure what to wait on
227
228
const compUrl = page . url ( )
228
- expect ( compUrl ) . toEqual ( `${ BASE_URL } /3.1/diff/4.0?sdk=py` )
229
+ expect ( compUrl ) . toEqual (
230
+ `${ BASE_URL } /3.1/diff/4.0?sdk=py&opts=missing%2Cparams%2Ctype%2Cbody%2Cresponse`
231
+ )
229
232
230
233
// Check the results
231
234
const diffResultCards = await page . $$ ( resultCardsSelector )
@@ -253,7 +256,9 @@ describe('Diff Scene', () => {
253
256
await page . waitForTimeout ( 150 )
254
257
255
258
const switchUrl = page . url ( )
256
- expect ( switchUrl ) . toEqual ( `${ BASE_URL } /4.0/diff/3.1?sdk=py` )
259
+ expect ( switchUrl ) . toEqual (
260
+ `${ BASE_URL } /4.0/diff/3.1?sdk=py&opts=missing%2Cparams%2Ctype%2Cbody%2Cresponse`
261
+ )
257
262
258
263
// Check the results again, even though they should be the same
259
264
const diff40to31Page1Methods = await Promise . all (
@@ -265,4 +270,70 @@ describe('Diff Scene', () => {
265
270
expect ( diff40to31Page1Methods ) . toHaveLength ( 15 )
266
271
expect ( diff40to31Page1Methods ) . toContain ( 'delete_board_item' )
267
272
} )
273
+
274
+ it ( 'updates when a comparison option is toggled' , async ( ) => {
275
+ await goToPage ( `${ BASE_URL } /3.1/diff/4.0` )
276
+
277
+ // expect default diff options in url
278
+ expect ( page . url ( ) ) . toEqual (
279
+ `${ BASE_URL } /3.1/diff/4.0?sdk=py&opts=missing%2Cparams%2Ctype%2Cbody%2Cresponse`
280
+ )
281
+
282
+ // "Base" input element
283
+ const baseInputElement = await page . $ ( baseInputSelector )
284
+ expect ( baseInputElement ) . not . toBeNull ( )
285
+
286
+ // "Comparison" input element
287
+ const compInputElement = await page . $ ( compInputSelector )
288
+ expect ( compInputElement ) . not . toBeNull ( )
289
+
290
+ // "Comparison Options" input element
291
+ const compOptionsInputElement = await page . $ ( compOptionsInputSelector )
292
+ expect ( compOptionsInputElement ) . not . toBeNull ( )
293
+
294
+ // Check that initial results exist with default comparison options
295
+ const initDiffResults = await page . $$ ( resultCardsSelector )
296
+ expect ( initDiffResults ) . not . toHaveLength ( 0 )
297
+ const initDiff31to40Page1Methods = await Promise . all (
298
+ initDiffResults . map ( ( resultCard ) =>
299
+ page . evaluate ( ( el ) => el . innerText . match ( / ^ [ a - z _ ] * / ) [ 0 ] , resultCard )
300
+ )
301
+ )
302
+ expect ( initDiff31to40Page1Methods ) . toHaveLength ( 15 )
303
+ expect ( initDiff31to40Page1Methods ) . toContain ( 'delete_alert' )
304
+
305
+ // Click comparison input
306
+ await compOptionsInputElement ! . click ( )
307
+ const compOptionsOnClick = await page . $$ ( globalOptionsSelector )
308
+ expect ( compOptionsOnClick ) . toHaveLength ( 6 )
309
+
310
+ // Find an option containing the text Missing
311
+ const missingOptionIndex = await page . $$eval ( globalOptionsSelector , ( els ) =>
312
+ els . findIndex ( ( el ) => el ?. textContent ?. match ( 'Missing' ) )
313
+ )
314
+ const missingOption = compOptionsOnClick [ missingOptionIndex ]
315
+ expect ( missingOption ) . not . toBeUndefined ( )
316
+
317
+ // Click that option
318
+ await missingOption . click ( )
319
+ await page . waitForSelector ( resultCardsSelector , { timeout : 5000 } )
320
+
321
+ // Check the URL
322
+ // Would like to do this earlier, but not sure what to wait on
323
+ const compUrl = page . url ( )
324
+ expect ( compUrl ) . toEqual (
325
+ `${ BASE_URL } /3.1/diff/4.0?sdk=py&opts=params%2Ctype%2Cbody%2Cresponse`
326
+ )
327
+
328
+ // Check that there are new results
329
+ const newDiffResults = await page . $$ ( resultCardsSelector )
330
+ expect ( newDiffResults ) . not . toHaveLength ( 0 )
331
+ const newDiff31to40Page1Methods = await Promise . all (
332
+ newDiffResults . map ( ( resultCard ) =>
333
+ page . evaluate ( ( el ) => el . innerText . match ( / ^ [ a - z _ ] * / ) [ 0 ] , resultCard )
334
+ )
335
+ )
336
+ expect ( newDiff31to40Page1Methods ) . toHaveLength ( 15 )
337
+ expect ( newDiff31to40Page1Methods ) . not . toContain ( 'delete_alert' )
338
+ } )
268
339
} )
0 commit comments