Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions tests/ui/perfherder/graphs-view/graphs_view_test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,21 @@ import {

fetchMock.mock(`begin:${getApiUrl(endpoints.changelog)}`, changelogData);

// Mock the single-job endpoint so that request resolves in tests
fetchMock.mock(/\/jobs\/\d+\/$/, {
id: 1,
job_type_name: 'test-linux64/opt-talos-tp5o',
job_type_symbol: 'tp5o',
job_group_name: 'Talos performance tests',
platform: 'linux64',
platform_option: 'opt',
result: 'success',
state: 'completed',
submit_timestamp: 0,
start_timestamp: 0,
end_timestamp: 0,
});

const graphData = createGraphData(
testData,
alertSummaries,
Expand Down
35 changes: 34 additions & 1 deletion ui/perfherder/graphs/GraphTooltip.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useLayoutEffect, useRef, useState } from 'react';
import { useEffect, useLayoutEffect, useRef, useState } from 'react';
import PropTypes from 'prop-types';
import countBy from 'lodash/countBy';
import { Button } from 'react-bootstrap';
Expand Down Expand Up @@ -27,6 +27,9 @@ import { notify } from '../../shared/stores/notificationStore';
import { getAction } from '../../helpers/taskcluster';
import { formatTaskclusterError } from '../../helpers/errorMessage';

// Cache job.searchStr so we can hover over multiple data points
const jobSearchStrCache = new Map();

const GraphTooltip = ({
testData,
infraAffectedData,
Expand Down Expand Up @@ -115,11 +118,41 @@ const GraphTooltip = ({
});
}

const cacheKey = `${testDetails.repository_name}/${dataPointDetails.jobId}`;
const [jobSearchStr, setJobSearchStr] = useState(
dataPointDetails.jobId ? jobSearchStrCache.get(cacheKey) || '' : '',
);

useEffect(() => {
if (!dataPointDetails.jobId) return undefined;

if (jobSearchStrCache.has(cacheKey)) {
setJobSearchStr(jobSearchStrCache.get(cacheKey));
return undefined;
}

let cancelled = false;
JobModel.get(testDetails.repository_name, dataPointDetails.jobId)
.then((job) => {
const searchStr = job.searchStr || '';
jobSearchStrCache.set(cacheKey, searchStr);
if (!cancelled) setJobSearchStr(searchStr);
})
.catch(() => {
if (!cancelled) setJobSearchStr('');
});

return () => {
cancelled = true;
};
}, [cacheKey, dataPointDetails.jobId, testDetails.repository_name]);

const jobsUrl = getJobsUrl({
repo: testDetails.repository_name,
revision: dataPointDetails.revision,
selectedJob: dataPointDetails.jobId,
group_state: 'expanded',
...(jobSearchStr ? { searchStr: jobSearchStr.split(' ') } : {}),
});

const createAlert = async () => {
Expand Down