1 <!-- 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 4 found in the LICENSE file. 5 --> 6 7 <link rel="import" href="../ct-results-panel.html"> 8 9 <link rel="import" href="../../model/ct-step-failure.html"> 10 11 <script> 12 (function () { 13 14 var assert = chai.assert; 15 16 var kExampleFailures = [ 17 new CTStepFailure("testName", "plugins/gesture-events-scrolled.html", 18 { 19 "WebKit Win7 (dbg)": { 20 "expected": "PASS", 21 "is_unexpected": true, 22 "actual": "CRASH", 23 "time": 0.9 24 }, 25 "WebKit Mac10.6 (dbg)": { 26 "expected": "PASS", 27 "is_unexpected": true, 28 "actual": "CRASH", 29 "has_stderr": true, 30 "time": 1.8 31 }, 32 "WebKit Mac10.7 (dbg)": { 33 "expected": "PASS", 34 "is_unexpected": true, 35 "actual": "CRASH", 36 "has_stderr": true, 37 "time": 3.2 38 } 39 }, 40 177164, 177165 41 ), 42 new CTStepFailure("testName", "plugins/transformed-events.html", 43 { 44 "WebKit Win7 (dbg)": { 45 "expected": "PASS", 46 "is_unexpected": true, 47 "actual": "CRASH", 48 "time": 0.6 49 }, 50 "WebKit Mac10.6 (dbg)": { 51 "expected": "PASS", 52 "is_unexpected": true, 53 "actual": "CRASH", 54 "has_stderr": true, 55 "time": 1.4 56 }, 57 "WebKit Mac10.7 (dbg)": { 58 "expected": "PASS", 59 "is_unexpected": true, 60 "actual": "CRASH", 61 "has_stderr": true, 62 "time": 3 63 } 64 }, 65 177164, 177165 66 ), 67 new CTStepFailure("testName", "plugins/gesture-events.html", 68 { 69 "WebKit Win7 (dbg)": { 70 "expected": "PASS", 71 "is_unexpected": true, 72 "actual": "CRASH", 73 "time": 1.7 74 }, 75 "WebKit Mac10.6 (dbg)": { 76 "expected": "PASS", 77 "is_unexpected": true, 78 "actual": "CRASH", 79 "has_stderr": true, 80 "time": 2.5 81 }, 82 "WebKit Mac10.7 (dbg)": { 83 "expected": "PASS", 84 "is_unexpected": true, 85 "actual": "CRASH", 86 "has_stderr": true, 87 "time": 3.4 88 } 89 }, 90 177164, 177165 91 ), 92 ]; 93 94 describe('ct-results-panel', function() { 95 var panel; 96 97 function createPanel() { 98 panel = document.createElement('ct-results-panel'); 99 // FIXME: The results-panel needs to be appended to the DOM so that the flakiness 100 // dashboard's iframe has a window when we grab location off of it, but that 101 // also means that we actually do fetches for the iframes of the foo_step stdio. 102 // This results in some console spam from the 404'ed request. 103 panel.hidden = true; 104 document.body.appendChild(panel); 105 } 106 107 function assignFailures(failures) { 108 // FIXME: This should be a proper CTFailureGroup 109 panel.group = { 110 data: { 111 failures: failures 112 } 113 }; 114 } 115 116 function assignUrl(url) { 117 // FIXME: This should be a proper CTFailureGroup 118 panel.group = { 119 data: { 120 url: url 121 } 122 }; 123 } 124 125 afterEach(function() { 126 panel.remove(); 127 panel = undefined; 128 }); 129 130 it('should show no results', function(done) { 131 createPanel(); 132 setTimeout(function() { 133 var message = panel.shadowRoot.querySelector('.message'); 134 assert.equal(message.textContent, 'Loading...'); 135 136 panel.group = 'this is an invalid group'; 137 138 setTimeout(function() { 139 var message = panel.shadowRoot.querySelector('.message'); 140 assert.equal(message.textContent, 'No results to display.'); 141 done(); 142 }); 143 }); 144 }); 145 146 it('should show tests and results for selected test', function(done) { 147 createPanel(); 148 assignFailures(kExampleFailures); 149 150 setTimeout(function() { 151 assert.notOk(panel.shadowRoot.querySelector('.message')); 152 153 var items = panel.shadowRoot.querySelectorAll('core-menu > div'); 154 assert.lengthOf(items, 3); 155 assert.equal(items[0].textContent, 'plugins/gesture-events-scrolled.html'); 156 assert.equal(items[1].textContent, 'plugins/transformed-events.html'); 157 assert.equal(items[2].textContent, 'plugins/gesture-events.html'); 158 159 var results = panel.shadowRoot.querySelectorAll('ct-results-by-builder'); 160 assert.lengthOf(results, 1); 161 assert.equal(results[0].failure, kExampleFailures[0]); 162 163 panel.shadowRoot.querySelector('core-menu').selected = 2; 164 165 setTimeout(function() { 166 var results = panel.shadowRoot.querySelectorAll('ct-results-by-builder'); 167 assert.lengthOf(results, 1); 168 assert.equal(results[0].failure, kExampleFailures[2]); 169 170 done(); 171 }); 172 }); 173 }); 174 175 it('should show step failure', function(done) { 176 createPanel(); 177 var failure = { 178 testName: null, 179 step: 'foo-step', 180 resultNodesByBuilder: { 181 'WebKit Win7 (dbg)': { 182 actual: 'UNKNOWN', 183 }, 184 }, 185 oldestFailingRevision: 123, 186 newestPassingRevision: 124, 187 }; 188 assignFailures([failure]); 189 190 setTimeout(function() { 191 assert.notOk(panel.shadowRoot.querySelector('.message')); 192 193 var items = panel.shadowRoot.querySelectorAll('core-menu > div'); 194 assert.lengthOf(items, 0); 195 196 var results = panel.shadowRoot.querySelectorAll('ct-results-by-builder'); 197 assert.lengthOf(results, 1); 198 assert.equal(results[0].failure, failure); 199 200 assert.lengthOf(panel.shadowRoot.querySelectorAll('ct-embedded-flakiness-dashboard'), 0); 201 done(); 202 }); 203 }); 204 205 it('should show url failure', function(done) { 206 createPanel(); 207 var url = 'https://url.com'; 208 assignUrl(url); 209 210 setTimeout(function() { 211 assert.notOk(panel.shadowRoot.querySelector('.message')); 212 213 var items = panel.shadowRoot.querySelectorAll('core-menu > div'); 214 assert.lengthOf(items, 0); 215 216 var results = panel.shadowRoot.querySelectorAll('ct-popout-iframe'); 217 assert.lengthOf(results, 1); 218 assert.equal(results[0].src, url); 219 220 assert.lengthOf(panel.shadowRoot.querySelectorAll('ct-embedded-flakiness-dashboard'), 0); 221 done(); 222 }); 223 }); 224 225 }); 226 227 })(); 228 </script> 229