OLD | NEW |
(Empty) | |
| 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-failure-card.html"> |
| 8 |
| 9 <link rel="import" href="../../model/ct-failure-group.html"> |
| 10 |
| 11 <script> |
| 12 (function () { |
| 13 |
| 14 var assert = chai.assert; |
| 15 |
| 16 describe('ct-failure-group', function() { |
| 17 var group; |
| 18 var card; |
| 19 |
| 20 beforeEach(function(done) { |
| 21 card = document.createElement('ct-failure-card'); |
| 22 group = new CTFailureGroup('key', []); |
| 23 card.group = group; |
| 24 setTimeout(done); |
| 25 }); |
| 26 |
| 27 describe('failure group UI', function(done) { |
| 28 it('examine should dispatch event', function() { |
| 29 card.addEventListener('ct-examine-failures', function(event) { |
| 30 assert.deepEqual(event.detail.failures, []); |
| 31 setTimeout(done); |
| 32 }); |
| 33 |
| 34 card.shadowRoot.getElementById('examine').dispatchEvent(new CustomEvent('t
ap')); |
| 35 }); |
| 36 |
| 37 it('adding a bug number should show link', function(done) { |
| 38 group.setBug(123); |
| 39 |
| 40 setTimeout(function() { |
| 41 var links = card.shadowRoot.querySelectorAll('a'); |
| 42 assert.lengthOf(links, 1); |
| 43 assert.match(links[0].href, /crbug.com\/123/); |
| 44 setTimeout(done); |
| 45 }); |
| 46 }); |
| 47 |
| 48 it('should not show link without a bug number', function() { |
| 49 var links = card.shadowRoot.querySelectorAll('a'); |
| 50 assert.lengthOf(links, 0); |
| 51 }); |
| 52 |
| 53 it('clicking link bug should show dialog', function(done) { |
| 54 card.shadowRoot.getElementById('link-bug').dispatchEvent(new CustomEvent('
tap')); |
| 55 setTimeout(function() { |
| 56 var dialog = card.shadowRoot.getElementById('bugDialog'); |
| 57 assert.isTrue(dialog.opened); |
| 58 var bugField = card.shadowRoot.getElementById('bug'); |
| 59 bugField.value = '999'; |
| 60 card.shadowRoot.getElementById('dialogOk').dispatchEvent(new CustomEvent
('tap')); |
| 61 setTimeout(function() { |
| 62 assert.equal(group.bug, 'http://crbug.com/999'); |
| 63 assert.equal(group.bugLabel, 'Bug 999'); |
| 64 assert.equal(group._annotation.bug, 'http://crbug.com/999'); |
| 65 setTimeout(done); |
| 66 }); |
| 67 }); |
| 68 }); |
| 69 |
| 70 it('entering URLs should work for bugs', function(done) { |
| 71 card.shadowRoot.getElementById('link-bug').dispatchEvent(new CustomEvent('
tap')); |
| 72 setTimeout(function() { |
| 73 var dialog = card.shadowRoot.getElementById('bugDialog'); |
| 74 assert.isTrue(dialog.opened); |
| 75 var bugField = card.shadowRoot.getElementById('bug'); |
| 76 bugField.value = 'http://foo.com/?id=888'; |
| 77 card.shadowRoot.getElementById('dialogOk').dispatchEvent(new CustomEvent
('tap')); |
| 78 setTimeout(function() { |
| 79 assert.equal(group.bug, 'http://foo.com/?id=888'); |
| 80 assert.equal(group.bugLabel, 'Bug 888'); |
| 81 assert.equal(group._annotation.bug, 'http://foo.com/?id=888'); |
| 82 setTimeout(done); |
| 83 }); |
| 84 }); |
| 85 }); |
| 86 }); |
| 87 |
| 88 }); |
| 89 |
| 90 })() |
| 91 </script> |
OLD | NEW |