Skip to content

Commit

Permalink
Update all existing tests with legacy rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
vrigal committed Jun 21, 2024
1 parent 584851d commit 0b23726
Show file tree
Hide file tree
Showing 45 changed files with 296 additions and 171 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,9 @@
"@pollyjs/adapter-puppeteer": "5.1.1",
"@pollyjs/core": "5.1.1",
"@pollyjs/persister-fs": "6.0.6",
"@testing-library/jest-dom": "6.1.6",
"@testing-library/react": "12.0.0",
"@testing-library/dom": "10.1.0",
"@testing-library/jest-dom": "6.4.6",
"@testing-library/react": "16.0.0",
"babel-loader": "9.1.3",
"clean-webpack-plugin": "4.0.0",
"copy-webpack-plugin": "12.0.2",
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/job-view/AppHistory_test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ describe('history', () => {
history.push(
'/#/jobs?repo=try&revision=07615c30668c70692d01a58a00e7e271e69ff6f1',
);
render(testApp());
render(testApp(), { legacyRoot: true });

expect(history.location).toEqual(
expect.objectContaining({
Expand All @@ -78,7 +78,7 @@ describe('history', () => {
});

test('lack of a specified route should redirect to jobs view with a default repo', () => {
render(testApp());
render(testApp(), { legacyRoot: true });

expect(history.location).toEqual(
expect.objectContaining({
Expand Down
8 changes: 4 additions & 4 deletions tests/ui/job-view/AppRoutes_test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('Test for backwards-compatible routes for other apps', () => {
history.push(
'/pushhealth.html?repo=autoland&revision=3c8e093335315c42a87eebf0531effe9cd6fdb95',
);
render(testApp());
render(testApp(), { legacyRoot: true });

expect(history.location).toEqual(
expect.objectContaining({
Expand All @@ -56,7 +56,7 @@ describe('Test for backwards-compatible routes for other apps', () => {
fetchMock.get('/api/performance/tag/', []);

history.push('/perf.html#/alerts?id=27285&hideDwnToInv=0');
render(testApp());
render(testApp(), { legacyRoot: true });

expect(history.location).toEqual(
expect.objectContaining({
Expand All @@ -71,7 +71,7 @@ describe('Test for backwards-compatible routes for other apps', () => {
history.push(
'/logviewer.html#/jobs?job_id=319893964&repo=autoland&lineNumber=2728',
);
render(testApp());
render(testApp(), { legacyRoot: true });

expect(history.location).toEqual(
expect.objectContaining({
Expand All @@ -88,7 +88,7 @@ describe('Test for backwards-compatible routes for other apps', () => {
history.push(
'/perfherder/compare?originalProject=mozilla-central&originalRevision=54e7fb66ad44b8dcb8caab587f929dad60932d71&newProject=mozilla-central&newRevision=54e7fb66ad44b8dcb8caab587f929dad60932d71&framework=1&page=1#tableLink-header-134266337',
);
render(testApp());
render(testApp(), { legacyRoot: true });

expect(history.location).toEqual(
expect.objectContaining({
Expand Down
8 changes: 5 additions & 3 deletions tests/ui/job-view/App_test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ describe('App', () => {
});

test('should have links to Perfherder and Intermittent Failures View', async () => {
const { getByText, getByAltText } = render(testApp());
const { getByText, getByAltText } = render(testApp(), { legacyRoot: true });
const appMenu = await waitFor(() => getByAltText('Treeherder'));

expect(appMenu).toBeInTheDocument();
Expand All @@ -160,7 +160,9 @@ describe('App', () => {
secondJobSymbol,
secondJobTaskId,
) => {
const { getByText, findByText, findByTestId } = render(testApp());
const { getByText, findByText, findByTestId } = render(testApp(), {
legacyRoot: true,
});
const firstJob = await findByText(firstJobSymbol);

fireEvent.mouseDown(firstJob);
Expand Down Expand Up @@ -228,7 +230,7 @@ describe('App', () => {
});

test('changing repo updates ``currentRepo``', async () => {
const { getByText, getByTitle } = render(testApp());
const { getByText, getByTitle } = render(testApp(), { legacyRoot: true });

const autolandRevision = await waitFor(() => getByText('ba9c692786e9'));
expect(autolandRevision).toBeInTheDocument();
Expand Down
48 changes: 36 additions & 12 deletions tests/ui/job-view/Filtering_test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ describe('Filtering', () => {
test('should have 1 push', async () => {
const { getAllByText, getAllByTestId, getByText, getByTitle } = render(
testApp(),
{ legacyRoot: true },
);
const unfilteredPushes = await waitFor(() =>
getAllByTestId('push-header'),
Expand All @@ -216,7 +217,9 @@ describe('Filtering', () => {

describe('by failure result', () => {
test('should have 10 failures', async () => {
const { getByTitle, findAllByText, queryAllByText } = render(testApp());
const { getByTitle, findAllByText, queryAllByText } = render(testApp(), {
legacyRoot: true,
});

await findAllByText('B');
const unclassifiedOnlyButton = getByTitle(
Expand All @@ -242,7 +245,9 @@ describe('Filtering', () => {
expect(jobCount()).toBe(50);
});
test('KeyboardShortcut u: toggle unclassified jobs', async () => {
const { queryAllByText, getAllByText } = render(testApp());
const { queryAllByText, getAllByText } = render(testApp(), {
legacyRoot: true,
});
const symbolToRemove = 'yaml';
await waitFor(() => getAllByText(symbolToRemove));
fireEvent.keyDown(document.body, { key: 'u', keyCode: 85 });
Expand Down Expand Up @@ -295,7 +300,9 @@ describe('Filtering', () => {
};

test('click signature should have 10 jobs', async () => {
const { getByTitle, findAllByText } = render(testApp());
const { getByTitle, findAllByText } = render(testApp(), {
legacyRoot: true,
});

const build = await findAllByText('B');

Expand All @@ -311,7 +318,10 @@ describe('Filtering', () => {
});

test('string "yaml" should have 10 jobs', async () => {
const { getAllByText, findAllByText, queryAllByText } = render(testApp());
const { getAllByText, findAllByText, queryAllByText } = render(
testApp(),
{ legacyRoot: true },
);
await findAllByText('B');
const filterField = document.querySelector('#quick-filter');
setFilterText(filterField, 'yaml');
Expand All @@ -328,7 +338,7 @@ describe('Filtering', () => {
});

test('KeyboardShortcut f: focus the quick filter input', async () => {
const { findAllByText } = render(testApp());
const { findAllByText } = render(testApp(), { legacyRoot: true });
await findAllByText('B');

const filterField = document.querySelector('#quick-filter');
Expand All @@ -344,7 +354,7 @@ describe('Filtering', () => {
getAllByText,
getByPlaceholderText,
queryAllByText,
} = render(testApp());
} = render(testApp(), { legacyRoot: true });
await findAllByText('B');
const filterField = getByPlaceholderText('Filter platforms & jobs');
setFilterText(filterField, 'yaml');
Expand Down Expand Up @@ -373,7 +383,10 @@ describe('Filtering', () => {
};

test('uncheck success should leave 30 jobs', async () => {
const { getAllByText, findAllByText, queryAllByText } = render(testApp());
const { getAllByText, findAllByText, queryAllByText } = render(
testApp(),
{ legacyRoot: true },
);

await findAllByText('B');
clickFilterChicklet('green');
Expand All @@ -391,7 +404,10 @@ describe('Filtering', () => {
});

test('uncheck failures should leave 20 jobs', async () => {
const { getAllByText, findAllByText, queryAllByText } = render(testApp());
const { getAllByText, findAllByText, queryAllByText } = render(
testApp(),
{ legacyRoot: true },
);
const symbolToRemove = 'B';

await findAllByText(symbolToRemove);
Expand All @@ -410,7 +426,10 @@ describe('Filtering', () => {
});

test('uncheck in progress should leave 20 jobs', async () => {
const { getAllByText, findAllByText, queryAllByText } = render(testApp());
const { getAllByText, findAllByText, queryAllByText } = render(
testApp(),
{ legacyRoot: true },
);
const symbolToRemove = 'yaml';

await findAllByText('B');
Expand All @@ -428,7 +447,9 @@ describe('Filtering', () => {
});

test('KeyboardShortcut i: toggle off in-progress tasks', async () => {
const { getAllByText, queryAllByText } = render(testApp());
const { getAllByText, queryAllByText } = render(testApp(), {
legacyRoot: true,
});
const symbolToRemove = 'yaml';

await waitFor(() => getAllByText(symbolToRemove));
Expand All @@ -445,7 +466,10 @@ describe('Filtering', () => {
});

test('KeyboardShortcut i: toggle on in-progress tasks', async () => {
const { getAllByText, findAllByText, queryAllByText } = render(testApp());
const { getAllByText, findAllByText, queryAllByText } = render(
testApp(),
{ legacyRoot: true },
);
const symbolToRemove = 'yaml';

await waitFor(() => getAllByText(symbolToRemove));
Expand All @@ -469,7 +493,7 @@ describe('Filtering', () => {

test('Filters | Reset should get back to original set of jobs', async () => {
const { getAllByText, findAllByText, findByText, queryAllByText } =
render(testApp());
render(testApp(), { legacyRoot: true });
const symbolToRemove = 'yaml';

await findAllByText('B');
Expand Down
16 changes: 10 additions & 6 deletions tests/ui/job-view/PushList_test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,13 @@ describe('PushList', () => {
const push2Id = 'push-511137';

test('should have 2 pushes', async () => {
render(testPushList());
render(testPushList(), { legacyRoot: true });

expect(await pushCount()).toHaveLength(2);
});

test('should switch to single loaded revision', async () => {
const { getAllByTitle } = render(testPushList());
const { getAllByTitle } = render(testPushList(), { legacyRoot: true });

expect(await pushCount()).toHaveLength(2);
const pushLinks = await getAllByTitle('View only this push');
Expand All @@ -175,7 +175,9 @@ describe('PushList', () => {
});

test('should reload pushes when setting fromchange', async () => {
const { queryAllByTestId, queryByTestId } = render(testPushList());
const { queryAllByTestId, queryByTestId } = render(testPushList(), {
legacyRoot: true,
});

expect(await pushCount()).toHaveLength(2);

Expand All @@ -200,7 +202,7 @@ describe('PushList', () => {
});

test('should reload pushes when setting tochange', async () => {
const { getByTestId } = render(testPushList());
const { getByTestId } = render(testPushList(), { legacyRoot: true });

expect(await pushCount()).toHaveLength(2);

Expand All @@ -223,7 +225,9 @@ describe('PushList', () => {
});

test('should load N more pushes when click next N', async () => {
const { getByTestId, getAllByTestId } = render(testPushList());
const { getByTestId, getAllByTestId } = render(testPushList(), {
legacyRoot: true,
});
const nextNUrl = (count) =>
getProjectUrl(`/push/?full=true&count=${count + 1}&push_timestamp__lte=`);
const clickNext = (count) =>
Expand Down Expand Up @@ -272,7 +276,7 @@ describe('PushList', () => {
});

test('jobs should have fields required for retriggers', async () => {
const { getByText } = render(testPushList());
const { getByText } = render(testPushList(), { legacyRoot: true });
const jobEl = await waitFor(() => getByText('yaml'));
const jobInstance = findJobInstance(jobEl.getAttribute('data-job-id'));
const { job } = jobInstance.props;
Expand Down
4 changes: 3 additions & 1 deletion tests/ui/job-view/Push_test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ describe('Push', () => {
// eslint-disable-next-line jest/no-disabled-tests
test.skip('jobs should have test_path field to filter', async () => {
const { store } = configureStore();
const { getByText } = render(testPush(store, new FilterModel()));
const { getByText } = render(testPush(store, new FilterModel()), {
legacyRoot: true,
});

const validateJob = async (name, testPaths) => {
const jobEl = await waitFor(() => getByText(name));
Expand Down
12 changes: 9 additions & 3 deletions tests/ui/job-view/SecondaryNavBar_test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ describe('SecondaryNavBar', () => {
},
router,
});
const { getByText } = render(testSecondaryNavBar(store));
const { getByText } = render(testSecondaryNavBar(store), {
legacyRoot: true,
});

expect(await waitFor(() => getByText(repoName))).toBeInTheDocument();
expect(await waitFor(() => getByText('52'))).toBeInTheDocument();
Expand All @@ -86,7 +88,9 @@ describe('SecondaryNavBar', () => {
},
router,
});
const { getByText } = render(testSecondaryNavBar(store));
const { getByText } = render(testSecondaryNavBar(store), {
legacyRoot: true,
});

expect(await waitFor(() => getByText(repoName))).toBeInTheDocument();
expect(await waitFor(() => getByText('22'))).toBeInTheDocument();
Expand All @@ -106,7 +110,9 @@ describe('SecondaryNavBar', () => {
updateButtonClick: jest.fn(),
};

const { container } = render(testSecondaryNavBar(store, props));
const { container } = render(testSecondaryNavBar(store, props), {
legacyRoot: true,
});
const el = container.querySelector('#revisionChangedLabel');
fireEvent.click(el);
expect(props.updateButtonClick).toHaveBeenCalled();
Expand Down
24 changes: 10 additions & 14 deletions tests/ui/job-view/bugfiler_test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ describe('BugFiler', () => {
search: summary,
};

render(bugFilerComponentSuggestion(suggestion));
render(bugFilerComponentSuggestion(suggestion), { legacyRoot: true });
const area = screen.getAllByRole('textbox');
// TODO: hardcoded '1' in the array index
// TODO: this used to check specific areas of summary,
Expand Down Expand Up @@ -285,8 +285,8 @@ describe('BugFiler', () => {
},
];

render(bugFilerComponentSuggestions(suggestions));
const signatureArea = await screen.getByDisplayValue(
render(bugFilerComponentSuggestions(suggestions), { legacyRoot: true });
const signatureArea = screen.getByDisplayValue(
'[@ servo_arc::HeaderSlice<H,T>::slice]',
);
expect(signatureArea).toBeInTheDocument();
Expand All @@ -302,8 +302,8 @@ describe('BugFiler', () => {
},
];

render(bugFilerComponentSuggestions(suggestions));
const signatureArea = await screen.queryByDisplayValue('test_webvr.html');
render(bugFilerComponentSuggestions(suggestions), { legacyRoot: true });
const signatureArea = screen.queryByDisplayValue('test_webvr.html');
expect(signatureArea).toBeNull();
});

Expand All @@ -316,10 +316,8 @@ describe('BugFiler', () => {
'SUMMARY: AddressSanitizer: heap-use-after-free /builds/worker/checkouts/gecko/mock/folder/file.c:12:34 in mock::MockComponent::MockMethod(mock::squirrel::Weasel*)',
},
];
render(bugFilerComponentSuggestions(suggestions));
const securityIssue = await screen.getByText(
'Report this as a security issue',
);
render(bugFilerComponentSuggestions(suggestions), { legacyRoot: true });
const securityIssue = screen.getByText('Report this as a security issue');
expect(securityIssue).toBeTruthy();
});

Expand All @@ -333,10 +331,8 @@ describe('BugFiler', () => {
},
];

render(bugFilerComponentSuggestions(suggestions));
const securityIssue = await screen.getByText(
'Report this as a security issue',
);
render(bugFilerComponentSuggestions(suggestions), { legacyRoot: true });
const securityIssue = screen.getByText('Report this as a security issue');
expect(securityIssue.checked).toBeFalsy();
});

Expand All @@ -350,7 +346,7 @@ describe('BugFiler', () => {
});

test('should strip omitted leads from thisFailure', async () => {
const { getByTitle } = render(bugFilerComponentSuggestions(PdfSuggestions));
const { getByTitle } = bugFilerComponentSuggestions(PdfSuggestions);

const toggleSummary = getByTitle('expand');
await fireEvent.click(toggleSummary);
Expand Down
Loading

0 comments on commit 0b23726

Please sign in to comment.