Make baseline data points selectable
[WebKit-https.git] / Websites / perf.webkit.org / browser-tests / chart-revision-range-tests.js
1
2 describe('ChartRevisionRange', () => {
3
4     function importRevisionList(context)
5     {
6         return ChartTest.importChartScripts(context).then(() => {
7             ChartTest.makeModelObjectsForSampleCluster(context);
8             return context.importScripts(['lazily-evaluated-function.js', 'components/chart-revision-range.js'], 'ChartRevisionRange');
9         });
10     }
11
12     describe('revisionList on a non-interactive chart', () => {
13         it('should report the list of revision for the latest point', () => {
14             const context = new BrowsingContext();
15             let evaluator;
16             return importRevisionList(context).then((ChartRevisionRange) => {
17                 const chart = ChartTest.createChartWithSampleCluster(context);
18                 chart.setDomain(ChartTest.sampleCluster.startTime, ChartTest.sampleCluster.endTime);
19                 chart.fetchMeasurementSets();
20
21                 const requests = context.symbols.MockRemoteAPI.requests;
22                 expect(requests.length).to.be(1);
23                 ChartTest.respondWithSampleCluster(requests[0]);
24
25                 evaluator = new ChartRevisionRange(chart);
26                 expect(evaluator.revisionList()).to.be(null);
27
28                 return waitForComponentsToRender(context);
29             }).then(() => {
30                 const revisionList = evaluator.revisionList();
31                 expect(revisionList).to.not.be(null);
32                 expect(revisionList.length).to.be(2);
33
34                 expect(revisionList[0].repository.label()).to.be('SomeApp');
35                 expect(revisionList[0].label).to.be('r4006');
36                 expect(revisionList[0].from).to.be(null);
37                 expect(revisionList[0].to).to.be('4006');
38
39                 expect(revisionList[1].repository.label()).to.be('macOS');
40                 expect(revisionList[1].label).to.be('15C50');
41                 expect(revisionList[1].from).to.be(null);
42                 expect(revisionList[1].to).to.be('15C50');
43             })
44         });
45     });
46
47
48     describe('revisionList on an interactive chart', () => {
49
50         it('should not report the list of revision for the latest point when there is no selection or indicator', () => {
51             const context = new BrowsingContext();
52             let evaluator;
53             return importRevisionList(context).then((ChartRevisionRange) => {
54                 const chart = ChartTest.createInteractiveChartWithSampleCluster(context);
55                 chart.setDomain(ChartTest.sampleCluster.startTime, ChartTest.sampleCluster.endTime);
56                 chart.fetchMeasurementSets();
57
58                 const requests = context.symbols.MockRemoteAPI.requests;
59                 expect(requests.length).to.be(1);
60                 ChartTest.respondWithSampleCluster(requests[0]);
61
62                 evaluator = new ChartRevisionRange(chart);
63                 expect(evaluator.revisionList()).to.be(null);
64
65                 return waitForComponentsToRender(context);
66             }).then(() => {
67                 expect(evaluator.revisionList()).to.be(null);
68             })
69         });
70
71         it('should report the list of revision for the locked indicator with differences to the previous point', () => {
72             const context = new BrowsingContext();
73             let chart;
74             let evaluator;
75             return importRevisionList(context).then((ChartRevisionRange) => {
76                 chart = ChartTest.createInteractiveChartWithSampleCluster(context);
77                 chart.setDomain(ChartTest.sampleCluster.startTime, ChartTest.sampleCluster.endTime);
78                 chart.fetchMeasurementSets();
79
80                 const requests = context.symbols.MockRemoteAPI.requests;
81                 expect(requests.length).to.be(1);
82                 ChartTest.respondWithSampleCluster(requests[0]);
83
84                 evaluator = new ChartRevisionRange(chart);
85                 expect(evaluator.revisionList()).to.be(null);
86
87                 return waitForComponentsToRender(context);
88             }).then(() => {
89                 expect(evaluator.revisionList()).to.be(null);
90
91                 const currentView = chart.sampledTimeSeriesData('current');
92                 chart.setIndicator(currentView.lastPoint().id, true);
93
94                 let revisionList = evaluator.revisionList();
95                 expect(revisionList).to.not.be(null);
96                 expect(revisionList.length).to.be(2);
97
98                 expect(revisionList[0].repository.label()).to.be('SomeApp');
99                 expect(revisionList[0].label).to.be('r4005-r4006');
100                 expect(revisionList[0].from).to.be('4005');
101                 expect(revisionList[0].to).to.be('4006');
102
103                 expect(revisionList[1].repository.label()).to.be('macOS');
104                 expect(revisionList[1].label).to.be('15C50');
105                 expect(revisionList[1].from).to.be(null);
106                 expect(revisionList[1].to).to.be('15C50');
107
108                 chart.setIndicator(1004, true); // Across macOS change.
109
110                 revisionList = evaluator.revisionList();
111                 expect(revisionList.length).to.be(2);
112
113                 expect(revisionList[0].repository.label()).to.be('SomeApp');
114                 expect(revisionList[0].label).to.be('r4004-r4004');
115                 expect(revisionList[0].from).to.be('4004');
116                 expect(revisionList[0].to).to.be('4004');
117
118                 expect(revisionList[1].repository.label()).to.be('macOS');
119                 expect(revisionList[1].label).to.be('15B42 - 15C50');
120                 expect(revisionList[1].from).to.be('15B42');
121                 expect(revisionList[1].to).to.be('15C50');
122             });
123         });
124
125         it('should report the list of revision for the selected range', () => {
126             const context = new BrowsingContext();
127             let chart;
128             let evaluator;
129             return importRevisionList(context).then((ChartRevisionRange) => {
130                 chart = ChartTest.createInteractiveChartWithSampleCluster(context);
131                 chart.setDomain(ChartTest.sampleCluster.startTime, ChartTest.sampleCluster.endTime);
132                 chart.fetchMeasurementSets();
133
134                 const requests = context.symbols.MockRemoteAPI.requests;
135                 expect(requests.length).to.be(1);
136                 ChartTest.respondWithSampleCluster(requests[0]);
137
138                 evaluator = new ChartRevisionRange(chart);
139                 expect(evaluator.revisionList()).to.be(null);
140
141                 return waitForComponentsToRender(context);
142             }).then(() => {
143                 expect(evaluator.revisionList()).to.be(null);
144
145                 const currentView = chart.sampledTimeSeriesData('current');
146                 chart.setSelection([currentView.firstPoint().time + 1, currentView.lastPoint().time - 1]);
147
148                 let revisionList = evaluator.revisionList();
149                 expect(revisionList).to.not.be(null);
150                 expect(revisionList.length).to.be(2);
151
152                 expect(revisionList[0].repository.label()).to.be('SomeApp');
153                 expect(revisionList[0].label).to.be('r4003-r4004'); // 4002 and 4005 are outliers and skipped.
154                 expect(revisionList[0].from).to.be('4003');
155                 expect(revisionList[0].to).to.be('4004');
156
157                 expect(revisionList[1].repository.label()).to.be('macOS');
158                 expect(revisionList[1].label).to.be('15B42 - 15C50');
159                 expect(revisionList[1].from).to.be('15B42');
160                 expect(revisionList[1].to).to.be('15C50');
161             });
162         });
163     });
164
165 });