Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(835)

Side by Side Diff: Tools/GardeningServer/ui/test/ct-failure-card-tests.html

Issue 565523002: [Sheriff-o-matic] Refactor cards and get rid of ct-failure-cards (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: ToT-ed Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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-commit-list-mock.html">
10 <link rel="import" href="../../model/ct-commit-log-mock.html">
11 <link rel="import" href="../../model/ct-failure-group.html">
12
13 <script>
14 (function () {
15
16 var assert = chai.assert;
17
18 describe('ct-failure-card', function() {
19 var group;
20 var card;
21 var failures;
22
23 beforeEach(function(done) {
24 card = document.createElement('ct-failure-card');
25 var cl = new CTCommitListMock();
26 group = new CTFailureGroup('', new CTSheriffFailureGroupData([
27 new CTFailure('autobot', 'unknown', {someBuilder: {key: 'a'}}, {'blink': 158547},
28 {'blink':158544})], cl));
29 card.group = group;
30 card.commitLog = new CTCommitLogMock();
31 setTimeout(done);
32 });
33
34 describe('failure card UI', function() {
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
59 it('should have commit summaries', function(done) {
60 // Expand the first repository so that the <ct-commit>'s are generated.
61 card.group.data.commitList.repositories[0].expanded = true;
62
63 setTimeout(function() {
64 var list = card.shadowRoot.querySelector('::shadow ct-commit-list');
65 var commits = list.shadowRoot.querySelectorAll('ct-commit');
66 assert(commits[1].data);
67 assert(commits[1].data.summary);
68 done();
69 });
70 });
71
72 it('removing a commit summary', function(done) {
73 card.commitLog.commits['blink']['158545'].summary = undefined;
74 card.group.data.commitList.repositories[0].expanded = true;
75
76 setTimeout(function() {
77 var list = card.shadowRoot.querySelector('::shadow ct-commit-list');
78 var commits = list.shadowRoot.querySelectorAll('ct-commit');
79 assert.notOk(commits[0].data.summary);
80 done();
81 });
82 });
83
84 it('examine should dispatch event', function(done) {
85 card.addEventListener('ct-examine-failures', function(event) {
86 assert.deepEqual(event.detail.failures, card.group.failures);
87 done();
88 });
89
90 card.shadowRoot.getElementById('examine').dispatchEvent(new CustomEvent('t ap'));
91 });
92
93 it('adding a bug number should show link', function(done) {
94 group.setBug(123);
95
96 setTimeout(function() {
97 var links = card.shadowRoot.querySelectorAll('a');
98 assert.lengthOf(links, 1);
99 assert.match(links[0].href, /crbug.com\/123/);
100 done();
101 });
102 });
103
104 it('should not show link without a bug number', function() {
105 var links = card.shadowRoot.querySelectorAll('a');
106 assert.lengthOf(links, 0);
107 });
108
109 it('clicking link bug should show dialog', function(done) {
110 card.shadowRoot.getElementById('link-bug').dispatchEvent(new CustomEvent(' tap'));
111 setTimeout(function() {
112 var dialog = card.shadowRoot.getElementById('bugDialog');
113 assert.isTrue(dialog.opened);
114 var bugField = card.shadowRoot.getElementById('bug');
115 bugField.value = '999';
116 card.shadowRoot.getElementById('dialogOk').dispatchEvent(new CustomEvent ('tap'));
117 setTimeout(function() {
118 assert.equal(group.bug, 'http://crbug.com/999');
119 assert.equal(group.bugLabel, 'Bug 999');
120 assert.equal(group._annotation.bug, 'http://crbug.com/999');
121 done();
122 });
123 });
124 });
125
126 it('entering URLs should work for bugs', function(done) {
127 card.shadowRoot.getElementById('link-bug').dispatchEvent(new CustomEvent(' tap'));
128 setTimeout(function() {
129 var dialog = card.shadowRoot.getElementById('bugDialog');
130 assert.isTrue(dialog.opened);
131 var bugField = card.shadowRoot.getElementById('bug');
132 bugField.value = 'http://foo.com/?id=888';
133 card.shadowRoot.getElementById('dialogOk').dispatchEvent(new CustomEvent ('tap'));
134 setTimeout(function() {
135 assert.equal(group.bug, 'http://foo.com/?id=888');
136 assert.equal(group.bugLabel, 'Bug 888');
137 assert.equal(group._annotation.bug, 'http://foo.com/?id=888');
138 done();
139 });
140 });
141 });
142
143 it('remove bug link should work', function(done) {
144 group.setBug(123);
145 card.shadowRoot.getElementById('link-bug').dispatchEvent(new CustomEvent(' tap'));
146 setTimeout(function() {
147 var dialog = card.shadowRoot.getElementById('bugDialog');
148 assert.isTrue(dialog.opened);
149 card.shadowRoot.getElementById('dialogRemoveBug').dispatchEvent(new Cust omEvent('tap'));
150 setTimeout(function() {
151 assert.isUndefined(group.bug);
152 assert.isUndefined(group.bugLabel);
153 done();
154 });
155 });
156 });
157 });
158
159 });
160
161 })()
162 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698