Skip to content
Merged
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
8 changes: 7 additions & 1 deletion src/components/timeline/TrackThread.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,13 @@ class TimelineTrackThreadImpl extends PureComponent<Props> {
} else {
selectLeafCallNode(threadsKey, sampleIndex);
}
focusCallTree();

if (sampleIndex !== null) {
// If the user clicked outside of the activity graph (sampleIndex === null),
// then we don't need to focus the call tree. This action also selects
// the call tree panel, which we don't want either in this case.
focusCallTree();
}
}
if (
typeof threadsKey === 'number' &&
Expand Down
27 changes: 26 additions & 1 deletion src/test/components/ThreadActivityGraph.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ import { Provider } from 'react-redux';

import { render } from 'firefox-profiler/test/fixtures/testing-library';
import { selectedThreadSelectors } from '../../selectors/per-thread';
import { getTimelineType } from '../../selectors/url-state';
import { getTimelineType, getSelectedTab } from '../../selectors/url-state';
import { getLastVisibleThreadTabSlug } from '../../selectors/app';
import { ensureExists } from '../../utils/flow';
import { TimelineTrackThread } from '../../components/timeline/TrackThread';
import { commitRange } from '../../actions/profile-view';
import { changeSelectedTab } from '../../actions/app';

import {
autoMockCanvasContext,
Expand Down Expand Up @@ -261,6 +263,29 @@ describe('ThreadActivityGraph', function () {
expect(getCallNodePath()).toEqual([]);
});

it('when clicking a stack, this selects the call tree panel', function () {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In #4331 I said that I couldn't find existing tests for the activity graph, looks like I found them in this file after all... so I moved the existing test here and added a new one.

const { dispatch, getState, clickActivityGraph } = setup();

dispatch(changeSelectedTab('marker-chart'));

// The full call node at this sample is:
// A -> B -> C -> F -> G
clickActivityGraph(1, 0.2);
expect(getSelectedTab(getState())).toBe('calltree');
expect(getLastVisibleThreadTabSlug(getState())).toBe('calltree');
});

it(`when clicking outside of the graph, this doesn't select the call tree panel`, function () {
const { dispatch, getState, clickActivityGraph } = setup();

dispatch(changeSelectedTab('marker-chart'));

// There's no sample at this location.
clickActivityGraph(0, 1);
expect(getSelectedTab(getState())).toBe('marker-chart');
expect(getLastVisibleThreadTabSlug(getState())).toBe('marker-chart');
});

it('will redraw even when there are no samples in range', function () {
const { dispatch } = setup();
flushDrawLog();
Expand Down
16 changes: 0 additions & 16 deletions src/test/components/TrackThread.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,9 @@ import {
changeInvertCallstack,
changeSelectedCallNode,
} from '../../actions/profile-view';
import { changeSelectedTab } from '../../actions/app';
import { TimelineTrackThread } from '../../components/timeline/TrackThread';
import { getPreviewSelection } from '../../selectors/profile';
import { selectedThreadSelectors } from '../../selectors/per-thread';
import { getSelectedTab } from '../../selectors/url-state';
import { getLastVisibleThreadTabSlug } from '../../selectors/app';
import { ensureExists } from '../../utils/flow';

import {
Expand Down Expand Up @@ -191,19 +188,6 @@ describe('timeline/TrackThread', function () {
expect(getCallNodePath()).toEqual(['j', 'k', 'l']);
});

it('when clicking a stack, this selects the call tree panel', function () {
const { dispatch, getState, stackGraphCanvas, getFillRectCenterByIndex } =
setup(getSamplesProfile());

dispatch(changeSelectedTab('marker-chart'));

const log = flushDrawLog();

fireFullClick(stackGraphCanvas(), getFillRectCenterByIndex(log, 0));
expect(getSelectedTab(getState())).toBe('calltree');
expect(getLastVisibleThreadTabSlug(getState())).toBe('calltree');
});

it('can click a stack in the stack graph in inverted call trees', function () {
const {
dispatch,
Expand Down