forked from web-platform-tests/wpt.fyi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathabstract-test-file-results-table.js
144 lines (132 loc) · 3.56 KB
/
abstract-test-file-results-table.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
/**
* 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/polymer/lib/elements/dom-if.js';
import '../node_modules/@polymer/polymer/lib/elements/dom-repeat.js';
import '../node_modules/@polymer/paper-button/paper-button.js';
import '../node_modules/@polymer/iron-icon/iron-icon.js';
import '../node_modules/@polymer/iron-icons/image-icons.js';
import { html } from '../node_modules/@polymer/polymer/polymer-element.js';
import './test-file-results.js';
import { TestRunsBase } from './test-runs.js';
import { WPTColors } from './wpt-colors.js';
class AbstractTestFileResultsTable extends WPTColors(TestRunsBase) {
static get is() {
return 'abstract-test-file-results-table';
}
static get template() {
return html`
<style include="wpt-colors">
table {
width: 100%;
border-collapse: collapse;
}
th {
background: white;
position: sticky;
top: 0;
z-index: 1;
}
td {
padding: 0;
height: 1.5em;
}
td code, td paper-button {
line-height: 1.6em;
padding: 0 0.25em;
}
td.sub-test-name {
font-family: monospace;
}
td.result {
background-color: #eee;
}
tbody tr:first-child {
border-bottom: 8px solid white;
padding: 8px;
}
paper-button {
float: right;
}
</style>
<table>
<thead>
<tr>
<th width="[[computeSubtestThWidth(testRuns)]]">Subtest</th>
<template is="dom-repeat" items="[[testRuns]]" as="testRun">
<th width="[[computeRunThWidth(testRuns)]]">
<test-run test-run="[[testRun]]"></test-run>
</th>
</template>
</tr>
</thead>
<tbody>
<template is="dom-repeat" items="[[resultsTable]]" as="row">
<tr>
<td class="sub-test-name"><code>[[ row.name ]]</code></td>
<template is="dom-repeat" items="{{row.results}}" as="result">
<td class$="[[ colorClass(result.status) ]]">
<code>[[ subtestMessage(result) ]]</code>
<template is="dom-if" if="[[result.screenshots]]">
<paper-button onclick="[[compareReferences(result)]]">
<iron-icon icon="image:compare"></iron-icon>
Compare
</paper-button>
</template>
</td>
</template>
</tr>
</template>
</tbody>
</table>
`;
}
static get properties() {
return {
statusesAsMessage: {
type: Array,
value: ['OK', 'PASS', 'TIMEOUT'],
},
resultsTable: {
type: Array,
value: [],
},
};
}
constructor() {
super();
this.compareReferences = (result) => {
return () => this.onReftestCompare && this.onReftestCompare(
// Clone the result first.
JSON.parse(JSON.stringify(result)));
};
}
subtestMessage(result) {
// Return status string for messageless status or "status-as-message".
if ((result.status && !result.message) ||
this.statusesAsMessage.includes(result.status)) {
return result.status;
}
if (!result.status) {
return 'MISSING';
}
return '';
}
computeSubtestThWidth(testRuns) {
return `${200 / (testRuns.length + 2)}%`;
}
computeRunThWidth(testRuns) {
return `${100 / (testRuns.length + 2)}%`;
}
colorClass(status) {
if (['OK', 'PASS'].includes(status)) {
return this.passRateClass(1, 1);
} else if (['FAIL', 'ERROR'].includes(status)) {
return this.passRateClass(0, 1);
}
return 'result';
}
}
export { AbstractTestFileResultsTable };