forked from web-platform-tests/wpt.fyi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwpt-insights.js
181 lines (163 loc) · 4.41 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
/**
* 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 './browser-picker.js';
import './info-banner.js';
import { DefaultBrowserNames, ProductInfo } from './product-info.js';
import { TestStatuses } from './test-info.js';
import { WPTFlags } from './wpt-flags.js';
class Insights extends ProductInfo(WPTFlags(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>
`;
}
static get is() {
return 'wpt-insights';
}
}
window.customElements.define(Insights.is, Insights);
const cardStyle = html`
<style>
paper-card {
display: block;
margin-top: 1em;
width: 100%;
}
.query {
word-break: break-all;
}
</style>
`;
class Flakes extends ProductInfo(PolymerElement) {
static get is() {
return 'wpt-flakes';
}
static get template() {
return html`
${cardStyle}
<paper-card>
<div class="card-content">
<h3>Flakes</h3>
<browser-picker browser="{{browser}}"></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`
${cardStyle}
<paper-card>
<div class="card-content">
<h3>Anomalies</h3>
<browser-picker browser="{{browser}}"></browser-picker>
<info-banner>
<a class="query" href="[[url]]">[[query]]</a>
</info-banner>
<p>
Tests that are failing in [[browserDisplayName]], but passing in the other browsers ([[others]])
</p>
</div>
</paper-card>
`;
}
static get properties() {
return {
browser: String,
browserDisplayName: {
type: String,
computed: 'displayName(browser)',
},
others: {
type: String,
computed: 'computeOthers(browser)',
},
query: {
type: String,
computed: 'computeQuery(browser)',
},
url: {
type: URL,
computed: 'computeURL(query)',
}
};
}
computeOthers(browser) {
return DefaultBrowserNames
.filter(b => b !== browser)
.map(b => this.displayName(b))
.join(', ');
}
computeQuery(browser) {
const othersPassing = DefaultBrowserNames
.filter(b => b !== browser)
.map(o => `(${o}:pass|${o}:ok)`)
.join(' ');
return `(${browser}:!pass&${browser}:!ok) ${othersPassing}`;
}
computeURL(query) {
const url = new URL('/results/', window.location);
url.searchParams.set('q', query);
return url;
}
}
window.customElements.define(Anomalies.is, Anomalies);
export { Insights, Anomalies, Flakes };