forked from firefox-devtools/profiler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuseful-tabs.test.js
108 lines (98 loc) · 3.5 KB
/
useful-tabs.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// @flow
import { selectedThreadSelectors } from '../../selectors/per-thread';
import { storeWithProfile } from '../fixtures/stores';
import {
getProfileFromTextSamples,
getProfileWithMarkers,
getNetworkMarkers,
getProfileWithJsTracerEvents,
getMergedProfileFromTextSamples,
addActiveTabInformationToProfile,
} from '../fixtures/profiles/processed-profile';
import { changeTimelineTrackOrganization } from 'firefox-profiler/actions/receive-profile';
describe('getUsefulTabs', function () {
it('hides the network chart and JS tracer when no data is in the thread', function () {
const { profile } = getProfileFromTextSamples('A');
const { getState } = storeWithProfile(profile);
expect(selectedThreadSelectors.getUsefulTabs(getState())).toEqual([
'calltree',
'flame-graph',
'stack-chart',
'marker-chart',
'marker-table',
]);
});
it('shows the network chart when network markers are present in the thread', function () {
const profile = getProfileWithMarkers(getNetworkMarkers());
const { getState } = storeWithProfile(profile);
expect(selectedThreadSelectors.getUsefulTabs(getState())).toEqual([
'calltree',
'flame-graph',
'stack-chart',
'marker-chart',
'marker-table',
'network-chart',
]);
});
it('shows the js tracer when it is available in a thread', function () {
const profile = getProfileWithJsTracerEvents([['A', 0, 10]]);
const { getState } = storeWithProfile(profile);
expect(selectedThreadSelectors.getUsefulTabs(getState())).toEqual([
'calltree',
'flame-graph',
'stack-chart',
'marker-chart',
'marker-table',
'js-tracer',
]);
});
it('shows only the call tree when a diffing track is selected', function () {
const { profile } = getMergedProfileFromTextSamples('A B C', 'A B B');
const { getState, dispatch } = storeWithProfile(profile);
expect(selectedThreadSelectors.getUsefulTabs(getState())).toEqual([
'calltree',
'flame-graph',
'stack-chart',
'marker-chart',
'marker-table',
]);
dispatch({
type: 'SELECT_TRACK',
selectedThreadIndexes: new Set([2]),
selectedTab: 'calltree',
});
expect(selectedThreadSelectors.getUsefulTabs(getState())).toEqual([
'calltree',
]);
});
it('shows the network chart when network markers are present in the active tab view', function () {
const { profile, parentInnerWindowIDsWithChildren, firstTabTabID } =
addActiveTabInformationToProfile(
getProfileWithMarkers(getNetworkMarkers())
);
// Adding the parent innerWindowID to the first thread's first sample, so
// this thread will be inluded in the active tab view.
profile.threads[0].frameTable.innerWindowID[0] =
parentInnerWindowIDsWithChildren;
const { dispatch, getState } = storeWithProfile(profile);
// Switch to the active tab view.
dispatch(
changeTimelineTrackOrganization({
type: 'active-tab',
tabID: firstTabTabID,
})
);
// Check the tabs and make sure that the network chart is there.
expect(selectedThreadSelectors.getUsefulTabs(getState())).toEqual([
'calltree',
'flame-graph',
'stack-chart',
'marker-chart',
'marker-table',
'network-chart',
]);
});
});