OLD | NEW |
1 <!-- | 1 <!-- |
2 Copyright 2014 The Chromium Authors. All rights reserved. | 2 Copyright 2014 The Chromium Authors. All rights reserved. |
3 Use of this source code is governed by a BSD-style license that can be | 3 Use of this source code is governed by a BSD-style license that can be |
4 found in the LICENSE file. | 4 found in the LICENSE file. |
5 --> | 5 --> |
6 | 6 |
| 7 <link rel="import" href="../bower_components/paper-icon-button/paper-icon-button
.html"> |
| 8 |
7 <polymer-element name="ct-test-list" attributes="tests tree"> | 9 <polymer-element name="ct-test-list" attributes="tests tree"> |
8 <template> | 10 <template> |
9 <style> | 11 <style> |
10 :host { | 12 :host { |
11 display: block; | 13 display: block; |
12 } | 14 } |
| 15 |
| 16 paper-icon-button { |
| 17 vertical-align: middle; |
| 18 } |
13 </style> | 19 </style> |
14 <template repeat="{{ test in tests }}"> | 20 <template repeat="{{ groups in testGroups_ }}"> |
15 <!-- FIXME: Find a less redundant UI than repeating the step on each line.
--> | 21 <!-- FIXME: Find a less redundant UI than repeating the step on each line.
--> |
16 <div> | 22 <template repeat="{{ group in groups.tests }}"> |
17 {{ test.step }} | 23 <!-- Case 1: entire step failed --> |
18 <template if="{{ test.testName }}"><a href="{{ test | flakinessDashboard
URL }}">{{ test.testName }}</a></template> | 24 <template if="{{ !group.name }}"> |
19 <template if="{{ !test.testName }}"><b>whole step failed</b></template> | 25 <div>{{ groups.step }} <b>whole step failed</b></div> |
20 </div> | 26 </template> |
| 27 <!-- Case 2: single test failure --> |
| 28 <template if="{{ group.name && (group.tests.length == 1 || group.expande
d) }}"> |
| 29 <template repeat="{{ test in group.tests }}"> |
| 30 <div> |
| 31 {{ groups.step }} |
| 32 <a href="{{ test | flakinessDashboardURL }}">{{ test.testName }}</
a> |
| 33 </div> |
| 34 </template> |
| 35 </template> |
| 36 <!-- Case 3: group of tests failed --> |
| 37 <template if="{{ group.name && group.tests.length > 1 && !group.expanded
}}"> |
| 38 <div> |
| 39 {{ groups.step }} {{ group.name }} ({{ group.tests.length }} Tests) |
| 40 <paper-icon-button id="expand" icon="more-vert" step="{{ groups.step
}}" group="{{ group.name }}" on-click="{{ _expand }}"></paper-icon-button> |
| 41 </div> |
| 42 </template> |
| 43 </template> |
21 </template> | 44 </template> |
22 </template> | 45 </template> |
23 <script> | 46 <script> |
24 Polymer({ | 47 Polymer('ct-test-list', { |
| 48 testsChanged: function() { |
| 49 var groups = {}; |
| 50 if (this.tests) { |
| 51 this.tests.forEach(function(test) { |
| 52 if (!groups[test.step]) |
| 53 groups[test.step] = {}; |
| 54 var testName = test.reasonGroupName(); |
| 55 if (!groups[test.step][testName]) |
| 56 groups[test.step][testName] = []; |
| 57 groups[test.step][testName].push(test); |
| 58 }.bind(this)); |
| 59 } |
| 60 this.testGroups_ = []; |
| 61 Object.keys(groups, function(step, testsByName) { |
| 62 var tests = []; |
| 63 Object.keys(testsByName, function(name, testList) { |
| 64 if (name == 'undefined') |
| 65 name = undefined; |
| 66 tests.push({'name': name, 'tests': testList, 'expanded': false}); |
| 67 }.bind(this)); |
| 68 tests.sortBy('name'); |
| 69 this.testGroups_.push({'step': step, 'tests': tests}); |
| 70 }.bind(this)); |
| 71 this.testGroups_.sortBy('step'); |
| 72 }, |
| 73 |
| 74 _expand: function(evt) { |
| 75 step = evt.target.attributes['step'].value; |
| 76 name = evt.target.attributes['group'].value; |
| 77 this.testGroups_.forEach(function(testGroup) { |
| 78 if (testGroup.step == step) { |
| 79 testGroup.tests.forEach(function(test) { |
| 80 // FIXME: This attribute should be persisted over reloads. |
| 81 if (test.name == name) |
| 82 test.expanded = true; |
| 83 }); |
| 84 } |
| 85 }); |
| 86 }, |
| 87 |
25 flakinessDashboardURL: function(test) { | 88 flakinessDashboardURL: function(test) { |
26 return test.flakinessDashboardURL(this.tree); | 89 return test.flakinessDashboardURL(this.tree); |
27 }, | 90 }, |
28 }); | 91 }); |
29 </script> | 92 </script> |
30 </polymer-element> | 93 </polymer-element> |
OLD | NEW |