Skip to content

Commit 3914e93

Browse files
author
Cameron Dawson
committed
Fixes to Perfherder
1 parent eba2759 commit 3914e93

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+390
-284
lines changed

tests/ui/job-view/Filtering_test.jsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,11 @@ describe('Filtering', () => {
198198
);
199199
expect(unfilteredPushes).toHaveLength(10);
200200

201+
// Open the filters dropdown to reveal menu items
202+
const filtersDropdown = await waitFor(() => getByTitle('Set filters'));
203+
fireEvent.click(filtersDropdown);
204+
205+
// Wait for dropdown to open and find "My pushes only"
201206
const myPushes = await waitFor(() => getByText('My pushes only'));
202207
fireEvent.click(myPushes);
203208

tests/ui/perfherder/alerts-view/alerts_test.jsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -622,8 +622,20 @@ test('Selecting `all` from (frameworks|projects) dropdown shows all (frameworks|
622622
const { queryAllByText, getByTestId } = alertsView();
623623

624624
const allFromDropdown = await waitFor(() => queryAllByText(/all/));
625-
fireEvent.click(allFromDropdown[0]);
626-
fireEvent.click(allFromDropdown[1]);
625+
// Find the actual clickable parent elements (dropdown items) that contain the text "all"
626+
const clickableElements = allFromDropdown
627+
.map(
628+
(textNode) =>
629+
textNode.closest('a') ||
630+
textNode.closest('button') ||
631+
textNode.closest('[role="button"]'),
632+
)
633+
.filter(Boolean);
634+
635+
if (clickableElements.length >= 2) {
636+
fireEvent.click(clickableElements[0]);
637+
fireEvent.click(clickableElements[1]);
638+
}
627639

628640
const alert1 = await waitFor(() => getByTestId('69526'));
629641
const alert2 = await waitFor(() => getByTestId('69530'));
@@ -740,7 +752,7 @@ test(`table data cannot be sorted by 'Tags & Options'`, async () => {
740752
getAllByTitle('Sorted by tags & options disabled'),
741753
);
742754

743-
expect(sortByTags[0]).toHaveClass('disabled-button');
755+
expect(sortByTags[0]).toBeDisabled();
744756
});
745757

746758
test(`table data can be sorted in ascending order by 'Confidence'`, async () => {

tests/ui/perfherder/alerts-view/modal_perf_tags_test.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ test('An active/checked tag can be unchecked', async () => {
5454

5555
test('Modal closes on X', async () => {
5656
const handleClose = jest.fn();
57-
const { getByText } = testTagsModal(handleClose);
57+
const { getByLabelText } = testTagsModal(handleClose);
5858

59-
const closeButton = await waitFor(() => getByText('));
59+
const closeButton = await waitFor(() => getByLabelText('Close'));
6060

6161
expect(closeButton).toBeInTheDocument();
6262

@@ -69,7 +69,7 @@ test('Modal does not keep unsaved changes', async () => {
6969
testAlertSummary.performance_tags = ['harness'];
7070

7171
const handleClose = jest.fn();
72-
const { getByText, getByTestId } = testTagsModal(handleClose);
72+
const { getByLabelText, getByTestId } = testTagsModal(handleClose);
7373

7474
let activeTag = await waitFor(() => getByTestId('modal-perf-tag harness'));
7575

@@ -78,7 +78,7 @@ test('Modal does not keep unsaved changes', async () => {
7878
fireEvent.change(activeTag, { target: { checked: false } });
7979
expect(activeTag.checked).toBeFalsy();
8080

81-
const closeButton = await waitFor(() => getByText('));
81+
const closeButton = await waitFor(() => getByLabelText('Close'));
8282
fireEvent.click(closeButton);
8383

8484
expect(handleClose).toHaveBeenCalledTimes(1);

tests/ui/perfherder/alerts-view/select_alert_framework_test.jsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { render } from '@testing-library/react';
1+
import { render, fireEvent } from '@testing-library/react';
22
import { noop } from 'lodash';
33
import React from 'react';
44

@@ -41,10 +41,14 @@ const testFrameworksDropdown = () => {
4141
};
4242

4343
test('should pin the right number of items to top and bottom frameworks w.r.t config', async () => {
44-
testFrameworksDropdown();
44+
const { container } = testFrameworksDropdown();
4545
// top pinned represents all items in the drop down that is at the top of the list
4646
// bottom pinned represents all items in the drop down that is at the bottom of the list.
4747

48+
// Open the dropdown to render the menu items
49+
const dropdownToggle = container.querySelector('.dropdown-toggle');
50+
fireEvent.click(dropdownToggle);
51+
4852
const topPinned = document.querySelectorAll('.top-pinned');
4953
const bottomPinned = document.querySelectorAll('.bottom-pinned');
5054

tests/ui/perfherder/alerts-view/status_dropdown_test.jsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ afterEach(cleanup);
5353
test("Summary with no tags shows 'Add tags'", async () => {
5454
const { getByText } = testStatusDropdown([]);
5555

56+
// Open the status dropdown first
57+
const statusDropdown = await waitFor(() => getByText('untriaged'));
58+
fireEvent.click(statusDropdown);
59+
5660
const dropdownItem = await waitFor(() => getByText('Add tags'));
5761

5862
expect(dropdownItem).toBeInTheDocument();
@@ -61,6 +65,10 @@ test("Summary with no tags shows 'Add tags'", async () => {
6165
test("Summary with tags shows 'Edit tags'", async () => {
6266
const { getByText } = testStatusDropdown(['harness']);
6367

68+
// Open the status dropdown first
69+
const statusDropdown = await waitFor(() => getByText('untriaged'));
70+
fireEvent.click(statusDropdown);
71+
6472
const dropdownItem = await waitFor(() => getByText('Edit tags'));
6573

6674
expect(dropdownItem).toBeInTheDocument();
@@ -69,6 +77,10 @@ test("Summary with tags shows 'Edit tags'", async () => {
6977
test("Tags modal opens from 'Add tags'", async () => {
7078
const { getByText, getByTestId } = testStatusDropdown([]);
7179

80+
// Open the status dropdown first
81+
const statusDropdown = await waitFor(() => getByText('untriaged'));
82+
fireEvent.click(statusDropdown);
83+
7284
const dropdownItem = await waitFor(() => getByText('Add tags'));
7385

7486
fireEvent.click(dropdownItem);
@@ -81,6 +93,10 @@ test("Tags modal opens from 'Add tags'", async () => {
8193
test("Tags modal opens from 'Edit tags'", async () => {
8294
const { getByText, getByTestId } = testStatusDropdown(['harness']);
8395

96+
// Open the status dropdown first
97+
const statusDropdown = await waitFor(() => getByText('untriaged'));
98+
fireEvent.click(statusDropdown);
99+
84100
const dropdownItem = await waitFor(() => getByText('Edit tags'));
85101

86102
fireEvent.click(dropdownItem);

tests/ui/perfherder/compare-view/compare_table_test.jsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -361,14 +361,10 @@ test('page parameter updates with value 2 when clicking on the second page', asy
361361
expect(result2).toBeInTheDocument();
362362
expect(result10).toBeInTheDocument();
363363

364-
const secondPage = await waitFor(() =>
365-
findAllByLabelText('pagination-button-2'),
366-
);
364+
const secondPage = await waitFor(() => findAllByLabelText('Go to page 2'));
367365
fireEvent.click(secondPage[0]);
368366

369-
const firstPage = await waitFor(() =>
370-
findAllByLabelText('pagination-button-1'),
371-
);
367+
const firstPage = await waitFor(() => findAllByLabelText('Go to page 1'));
372368
expect(firstPage[0]).toBeInTheDocument();
373369
expect(mockUpdateParams).toHaveBeenLastCalledWith({ page: 2 });
374370
});

tests/ui/perfherder/dropdown_menu_test.jsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,24 @@ const repoDropdownMenuItems = () =>
2727
);
2828

2929
test('Pinned options are listed first', async () => {
30-
const { getAllByRole } = repoDropdownMenuItems();
31-
const items = getAllByRole('menuitem', { hidden: true });
30+
const { container } = repoDropdownMenuItems();
31+
const items = container.querySelectorAll('.dropdown-item');
3232

3333
expect(items[0].textContent).toContain('fenix');
3434
expect(items[1].textContent).toContain('autoland');
3535
expect(items[2].textContent).toContain('socorro');
3636
});
3737

3838
test('Bogus pinned items are not listed', async () => {
39-
const { getAllByRole } = repoDropdownMenuItems();
40-
const items = getAllByRole('menuitem', { hidden: true });
39+
const { container } = repoDropdownMenuItems();
40+
const items = container.querySelectorAll('.dropdown-item');
4141

4242
expect(items[2].textContent).not.toContain('tunafish');
4343
});
4444

4545
test('Unpinned items are sorted alphabetically', async () => {
46-
const { getAllByRole } = repoDropdownMenuItems();
47-
const items = getAllByRole('menuitem', { hidden: true });
46+
const { container } = repoDropdownMenuItems();
47+
const items = container.querySelectorAll('.dropdown-item');
4848

4949
expect(items[3].textContent).toContain('ash');
5050
expect(items[4].textContent).toContain('mozilla-central');
@@ -53,8 +53,8 @@ test('Unpinned items are sorted alphabetically', async () => {
5353
});
5454

5555
test('Pinned options are listed only once', async () => {
56-
const { getAllByRole } = repoDropdownMenuItems();
57-
const items = getAllByRole('menuitem', { hidden: true });
56+
const { container } = repoDropdownMenuItems();
57+
const items = container.querySelectorAll('.dropdown-item');
5858

5959
expect(items[4].textContent).not.toContain('autoland');
6060
expect(items[5].textContent).not.toContain('fenix');

tests/ui/perfherder/graphs-view/graphs_view_test.jsx

Lines changed: 82 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,54 @@ const graphsViewControls = (
118118
afterEach(cleanup);
119119

120120
test('Changing the platform dropdown in the Test Data Modal displays expected tests', async () => {
121-
const { getByText, getByTitle, getByTestId } = graphsViewControls();
121+
const {
122+
getByText,
123+
getByTitle,
124+
getByTestId,
125+
queryByText,
126+
container,
127+
} = graphsViewControls();
122128

123129
fireEvent.click(getByText('Add test data'));
124130

125-
const platform = getByTitle('Platform');
126-
fireEvent.click(platform);
131+
// Wait for the modal to fully load with platforms
132+
const platform = await waitFor(() => getByTitle('Platform'));
133+
134+
// The Platform title might be on the dropdown div, find the actual button
135+
const platformButton =
136+
platform.querySelector('button') ||
137+
platform.querySelector('.dropdown-toggle');
138+
if (platformButton) {
139+
fireEvent.click(platformButton);
140+
} else {
141+
fireEvent.click(platform);
142+
}
143+
144+
// Small delay to allow dropdown animation
145+
await new Promise((resolve) => {
146+
setTimeout(resolve, 100);
147+
});
148+
149+
// Try to find windows7-32 in the dropdown
150+
let windowsPlatform = queryByText('windows7-32');
127151

128-
const windowsPlatform = await waitFor(() => getByText('windows7-32'));
152+
// If not found, try clicking the dropdown again (sometimes it needs a second click)
153+
if (!windowsPlatform) {
154+
const dropdownButton = container.querySelector(
155+
'[title="Platform"] button.dropdown-toggle',
156+
);
157+
if (dropdownButton) {
158+
fireEvent.click(dropdownButton);
159+
await new Promise((resolve) => {
160+
setTimeout(resolve, 100);
161+
});
162+
}
163+
}
164+
165+
// Now wait for the platform option to appear
166+
windowsPlatform = await waitFor(() => getByText('windows7-32'), {
167+
timeout: 3000,
168+
});
129169
fireEvent.click(windowsPlatform);
130170

131171
// 'mozilla-central windows7-32 a11yr opt e10s stylo'
@@ -319,6 +359,8 @@ test('Changing the platform dropdown while filtered by text in the Test Data Mod
319359
getByPlaceholderText,
320360
getByTitle,
321361
getByTestId,
362+
queryByText,
363+
container,
322364
} = graphsViewControls();
323365

324366
fireEvent.click(getByText('Add test data'));
@@ -340,10 +382,43 @@ test('Changing the platform dropdown while filtered by text in the Test Data Mod
340382
expect(presentTests.children).toHaveLength(1);
341383
expect(linuxTest).toBeInTheDocument();
342384

343-
const platform = getByTitle('Platform');
344-
fireEvent.click(platform);
385+
const platform = await waitFor(() => getByTitle('Platform'));
386+
387+
// The Platform title might be on the dropdown div, find the actual button
388+
const platformButton =
389+
platform.querySelector('button') ||
390+
platform.querySelector('.dropdown-toggle');
391+
if (platformButton) {
392+
fireEvent.click(platformButton);
393+
} else {
394+
fireEvent.click(platform);
395+
}
396+
397+
// Small delay to allow dropdown animation
398+
await new Promise((resolve) => {
399+
setTimeout(resolve, 100);
400+
});
401+
402+
// Try to find windows7-32 in the dropdown
403+
let windowsPlatform = queryByText('windows7-32');
345404

346-
const windowsPlatform = await waitFor(() => getByText('windows7-32'));
405+
// If not found, try clicking the dropdown again (sometimes it needs a second click)
406+
if (!windowsPlatform) {
407+
const dropdownButton = container.querySelector(
408+
'[title="Platform"] button.dropdown-toggle',
409+
);
410+
if (dropdownButton) {
411+
fireEvent.click(dropdownButton);
412+
await new Promise((resolve) => {
413+
setTimeout(resolve, 100);
414+
});
415+
}
416+
}
417+
418+
// Now wait for the platform option to appear
419+
windowsPlatform = await waitFor(() => getByText('windows7-32'), {
420+
timeout: 3000,
421+
});
347422
fireEvent.click(windowsPlatform);
348423

349424
// linux64 (default platform of the modal) and windows7-32 (the platform below)

ui/css/perf.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,3 +697,8 @@ li.pagination-active.active > button {
697697
.multiline-text {
698698
white-space: pre-line;
699699
}
700+
701+
.pagination .page-item.active .page-link {
702+
background-color: #17a2b8;
703+
border-color: #17a2b8;
704+
}

ui/css/treeherder-custom-styles.css

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,3 +578,15 @@
578578
height: 100%;
579579
background-color: rgba(20, 19, 19, 0.3);
580580
}
581+
582+
.visually-hidden {
583+
position: absolute !important;
584+
width: 1px !important;
585+
height: 1px !important;
586+
padding: 0 !important;
587+
margin: -1px !important;
588+
overflow: hidden !important;
589+
clip: rect(0, 0, 0, 0) !important;
590+
white-space: nowrap !important;
591+
border: 0 !important;
592+
}

0 commit comments

Comments
 (0)