| 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="../ct-failure-card.html"> | 7 <link rel="import" href="../ct-failure-card.html"> |
| 8 | 8 |
| 9 <link rel="import" href="../../model/ct-commit-list-mock.html"> | 9 <link rel="import" href="../../model/ct-commit-list-mock.html"> |
| 10 <link rel="import" href="../../model/ct-commit-log-mock.html"> | 10 <link rel="import" href="../../model/ct-commit-log-mock.html"> |
| 11 <link rel="import" href="../../model/ct-failure-group.html"> | 11 <link rel="import" href="../../model/ct-failure-group.html"> |
| 12 | 12 |
| 13 <script> | 13 <script> |
| 14 (function () { | 14 (function () { |
| 15 | 15 |
| 16 var assert = chai.assert; | 16 var assert = chai.assert; |
| 17 | 17 |
| 18 describe('ct-failure-card', function() { | 18 describe('ct-failure-card', function() { |
| 19 var group; | 19 var group; |
| 20 var card; | 20 var card; |
| 21 var failures; | 21 var failures; |
| 22 | 22 |
| 23 beforeEach(function(done) { | 23 beforeEach(function(done) { |
| 24 card = document.createElement('ct-failure-card'); | 24 card = document.createElement('ct-failure-card'); |
| 25 var cl = new CTCommitListMock(); | 25 var cl = new CTCommitListMock(); |
| 26 group = new CTFailureGroup('', [ | 26 group = new CTFailureGroup('', new CTSheriffFailureGroupData([ |
| 27 new CTFailure('autobot', 'unknown', {someBuilder: {key: 'a'}}, {'blink':
158547}, | 27 new CTFailure('autobot', 'unknown', {someBuilder: {key: 'a'}}, {'blink':
158547}, |
| 28 {'blink':158544})], cl); | 28 {'blink':158544})], cl)); |
| 29 card.group = group; | 29 card.group = group; |
| 30 card.commitLog = new CTCommitLogMock(); | 30 card.commitLog = new CTCommitLogMock(); |
| 31 setTimeout(done); | 31 setTimeout(done); |
| 32 }); | 32 }); |
| 33 | 33 |
| 34 describe('failure card UI', function() { | 34 describe('failure card UI', function() { |
| 35 | 35 |
| 36 it('should select the correct card type', function(done) { |
| 37 assert(card.shadowRoot.querySelector('ct-bot-failure-card') != null, |
| 38 'missing sheriff card'); |
| 39 card.group = new CTFailureGroup('', new CTTrooperFailureGroupData( |
| 40 'details', 'url', {percent_over_median_slo: '6%', |
| 41 percent_over_max_slo: '7%'}, 'cq_latency', '')); |
| 42 setTimeout(function() { |
| 43 assert(card.shadowRoot.querySelector('ct-trooper-card') != null, |
| 44 'missing cq-latency card'); |
| 45 card.group.data.type = 'tree_status'; |
| 46 setTimeout(function() { |
| 47 assert(card.shadowRoot.querySelector('ct-trooper-card') != |
| 48 null, 'missing tree-status card'); |
| 49 card.group.data.type = 'cycle_time'; |
| 50 setTimeout(function() { |
| 51 assert(card.shadowRoot.querySelector('ct-trooper-card') != |
| 52 null, 'missing cycle-time card'); |
| 53 done(); |
| 54 }); |
| 55 }); |
| 56 }); |
| 57 }); |
| 58 |
| 36 it('should have commit summaries', function(done) { | 59 it('should have commit summaries', function(done) { |
| 37 // Expand the first repository so that the <ct-commit>'s are generated. | 60 // Expand the first repository so that the <ct-commit>'s are generated. |
| 38 card.group.commitList.repositories[0].expanded = true; | 61 card.group.data.commitList.repositories[0].expanded = true; |
| 39 | 62 |
| 40 setTimeout(function() { | 63 setTimeout(function() { |
| 41 var list = card.shadowRoot.querySelector('ct-commit-list'); | 64 var list = card.shadowRoot.querySelector('::shadow ct-commit-list'); |
| 42 var commits = list.shadowRoot.querySelectorAll('ct-commit'); | 65 var commits = list.shadowRoot.querySelectorAll('ct-commit'); |
| 43 assert(commits[1].data); | 66 assert(commits[1].data); |
| 44 assert(commits[1].data.summary); | 67 assert(commits[1].data.summary); |
| 45 done(); | 68 done(); |
| 46 }); | 69 }); |
| 47 }); | 70 }); |
| 48 | 71 |
| 49 it('removing a commit summary', function(done) { | 72 it('removing a commit summary', function(done) { |
| 50 card.commitLog.commits['blink']['158545'].summary = undefined; | 73 card.commitLog.commits['blink']['158545'].summary = undefined; |
| 51 card.group.commitList.repositories[0].expanded = true; | 74 card.group.data.commitList.repositories[0].expanded = true; |
| 52 | 75 |
| 53 setTimeout(function() { | 76 setTimeout(function() { |
| 54 var list = card.shadowRoot.querySelector('ct-commit-list'); | 77 var list = card.shadowRoot.querySelector('::shadow ct-commit-list'); |
| 55 var commits = list.shadowRoot.querySelectorAll('ct-commit'); | 78 var commits = list.shadowRoot.querySelectorAll('ct-commit'); |
| 56 assert.notOk(commits[0].data.summary); | 79 assert.notOk(commits[0].data.summary); |
| 57 done(); | 80 done(); |
| 58 }); | 81 }); |
| 59 }); | 82 }); |
| 60 | 83 |
| 61 it('examine should dispatch event', function(done) { | 84 it('examine should dispatch event', function(done) { |
| 62 card.addEventListener('ct-examine-failures', function(event) { | 85 card.addEventListener('ct-examine-failures', function(event) { |
| 63 assert.deepEqual(event.detail.failures, card.group.failures); | 86 assert.deepEqual(event.detail.failures, card.group.failures); |
| 64 done(); | 87 done(); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 done(); | 153 done(); |
| 131 }); | 154 }); |
| 132 }); | 155 }); |
| 133 }); | 156 }); |
| 134 }); | 157 }); |
| 135 | 158 |
| 136 }); | 159 }); |
| 137 | 160 |
| 138 })() | 161 })() |
| 139 </script> | 162 </script> |
| OLD | NEW |