Skip to content

Commit

Permalink
Add tests for the Debug Tools column in alerts view (#7731)
Browse files Browse the repository at this point in the history
Bug 1841022 - Add tests for the Debug Tools column in alerts view
  • Loading branch information
alexandru-io committed Sep 13, 2023
1 parent ae4b778 commit f553516
Show file tree
Hide file tree
Showing 4 changed files with 284 additions and 5 deletions.
135 changes: 135 additions & 0 deletions tests/ui/mock/alert_summaries.json
Original file line number Diff line number Diff line change
Expand Up @@ -234,5 +234,140 @@
"prev_push_revision": "c8e9b6a81194dff2d37b4f67d23a419fd4587e49",
"assignee_username": "mozilla-ldap/test_user@mozilla.com",
"assignee_email": "test_user@mozilla.com"
},
{
"id": 38857,
"push_id": 1260291,
"prev_push_id": 1260284,
"created": "2023-06-23T11:16:45.819043",
"triage_due_date": "2023-06-28T11:16:45.819043",
"repository": "autoland",
"framework": 13,
"alerts": [
{
"id": 177726,
"status": 0,
"series_signature": {
"id": 3777239,
"framework_id": 13,
"signature_hash": "635a1c917ca6f35569cf5fed4a1e420b99f3386b",
"machine_platform": "linux1804-64-shippable-qr",
"suite": "imgur",
"test": "SpeedIndex",
"lower_is_better": true,
"has_subtests": false,
"option_collection_hash": "102210fe594ee9b33d82058545b1ed14f4c8206e",
"tags": ["cold", "fission", "webrender"],
"extra_options": ["cold", "fission", "webrender"],
"measurement_unit": "ms",
"suite_public_name": null,
"test_public_name": null
},
"is_regression": false,
"prev_value": 1295.34,
"new_value": 1242.71,
"t_value": 7.06,
"amount_abs": -52.63,
"amount_pct": 4.06,
"summary_id": 38857,
"related_summary_id": null,
"manually_created": false,
"classifier": null,
"starred": false,
"classifier_email": null,
"backfill_record": {
"context": "[]",
"status": 3,
"total_actions_triggered": 4,
"total_backfills_failed": 0,
"total_backfills_successful": 5,
"total_backfills_in_progress": 0
},
"noise_profile": "OK",
"title": "imgur SpeedIndex linux1804-64-shippable-qr opt cold fission webrender"
},
{
"id": 177727,
"status": 0,
"series_signature": {
"id": 3777240,
"framework_id": 13,
"signature_hash": "a8b7d746763f7da0a98c9b8bb97f6e23c8815655",
"machine_platform": "linux1804-64-shippable-qr",
"suite": "imgur",
"test": "FirstVisualChange",
"lower_is_better": true,
"has_subtests": false,
"option_collection_hash": "102210fe594ee9b33d82058545b1ed14f4c8206e",
"tags": ["cold", "fission", "webrender"],
"extra_options": ["cold", "fission", "webrender"],
"measurement_unit": "ms",
"suite_public_name": null,
"test_public_name": null
},
"is_regression": true,
"prev_value": 415.81,
"new_value": 490.25,
"t_value": 7.06,
"amount_abs": 74.44,
"amount_pct": 17.9,
"summary_id": 38857,
"related_summary_id": null,
"manually_created": false,
"classifier": null,
"starred": false,
"classifier_email": null,
"backfill_record": null,
"noise_profile": "SKEWED",
"title": "imgur FirstVisualChange linux1804-64-shippable-qr opt cold fission webrender"
},
{
"id": 177724,
"status": 0,
"series_signature": {
"id": 3777242,
"framework_id": 13,
"signature_hash": "351e863dd09af73f6756585908eef7a42b87f35a",
"machine_platform": "linux1804-64-shippable-qr",
"suite": "imgur",
"test": "ContentfulSpeedIndex",
"lower_is_better": true,
"has_subtests": false,
"option_collection_hash": "102210fe594ee9b33d82058545b1ed14f4c8206e",
"tags": ["cold", "fission", "webrender"],
"extra_options": ["cold", "fission", "webrender"],
"measurement_unit": "ms",
"suite_public_name": null,
"test_public_name": null
},
"is_regression": false,
"prev_value": 1403.18,
"new_value": 1317.94,
"t_value": 7,
"amount_abs": -85.23,
"amount_pct": 6.07,
"summary_id": 38857,
"related_summary_id": null,
"manually_created": false,
"classifier": null,
"starred": false,
"classifier_email": null,
"backfill_record": null,
"noise_profile": "OK",
"title": "imgur ContentfulSpeedIndex linux1804-64-shippable-qr opt cold fission webrender"
}
],
"related_alerts": [],
"status": 0,
"bug_number": null,
"bug_updated": null,
"issue_tracker": 1,
"notes": null,
"revision": "ed3672832487424625691069c34d5cd1c4800783",
"push_timestamp": 1687264464,
"prev_push_revision": "5ade2b37847325019878bde832493c342759d7eb",
"assignee_username": null,
"assignee_email": null,
"performance_tags": ["infra"]
}
]
146 changes: 142 additions & 4 deletions tests/ui/perfherder/alerts-view/alerts_test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ beforeAll(() => {
fetchMock.mock(getApiUrl(endpoints.issueTrackers), testIssueTrackers);

fetchMock.mock(`begin:${getApiUrl(endpoints.alertSummary)}`, {
count: 2,
count: 3,
next: null,
previous: null,
results: testAlertSummaries,
Expand Down Expand Up @@ -251,6 +251,28 @@ describe('alert filtering ignores repository and/or options', () => {
});
});

test('Debug Tools heading not displayed for non-browsertime summaries', async () => {
const alertSummary1 = testAlertSummaries[0];

const { queryByTestId } = alertsViewControls();

expect(
queryByTestId(`${alertSummary1.id.toString()} Debug Tools`),
).not.toBeInTheDocument();
});

test('Debug Tools heading displayed for browsertime summaries', async () => {
const alertSummary1 = testAlertSummaries[2];

const { getByTestId } = alertsViewControls();

const heading = await waitFor(() =>
getByTestId(`${alertSummary1.id.toString()} Debug Tools`),
);

expect(heading).toBeInTheDocument();
});

test('clicking the star icon for an alert updates that alert', async () => {
const { getByTestId } = alertsViewControls();

Expand Down Expand Up @@ -421,6 +443,10 @@ test('selecting the alert summary checkbox then clicking on the reassign button
});

test("display of alert summaries's assignee badge", async () => {
const alertSummary = testAlertSummaries[2];
alertSummary.assignee_email = 'test_user@mozilla.com';
alertSummary.assignee_username = 'mozilla-ldap/test_user@mozilla.com';

const { getAllByTitle, getAllByText } = alertsViewControls();

const ownershipBadges = getAllByTitle('Click to change assignee');
Expand All @@ -437,6 +463,10 @@ test("display of alert summaries's assignee badge", async () => {
});

test("'Take' button hides when clicking on 'Unassigned' badge", async () => {
const alertSummary = testAlertSummaries[2];
alertSummary.assignee_email = 'test_user@mozilla.com';
alertSummary.assignee_username = 'mozilla-ldap/test_user@mozilla.com';

const {
getByText,
queryByText,
Expand All @@ -452,6 +482,10 @@ test("'Take' button hides when clicking on 'Unassigned' badge", async () => {
});

test('setting an assignee on unassigned alert summary updates the badge accordingly', async () => {
const alertSummary = testAlertSummaries[2];
alertSummary.assignee_email = 'test_user@mozilla.com';
alertSummary.assignee_username = 'mozilla-ldap/test_user@mozilla.com';

const { getByText, getByPlaceholderText } = alertsViewControls();

const unassignedBadge = await waitFor(() => getByText('Unassigned'));
Expand All @@ -472,6 +506,10 @@ test('setting an assignee on unassigned alert summary updates the badge accordin
});

test('setting an assignee on an already assigned summary is possible', async () => {
const alertSummary = testAlertSummaries[2];
alertSummary.assignee_email = null;
alertSummary.assignee_username = null;

const { getByText, getByDisplayValue } = alertsViewControls();

const unassignedBadge = await waitFor(() => getByText('test_user'));
Expand Down Expand Up @@ -510,6 +548,10 @@ test("'Escape' from partially editted assignee does not update original assignee
});

test("Clicking on 'Take' prefills with logged in user", async () => {
const alertSummary = testAlertSummaries[2];
alertSummary.assignee_email = 'test_user@mozilla.com';
alertSummary.assignee_username = 'mozilla-ldap/test_user@mozilla.com';

const { getByText, getByDisplayValue } = alertsViewControls();

const takeButton = getByText('Take');
Expand All @@ -524,7 +566,7 @@ test('Alerts retriggered by the backfill bot have a title', async () => {
const { queryAllByTitle } = alertsViewControls();

const titles = await waitFor(() => queryAllByTitle(backfillRetriggeredTitle));
expect(titles).toHaveLength(2);
expect(titles).toHaveLength(3);
});

describe('"My alerts" checkbox\'s display behaviors', () => {
Expand Down Expand Up @@ -560,7 +602,7 @@ test('Framework name is displayed near alert summary', async () => {

const frameworkName = await waitFor(() => queryAllByText(dummyFrameworkName));
// one summary from testAlertSummaries have one bad framework id
expect(frameworkName).toHaveLength(testAlertSummaries.length - 1);
expect(frameworkName).toHaveLength(1);
});

test('Correct message is displayed if the framework id is invalid', async () => {
Expand All @@ -569,7 +611,11 @@ test('Correct message is displayed if the framework id is invalid', async () =>
const frameworkName = await waitFor(() =>
queryAllByText(unknownFrameworkMessage),
);
expect(frameworkName).toHaveLength(1);

// We expect 2 invalid frameworks because one is the alert with different framework id in the first item,
// and the second one is the browsertime alert whose framework_id is not present in frameworks param
// when the AlertsViewControls is mocked
expect(frameworkName).toHaveLength(2);
});

test('Selecting `all` from (frameworks|projects) dropdown shows all (frameworks|projects)', async () => {
Expand Down Expand Up @@ -834,6 +880,7 @@ test('Next alert button should be disable when reaching the last alert', async (

expect(nextScrollButton).not.toBeDisabled();

fireEvent.click(nextScrollButton);
fireEvent.click(nextScrollButton);
fireEvent.click(nextScrollButton);

Expand Down Expand Up @@ -869,6 +916,23 @@ test('Sherlock status 0 in tooltip on alerts', async () => {
await waitFor(() => getByText(alertBackfillResultVisual.preliminary.message));
});

test(`Side-by-side icon is not displayed in Debug Tools column when Sherlock status is 0 (Not backfilled) in tooltip alerts`, async () => {
const alert = testAlertSummaries[2].alerts[0];
alert.backfill_record.status = alertBackfillResultStatusMap.preliminary;
expect(alert.id).toBe(177726);

const { getByTestId, getByText, queryByTestId } = alertsViewControls();
// hovering over the Sherlock icon should display the tooltip
const sherlockIcon = await waitFor(() =>
getByTestId(`alert ${alert.id.toString()} sherlock icon`),
);
fireEvent.mouseOver(sherlockIcon);
await waitFor(() => getByText(alertBackfillResultVisual.preliminary.message));
expect(
queryByTestId(`alert ${alert.id.toString()} side-by-side icon`),
).not.toBeInTheDocument();
});

test('Sherlock status 1 in tooltip on alerts', async () => {
const alert = testAlertSummaries[0].alerts[3];
alert.backfill_record.status =
Expand All @@ -886,6 +950,26 @@ test('Sherlock status 1 in tooltip on alerts', async () => {
);
});

test(`Side-by-side icon is not displayed in Debug Tools column when Sherlock status is 1 (Soon to be backfilled) in tooltip on alerts`, async () => {
const alert = testAlertSummaries[2].alerts[0];
alert.backfill_record.status =
alertBackfillResultStatusMap.readyForProcessing;
expect(alert.id).toBe(177726);

const { getByTestId, getByText, queryByTestId } = alertsViewControls();
// hovering over the Sherlock icon should display the tooltip
const sherlockIcon = await waitFor(() =>
getByTestId(`alert ${alert.id.toString()} sherlock icon`),
);
fireEvent.mouseOver(sherlockIcon);
await waitFor(() =>
getByText(alertBackfillResultVisual.readyForProcessing.message),
);
expect(
queryByTestId(`alert ${alert.id.toString()} side-by-side icon`),
).not.toBeInTheDocument();
});

test('Sherlock status 2 in tooltip on alerts', async () => {
const alert = testAlertSummaries[0].alerts[3];
alert.backfill_record.status = alertBackfillResultStatusMap.backfilled;
Expand All @@ -900,6 +984,24 @@ test('Sherlock status 2 in tooltip on alerts', async () => {
await waitFor(() => getByText(alertBackfillResultVisual.backfilled.message));
});

test(`Side-by-side icon is not displayed in Debug Tools column when Sherlock status is 2 (Backfilling in progress) in tooltip on alerts`, async () => {
const alert = testAlertSummaries[2].alerts[0];
alert.backfill_record.status = alertBackfillResultStatusMap.backfilled;
expect(alert.id).toBe(177726);

const { getByTestId, getByText } = alertsViewControls();
// hovering over the Sherlock icon should display the tooltip
const sherlockIcon = await waitFor(() =>
getByTestId(`alert ${alert.id.toString()} sherlock icon`),
);
fireEvent.mouseOver(sherlockIcon);
await waitFor(() => getByText(alertBackfillResultVisual.backfilled.message));
const sxsIcon = await waitFor(() =>
getByTestId(`alert ${alert.id.toString()} side-by-side icon`),
);
expect(sxsIcon).toBeInTheDocument();
});

test('Sherlock status 3 in tooltip on alerts', async () => {
const alert = testAlertSummaries[0].alerts[3];
alert.backfill_record.status = alertBackfillResultStatusMap.successful;
Expand All @@ -914,6 +1016,24 @@ test('Sherlock status 3 in tooltip on alerts', async () => {
await waitFor(() => getByText(alertBackfillResultVisual.successful.message));
});

test(`Side-by-side icon is displayed in Debug Tools column when Sherlock status is 3 (Backfilled successfully some jobs) in tooltip on alerts`, async () => {
const alert = testAlertSummaries[2].alerts[0];
alert.backfill_record.status = alertBackfillResultStatusMap.successful;
expect(alert.id).toBe(177726);

const { getByTestId, getByText } = alertsViewControls();
// hovering over the Sherlock icon should display the tooltip
const sherlockIcon = await waitFor(() =>
getByTestId(`alert ${alert.id.toString()} sherlock icon`),
);
fireEvent.mouseOver(sherlockIcon);
await waitFor(() => getByText(alertBackfillResultVisual.successful.message));
const sxsIcon = await waitFor(() =>
getByTestId(`alert ${alert.id.toString()} side-by-side icon`),
);
expect(sxsIcon).toBeInTheDocument();
});

test('Sherlock status 4 in tooltip on alerts', async () => {
const alert = testAlertSummaries[0].alerts[3];
alert.backfill_record.status = alertBackfillResultStatusMap.failed;
Expand All @@ -928,6 +1048,24 @@ test('Sherlock status 4 in tooltip on alerts', async () => {
await waitFor(() => getByText(alertBackfillResultVisual.failed.message));
});

test(`Side-by-side icon is displayed in Debug Tools column when Sherlock status is 4 (Backfilling failed for some jobs) in tooltip on alerts`, async () => {
const alert = testAlertSummaries[2].alerts[0];
alert.backfill_record.status = alertBackfillResultStatusMap.failed;
expect(alert.id).toBe(177726);

const { getByTestId, getByText } = alertsViewControls();
// hovering over the Sherlock icon should display the tooltip
const sherlockIcon = await waitFor(() =>
getByTestId(`alert ${alert.id.toString()} sherlock icon`),
);
fireEvent.mouseOver(sherlockIcon);
await waitFor(() => getByText(alertBackfillResultVisual.failed.message));
const sxsIcon = await waitFor(() =>
getByTestId(`alert ${alert.id.toString()} side-by-side icon`),
);
expect(sxsIcon).toBeInTheDocument();
});

test("Alert's ID can be copied to clipboard", async () => {
const { queryAllByTitle } = alertsViewControls();
Object.assign(navigator, {
Expand Down

0 comments on commit f553516

Please sign in to comment.