forked from web-platform-tests/wpt.fyi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wpt-insights.js
311 lines (286 loc) · 8.53 KB
/
wpt-insights.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
/**
* Copyright 2018 The WPT Dashboard Project. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
import '../node_modules/@polymer/paper-card/paper-card.js';
import '../node_modules/@polymer/polymer/lib/elements/dom-repeat.js';
import { html, PolymerElement } from '../node_modules/@polymer/polymer/polymer-element.js';
import '../node_modules/@polymer/paper-radio-button/paper-radio-button.js';
import '../node_modules/@polymer/paper-radio-group/paper-radio-group.js';
import './browser-picker.js';
import './channel-picker.js';
import './info-banner.js';
import { AllProducts, DefaultProductSpecs, DefaultBrowserNames, ProductInfo } from './product-info.js';
import { TestStatuses } from './test-info.js';
class Insights extends ProductInfo(PolymerElement) {
static get template() {
return html`
<style>
info-banner {
margin: 0;
}
wpt-anomalies, wpt-flakes {
display: block;
}
</style>
<wpt-anomalies></wpt-anomalies>
<wpt-flakes></wpt-flakes>
<wpt-release-regressions></wpt-release-regressions>
`;
}
static get is() {
return 'wpt-insights';
}
}
window.customElements.define(Insights.is, Insights);
const cardStyle = html`
paper-card {
display: block;
margin-top: 1em;
width: 100%;
}
.query {
word-break: break-all;
}
`;
class Flakes extends ProductInfo(PolymerElement) {
static get is() {
return 'wpt-flakes';
}
static get template() {
return html`
<style>
${cardStyle}
</style>
<paper-card>
<div class="card-content">
<h3>Flakes</h3>
<browser-picker browser="{{browser}}" products="[[allProducts]]"></browser-picker>
<info-banner>
<a class="query" href="[[url]]">[[query]]</a>
</info-banner>
<p>
Tests that have both passing and non-passing results in the last 10 [[browserDisplayName]] runs
</p>
</div>
</paper-card>
`;
}
static get properties() {
return {
browser: String,
browserDisplayName: {
type: String,
computed: 'displayName(browser)',
},
query: {
type: String,
computed: 'computeQuery()',
},
url: {
type: URL,
computed: 'computeURL(browser, query)',
}
};
}
computeQuery() {
const passStatuses =Object.values(TestStatuses).filter(s => s.isPass);
const passing = passStatuses.map(s => `status:${s}`).join('|');
// Ignore UNKNOWN - that's just a missing test.
const notPassing = passStatuses.concat(['unknown']).map(s => `status:!${s}`).join('&');
return `seq((${passing}) (${notPassing})) seq((${notPassing}) (${passing}))`;
}
computeURL(browser, query) {
const url = new URL('/results/', window.location);
url.searchParams.set('q', query);
url.searchParams.set('product', browser);
url.searchParams.set('max-count', 10);
url.searchParams.set('labels', 'master,experimental');
return url;
}
}
window.customElements.define(Flakes.is, Flakes);
class Anomalies extends ProductInfo(PolymerElement) {
static get is() {
return 'wpt-anomalies';
}
static get template() {
return html`
<style>
${cardStyle}
</style>
<paper-card>
<div class="card-content">
<h3>Anomalies</h3>
<div>
<browser-picker browser="{{browser}}" products="[[allProducts]]"></browser-picker>
vs
<browser-multi-picker products="[[allProductsExcept(browser)]]" selected="{{others}}"></browser-multi-picker>
</div>
where [[browserDisplayName]] is the only one
<paper-radio-group selected="{{anomalyType}}">
<paper-radio-button name="failing">Failing</paper-radio-button>
<paper-radio-button name="passing">Passing</paper-radio-button>
</paper-radio-group>
<info-banner>
<a class="query" href="[[url]]">[[query]]</a>
</info-banner>
<p>
Tests that are failing in [[browserDisplayName]], but passing in the other browsers ([[othersDisplayNames]])
</p>
</div>
</paper-card>
`;
}
static get properties() {
return {
browser: String,
browserDisplayName: {
type: String,
computed: 'displayName(browser)',
},
others: {
type: Array,
value: DefaultBrowserNames.filter(b => b !== 'chrome'),
},
othersDisplayNames: {
type: String,
computed: 'computeOthersDisplayNames(others)',
},
anomalyType: {
type: String,
value: 'failing',
},
query: {
type: String,
computed: 'computeQuery(anomalyType, browser, others)',
},
url: {
type: URL,
computed: 'computeURL(query, browser, others)',
}
};
}
allProductsExcept(browser) {
return AllProducts.filter(b => b.browser_name !== browser);
}
computeOthersDisplayNames(others) {
return others
.map(p => this.displayName(p))
.join(', ');
}
computeQuery(anomalyType, browser, others) {
const not = anomalyType === 'passing' ? '!' : '';
const notnot = anomalyType === 'passing' ? '' : '!';
const otherFilters = others
.map(o => `(${o}:${not}pass|${o}:${not}ok)`)
.join(' ');
return `(${browser}:${notnot}pass&${browser}:${notnot}ok) ${otherFilters}`;
}
computeURL(query, browser, others) {
const url = new URL('/results/', window.location);
url.searchParams.set('labels', 'master');
url.searchParams.set('q', query);
const products = [browser, ...others];
if (DefaultProductSpecs.join(',') !== products.join(',')) {
url.searchParams.set('products', products.join(','));
}
return url;
}
}
window.customElements.define(Anomalies.is, Anomalies);
class ReleaseRegressions extends ProductInfo(PolymerElement) {
static get is() {
return 'wpt-release-regressions';
}
static get template() {
return html`
<style>
${cardStyle}
.wrapper {
display: flex;
align-items: center;
}
display-logo {
margin-left: 16px;
margin-right: 16px;
}
display-logo:first-child {
margin-left: 32px;
}
</style>
<paper-card>
<div class="card-content">
<h3>Release Regressions</h3>
<div class="wrapper">
<browser-picker browser="{{browser}}" products="[[allProducts]]"></browser-picker>
<channel-picker browser="[[browser]]" channel="{{channel}}" channels="["beta", "experimental"]"></channel-picker>
<display-logo product="[[channelBrowser]]"></display-logo>
vs
<display-logo product="[[stableBrowser]]"></display-logo>
</div>
<info-banner>
<a class="query" href="[[url]]">[[query]]</a>
</info-banner>
<p>
Tests that are passing in the latest stable [[browserDisplayName]] release,
but not passing in the latest [[channel]] run.
</p>
</div>
</paper-card>
`;
}
static get properties() {
return {
browser: String,
browserDisplayName: {
type: String,
computed: 'displayName(browser)',
},
channel: {
type: String,
value: 'beta',
},
channelBrowser: {
type: Object,
computed: 'computeBrowser(browser, channel)'
},
stableBrowser: {
type: Object,
computed: 'computeBrowser(browser, "stable")'
},
query: {
type: String,
computed: 'computeQuery()',
},
url: {
type: URL,
computed: 'computeURL(browser, channel, query)',
}
};
}
computeQuery() {
const passStatuses = Object.values(TestStatuses).filter(s => s.isPass);
const passing = passStatuses.map(s => `status:${s}`).join('|');
// Ignore UNKNOWN - that's just a missing test.
const notPassing = passStatuses.concat(['unknown']).map(s => `status:!${s}`).join('&');
return `seq((${passing}) (${notPassing}))`;
}
computeURL(browser, channel, query) {
const url = new URL('/results/', window.location);
url.searchParams.set('q', query);
url.searchParams.set('products', `${browser}[stable],${browser}[${channel}]`);
url.searchParams.set('labels', 'master');
url.searchParams.set('diff', 'true');
return url;
}
computeBrowser(browser, channel) {
return {
browser_name: browser,
labels: [channel],
};
}
}
window.customElements.define(ReleaseRegressions.is, ReleaseRegressions);
export { Insights, Anomalies, Flakes, ReleaseRegressions };