@@ -2,7 +2,13 @@ import React from 'react';
22import { Provider } from 'react-redux' ;
33import thunk from 'redux-thunk' ;
44import fetchMock from 'fetch-mock' ;
5- import { render , cleanup , fireEvent , screen } from '@testing-library/react' ;
5+ import {
6+ render ,
7+ cleanup ,
8+ fireEvent ,
9+ screen ,
10+ waitFor ,
11+ } from '@testing-library/react' ;
612import configureMockStore from 'redux-mock-store' ;
713
814import { bzComponentEndpoint , bzBaseUrl } from '../../../ui/helpers/url' ;
@@ -226,7 +232,7 @@ describe('BugFiler', () => {
226232 </ Provider >
227233 ) ;
228234
229- function SummaryAndExpected ( summary ) {
235+ async function SummaryAndExpected ( summary ) {
230236 const suggestion = {
231237 summary,
232238 search_terms : [
@@ -242,122 +248,128 @@ describe('BugFiler', () => {
242248 } ;
243249
244250 render ( bugFilerComponentSuggestion ( suggestion ) ) ;
251+
252+ // Wait for async findProductByPath to complete
253+ await waitFor ( ( ) => {
254+ expect ( screen . getByText ( 'Intermittent Bug Filer' ) ) . toBeInTheDocument ( ) ;
255+ } ) ;
256+
245257 const area = screen . getAllByRole ( 'textbox' ) ;
246258 // TODO: hardcoded '1' in the array index
247259 // TODO: this used to check specific areas of summary,
248260 // I cannot find the parts individually in the rendered html.
249261 return area [ 1 ] ;
250262 }
251263
252- test ( 'parses a crash suggestion' , ( ) => {
264+ test ( 'parses a crash suggestion' , async ( ) => {
253265 const rawSummary =
254266 'PROCESS-CRASH | browser/components/search/test/browser_searchbar_smallpanel_keyboard_navigation.js | application crashed [@ js::GCMarker::eagerlyMarkChildren]' ;
255267 const expected =
256268 'Intermittent browser/components/search/test/browser_searchbar_smallpanel_keyboard_navigation.js | single tracking bug' ;
257- const displayed = SummaryAndExpected ( rawSummary ) ;
269+ const displayed = await SummaryAndExpected ( rawSummary ) ;
258270 expect ( displayed ) . toHaveValue ( expected ) ;
259271 } ) ;
260272
261- test ( 'should parse mochitest-bc summaries' , ( ) => {
273+ test ( 'should parse mochitest-bc summaries' , async ( ) => {
262274 const rawSummary =
263275 'browser/components/sessionstore/test/browser_625016.js | observe1: 1 window in data written to disk - Got 0, expected 1' ;
264276 const expected =
265277 'Intermittent browser/components/sessionstore/test/browser_625016.js | single tracking bug' ;
266- const displayed = SummaryAndExpected ( rawSummary ) ;
278+ const displayed = await SummaryAndExpected ( rawSummary ) ;
267279 expect ( displayed ) . toHaveValue ( expected ) ;
268280 } ) ;
269281
270- test ( 'should parse accessibility summaries' , ( ) => {
282+ test ( 'should parse accessibility summaries' , async ( ) => {
271283 const rawSummary =
272284 'chrome://mochitests/content/a11y/accessible/tests/mochitest/states/test_expandable.xul' +
273285 ' | uncaught exception - TypeError: this.textbox.popup.oneOffButtons is undefined at ' +
274286 'searchbar_XBL_Constructor@chrome://browser/content/search/search.xml:95:9' ;
275287 const expected =
276288 'Intermittent accessible/tests/mochitest/states/test_expandable.xul | uncaught exception - TypeError: this.textbox.popup.oneOffButtons is undefined at searchbar_XBL_Constructor@chrome://browser/content/search/search.xml:95:9' ;
277- const displayed = SummaryAndExpected ( rawSummary ) ;
289+ const displayed = await SummaryAndExpected ( rawSummary ) ;
278290 expect ( displayed ) . toHaveValue ( expected ) ;
279291 } ) ;
280292
281- test ( 'should parse xpcshell summaries' , ( ) => {
293+ test ( 'should parse xpcshell summaries' , async ( ) => {
282294 const rawSummary =
283295 'xpcshell-child-process.ini:dom/indexedDB/test/unit/test_rename_objectStore_errors.js | application crashed [@ mozalloc_abort(char const*)]' ;
284296 const expected =
285297 'Intermittent dom/indexedDB/test/unit/test_rename_objectStore_errors.js | single tracking bug' ;
286- const displayed = SummaryAndExpected ( rawSummary ) ;
298+ const displayed = await SummaryAndExpected ( rawSummary ) ;
287299 expect ( displayed ) . toHaveValue ( expected ) ;
288300 } ) ;
289301
290- test ( 'should parse xpcshell unpack summaries' , ( ) => {
302+ test ( 'should parse xpcshell unpack summaries' , async ( ) => {
291303 const rawSummary =
292304 'xpcshell-unpack.ini:dom/indexedDB/test/unit/test_rename_objectStore_errors.js | application crashed [@ mozalloc_abort(char const*)]' ;
293305 const expected =
294306 'Intermittent dom/indexedDB/test/unit/test_rename_objectStore_errors.js | single tracking bug' ;
295- const displayed = SummaryAndExpected ( rawSummary ) ;
307+ const displayed = await SummaryAndExpected ( rawSummary ) ;
296308 expect ( displayed ) . toHaveValue ( expected ) ;
297309 } ) ;
298310
299- test ( 'should parse xpcshell dom summaries' , ( ) => {
311+ test ( 'should parse xpcshell dom summaries' , async ( ) => {
300312 const rawSummary =
301313 'xpcshell.ini:dom/indexedDB/test/unit/test_rename_objectStore_errors.js | application crashed [@ mozalloc_abort(char const*)]' ;
302314 const expected =
303315 'Intermittent dom/indexedDB/test/unit/test_rename_objectStore_errors.js | single tracking bug' ;
304- const displayed = SummaryAndExpected ( rawSummary ) ;
316+ const displayed = await SummaryAndExpected ( rawSummary ) ;
305317 expect ( displayed ) . toHaveValue ( expected ) ;
306318 } ) ;
307319
308- test ( 'should parse Windows reftests on C drive summaries' , ( ) => {
320+ test ( 'should parse Windows reftests on C drive summaries' , async ( ) => {
309321 const rawSummary =
310322 'file:///C:/slave/test/build/tests/reftest/tests/layout/reftests/w3c-css/submitted/variables/variable-supports-12.html | application timed out after 330 seconds with no output' ;
311323 const expected =
312324 'Intermittent layout/reftests/w3c-css/submitted/variables/variable-supports-12.html | application timed out after 330 seconds with no output' ;
313- const displayed = SummaryAndExpected ( rawSummary ) ;
325+ const displayed = await SummaryAndExpected ( rawSummary ) ;
314326 expect ( displayed ) . toHaveValue ( expected ) ;
315327 } ) ;
316328
317- test ( 'should parse Linux reftest summaries' , ( ) => {
329+ test ( 'should parse Linux reftest summaries' , async ( ) => {
318330 const rawSummary =
319331 'file:///home/worker/workspace/build/tests/reftest/tests/image/test/reftest/encoders-lossless/size-7x7.png | application timed out after 330 seconds with no output' ;
320332 const expected =
321333 'Intermittent image/test/reftest/encoders-lossless/size-7x7.png | application timed out after 330 seconds with no output' ;
322- const displayed = SummaryAndExpected ( rawSummary ) ;
334+ const displayed = await SummaryAndExpected ( rawSummary ) ;
323335 expect ( displayed ) . toHaveValue ( expected ) ;
324336 } ) ;
325337
326- test ( 'should parse Windows reftests on Z drive summaries' , ( ) => {
338+ test ( 'should parse Windows reftests on Z drive summaries' , async ( ) => {
327339 const rawSummary =
328340 'file:///Z:/task_1491428153/build/tests/reftest/tests/layout/reftests/font-face/src-list-local-full.html == file:///Z:/task_1491428153/build/tests/reftest/tests/layout/reftests/font-face/src-list-local-full-ref.html | image comparison, max difference: 255, number of differing pixels: 5184' ;
329341 const expected =
330342 'Intermittent layout/reftests/font-face/src-list-local-full.html == layout/reftests/font-face/src-list-local-full-ref.html | image comparison, max difference: 255, number of differing pixels: 5184' ;
331- const displayed = SummaryAndExpected ( rawSummary ) ;
343+ const displayed = await SummaryAndExpected ( rawSummary ) ;
332344 expect ( displayed ) . toHaveValue ( expected ) ;
333345 } ) ;
334346
335- test ( 'should parse android reftests summaries' , ( ) => {
347+ test ( 'should parse android reftests summaries' , async ( ) => {
336348 const rawSummary =
337349 'http://10.0.2.2:8854/tests/layout/reftests/css-display/display-contents-style-inheritance-1.html == http://10.0.2.2:8854/tests/layout/reftests/css-display/display-contents-style-inheritance-1-ref.html | image comparison, max difference: 255, number of differing pixels: 699' ;
338350 const expected =
339351 'Intermittent layout/reftests/css-display/display-contents-style-inheritance-1.html == layout/reftests/css-display/display-contents-style-inheritance-1-ref.html | image comparison, max difference: 255, number of differing pixels: 699' ;
340- const displayed = SummaryAndExpected ( rawSummary ) ;
352+ const displayed = await SummaryAndExpected ( rawSummary ) ;
341353 expect ( displayed ) . toHaveValue ( expected ) ;
342354 } ) ;
343355
344- test ( 'should parse reftest unexpected pass summaries' , ( ) => {
356+ test ( 'should parse reftest unexpected pass summaries' , async ( ) => {
345357 const rawSummary =
346358 'REFTEST TEST-UNEXPECTED-PASS | file:///home/worker/workspace/build/tests/reftest/tests/layout/' +
347359 'reftests/backgrounds/vector/empty/wide--cover--width.html == file:///home/worker/workspace/' +
348360 'build/tests/reftest/tests/layout/reftests/backgrounds/vector/empty/ref-wide-lime.html | image comparison' ;
349361 const expected =
350362 'Intermittent TEST-UNEXPECTED-PASS | layout/reftests/backgrounds/vector/empty/wide--cover--width.html == layout/reftests/backgrounds/vector/empty/ref-wide-lime.html | image comparison' ;
351- const displayed = SummaryAndExpected ( rawSummary ) ;
363+ const displayed = await SummaryAndExpected ( rawSummary ) ;
352364 expect ( displayed ) . toHaveValue ( expected ) ;
353365 } ) ;
354366
355- test ( 'should use test name for unexpected crashes if signature missing' , ( ) => {
367+ test ( 'should use test name for unexpected crashes if signature missing' , async ( ) => {
356368 const rawSummary =
357369 'TEST-UNEXPECTED-CRASH | /referrer-policy/gen/top.meta/never/sharedworker-module.http.html | expected OK' ;
358370 const expected =
359371 'Intermittent TEST-UNEXPECTED-CRASH | /referrer-policy/gen/top.meta/never/sharedworker-module.http.html | expected OK' ;
360- const displayed = SummaryAndExpected ( rawSummary ) ;
372+ const displayed = await SummaryAndExpected ( rawSummary ) ;
361373 expect ( displayed ) . toBeInTheDocument ( expected ) ;
362374 } ) ;
363375
@@ -422,18 +434,23 @@ describe('BugFiler', () => {
422434 expect ( securityIssue . checked ) . toBeFalsy ( ) ;
423435 } ) ;
424436
425- test ( 'should parse finding the filename when the `TEST-FOO` is not omitted' , ( ) => {
437+ test ( 'should parse finding the filename when the `TEST-FOO` is not omitted' , async ( ) => {
426438 const rawSummary =
427439 'TEST-UNEXPECTED-CRASH | /service-workers/service-worker/xhr.https.html | expected OK' ;
428440 const expected =
429441 'TEST-UNEXPECTED-CRASH | /service-workers/service-worker/xhr.https.html | expected OK' ;
430- const displayed = SummaryAndExpected ( rawSummary ) ;
442+ const displayed = await SummaryAndExpected ( rawSummary ) ;
431443 expect ( displayed ) . toBeInTheDocument ( expected ) ;
432444 } ) ;
433445
434446 test ( 'should strip omitted leads from thisFailure' , async ( ) => {
435447 render ( bugFilerComponentSuggestions ( PdfSuggestions ) ) ;
436448
449+ // Wait for async state updates to complete
450+ await waitFor ( ( ) => {
451+ expect ( screen . getByText ( 'Intermittent Bug Filer' ) ) . toBeInTheDocument ( ) ;
452+ } ) ;
453+
437454 const toggleSummary = screen . getByTitle ( 'expand' ) ;
438455 await fireEvent . click ( toggleSummary ) ;
439456
@@ -446,21 +463,21 @@ describe('BugFiler', () => {
446463 ) ;
447464 } ) ;
448465
449- test ( 'should have summary as "single tracking bug"' , ( ) => {
466+ test ( 'should have summary as "single tracking bug"' , async ( ) => {
450467 const rawSummary =
451468 'PROCESS-CRASH | application crashed [@ libc.so.6 + 0x0000000000114cf9] | /storage/estimate-usage-details-indexeddb.https.tentative.any.html' ;
452469 const expected =
453470 'application crashed [@ libc.so.6 + 0x0000000000114cf9] | single tracking bug' ;
454- const displayed = SummaryAndExpected ( rawSummary ) ;
471+ const displayed = await SummaryAndExpected ( rawSummary ) ;
455472 expect ( displayed ) . toBeInTheDocument ( expected ) ;
456473 } ) ;
457474
458- test ( 'should NOT have summary as "single tracking bug"' , ( ) => {
475+ test ( 'should NOT have summary as "single tracking bug"' , async ( ) => {
459476 const rawSummary =
460477 'TEST-UNEXPECTED-FAIL | browser/components/extensions/test/browser/browser_ext_contextMenus_targetUrlPatterns.js | Test timed out' ;
461478 const expected =
462479 'TEST-UNEXPECTED-FAIL | browser/components/extensions/test/browser/browser_ext_contextMenus_targetUrlPatterns.js | Test timed out' ;
463- const displayed = SummaryAndExpected ( rawSummary ) ;
480+ const displayed = await SummaryAndExpected ( rawSummary ) ;
464481 expect ( displayed ) . toBeInTheDocument ( expected ) ;
465482 } ) ;
466483} ) ;
0 commit comments