Skip to content

Commit 17afc7b

Browse files
committed
more test warning fixes
1 parent b958658 commit 17afc7b

File tree

19 files changed

+265
-92
lines changed

19 files changed

+265
-92
lines changed
Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,42 @@
11
// Mock for react-resizable-panels in Jest tests
22
import React from 'react';
33

4-
export const PanelGroup = ({ children, direction, onLayout, ...props }) =>
5-
React.createElement(
6-
'div',
7-
{ ...props, className: 'mock-panel-group' },
8-
children,
9-
);
4+
export const PanelGroup = React.forwardRef(
5+
({ children, direction, onLayout, ...props }, ref) => {
6+
React.useImperativeHandle(ref, () => ({
7+
setLayout: () => {},
8+
getLayout: () => [],
9+
}));
10+
return React.createElement(
11+
'div',
12+
{ ...props, className: 'mock-panel-group' },
13+
children,
14+
);
15+
},
16+
);
1017

11-
export const Panel = ({ children, defaultSize, minSize, ...props }) =>
12-
React.createElement('div', { ...props, className: 'mock-panel' }, children);
18+
export const Panel = React.forwardRef(
19+
({ children, defaultSize, minSize, ...props }, ref) => {
20+
React.useImperativeHandle(ref, () => ({
21+
collapse: () => {},
22+
expand: () => {},
23+
getCollapsed: () => false,
24+
getSize: () => defaultSize || 50,
25+
resize: () => {},
26+
}));
27+
return React.createElement(
28+
'div',
29+
{ ...props, className: 'mock-panel' },
30+
children,
31+
);
32+
},
33+
);
1334

14-
export const PanelResizeHandle = ({ className, ...props }) =>
15-
React.createElement('div', {
16-
...props,
17-
className: `mock-panel-resize-handle ${className || ''}`,
18-
});
35+
export const PanelResizeHandle = React.forwardRef(
36+
({ className, ...props }, ref) =>
37+
React.createElement('div', {
38+
...props,
39+
ref,
40+
className: `mock-panel-resize-handle ${className || ''}`,
41+
}),
42+
);

tests/ui/job-view/AppHistory_test.jsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import fetchMock from 'fetch-mock';
3-
import { render } from '@testing-library/react';
3+
import { render, act } from '@testing-library/react';
44
import { Provider, ReactReduxContext } from 'react-redux';
55
import { ConnectedRouter } from 'connected-react-router';
66

@@ -67,7 +67,9 @@ describe('history', () => {
6767
});
6868

6969
afterEach(() => {
70-
history.push('/');
70+
act(() => {
71+
history.push('/');
72+
});
7173
});
7274

7375
afterAll(() => {

tests/ui/job-view/Filtering_test.jsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import fetchMock from 'fetch-mock';
3-
import { render, fireEvent, waitFor } from '@testing-library/react';
3+
import { render, fireEvent, waitFor, act } from '@testing-library/react';
44
import { ConnectedRouter } from 'connected-react-router';
55
import { Provider, ReactReduxContext } from 'react-redux';
66
import { createBrowserHistory } from 'history';
@@ -77,7 +77,11 @@ describe('Filtering', () => {
7777
taskDefinition,
7878
);
7979
});
80-
afterEach(() => history.push('/'));
80+
afterEach(() => {
81+
act(() => {
82+
history.push('/');
83+
});
84+
});
8185

8286
afterAll(() => {
8387
fetchMock.reset();

tests/ui/job-view/PushList_test.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
fireEvent,
99
getAllByTestId,
1010
cleanup,
11+
act,
1112
} from '@testing-library/react';
1213
import { createBrowserHistory } from 'history';
1314

@@ -38,7 +39,9 @@ describe('PushList', () => {
3839

3940
beforeEach(() => {
4041
history = createBrowserHistory();
41-
history.push(`/jobs?repo=${repoName}`);
42+
act(() => {
43+
history.push(`/jobs?repo=${repoName}`);
44+
});
4245
});
4346

4447
const currentRepo = {

tests/ui/job-view/bugfiler_test.jsx

Lines changed: 49 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@ import React from 'react';
22
import { Provider } from 'react-redux';
33
import thunk from 'redux-thunk';
44
import 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';
612
import configureMockStore from 'redux-mock-store';
713

814
import { 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
});

tests/ui/job-view/selected_job_test.jsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
import React from 'react';
22
import { Provider, ReactReduxContext } from 'react-redux';
3-
import { render, cleanup, fireEvent, waitFor } from '@testing-library/react';
3+
import {
4+
render,
5+
cleanup,
6+
fireEvent,
7+
waitFor,
8+
act,
9+
} from '@testing-library/react';
410
import { createBrowserHistory } from 'history';
511
import { ConnectedRouter } from 'connected-react-router';
612

@@ -98,7 +104,9 @@ test('filter change keeps selected job visible', async () => {
98104
fireEvent.mouseDown(spell);
99105
await waitFor(() => expect(spell).toHaveClass('selected-job'));
100106

101-
filterModel.addFilter('searchStr', 'linux');
107+
act(() => {
108+
filterModel.addFilter('searchStr', 'linux');
109+
});
102110
rerender(testPushJobs(filterModel));
103111

104112
const spell2 = getByText('spell');

0 commit comments

Comments
 (0)