Add a "Link Bug" button to associate a bug with a failure

R=ojan@chromium.org
NOTRY=true
BUG=399734

Review URL: https://codereview.chromium.org/476903003

git-svn-id: svn://svn.chromium.org/blink/trunk@180401 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 64e647f9
......@@ -10,7 +10,7 @@ found in the LICENSE file.
function CTFailureGroup(key, failures, annotation) {
this.key = key;
this.failures = failures;
this.annotation = annotation || {};
this._annotation = annotation || {};
this._computeProperties();
}
......@@ -30,14 +30,28 @@ CTFailureGroup.prototype.commitList = function(commits) {
return new CTCommitList(this, commits);
};
CTFailureGroup.prototype.setBug = function(bug) {
if (/^[0-9]+$/.test(bug))
bug = 'http://crbug.com/' + bug;
return this._annotate({
bug: bug,
});
};
CTFailureGroup.prototype._computeProperties = function() {
this.isSnoozed = Date.now() < this.annotation.snoozeTime;
this.isSnoozed = Date.now() < this._annotation.snoozeTime;
if (this.isSnoozed) {
this.category = 'snoozed';
} else {
// FIXME: crbug.com/400397 Split into: Whole step failure, Tree closer, Test failure, Flaky tests
this.category = 'default';
}
this.bug = this._annotation.bug;
if (this.bug !== undefined)
this.bugLabel = 'Bug ' + /([0-9]{3,})/.exec(this.bug)[0];
else
this.bugLabel = undefined;
};
CTFailureGroup.prototype._annotate = function(newAnnotation) {
......@@ -61,7 +75,7 @@ CTFailureGroup.prototype._annotate = function(newAnnotation) {
localStorage.CTFailureGroupAnnotations = JSON.stringify(annotations);
this.annotation = annotation;
this._annotation = annotation;
this._computeProperties();
}.bind(this));
};
......
......@@ -51,28 +51,55 @@ describe('ct-failure-group', function() {
});
});
describe('setBug', function() {
it('should store the bug', function(done) {
var group = new CTFailureGroup('key', []);
group.setBug('123').then(function() {
assert.equal(group.bug, 'http://crbug.com/123');
assert.equal(group._annotation.bug, 'http://crbug.com/123');
assert.equal(group.bugLabel, 'Bug 123');
done();
});
});
it('should support URLs', function(done) {
var group = new CTFailureGroup('key', []);
group.setBug('http://foobar.com/?id=876&x=y').then(function() {
assert.equal(group.bug, 'http://foobar.com/?id=876&x=y');
assert.equal(group._annotation.bug, 'http://foobar.com/?id=876&x=y');
assert.equal(group.bugLabel, 'Bug 876');
done();
});
});
});
describe('annotations', function() {
it('should have sensible defaults', function() {
var group = new CTFailureGroup('key', []);
assert.deepEqual(group.annotation, {});
assert.deepEqual(group._annotation, {});
assert.isFalse(group.isSnoozed);
assert.isUndefined(group.bug);
assert.isUndefined(group.bugLabel);
});
it('should compute properties', function() {
var group = new CTFailureGroup('key', [], {snoozeTime: Date.now() + 1000 * 1000});
var group = new CTFailureGroup('key', [], {snoozeTime: Date.now() + 1000 * 1000, bug: 'http://crbug.com/123'});
assert.isTrue(group.isSnoozed);
assert.equal(group.bug, 'http://crbug.com/123');
});
it('should be persisted', function(done) {
var group = new CTFailureGroup('key', []);
group.snoozeUntil(123).then(function() {
group.setBug('456').then(function() {
CTFailureGroup.fetchAnnotations().then(function(annotations) {
assert.deepEqual(annotations['key'], {snoozeTime: 123});
assert.deepEqual(annotations['key'], {snoozeTime: 123, bug: 'http://crbug.com/456'});
done();
});
});
});
});
});
});
})()
......
......@@ -55,6 +55,5 @@ THE POSSIBILITY OF SUCH DAMAGE.
<link rel="import" href="model/ct-commit-tests.html">
<link rel="import" href="model/ct-failure-tests.html">
<link rel="import" href="model/tree-status-tests.html">
<link rel="import" href="ui/ct-failure-card-tests.html">
</body>
......@@ -13,6 +13,7 @@ found in the LICENSE file.
<link rel="import" href="../ui/test/ct-commit-tests.html">
<link rel="import" href="../ui/test/ct-embedded-flakiness-dashboard-tests.html">
<link rel="import" href="../ui/test/ct-failure-analyzer-tests.html">
<link rel="import" href="../ui/test/ct-failure-card-tests.html">
<link rel="import" href="../ui/test/ct-failure-stream-tests.html">
<link rel="import" href="../ui/test/ct-last-updated-tests.html">
<link rel="import" href="../ui/test/ct-party-time-tests.html">
......
<!--
Copyright 2014 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<link rel="import" href="ct-failure-card.html">
<script>
(function () {
module("ct-failure-card");
asyncTest("examine", 1, function() {
var card = document.createElement('ct-failure-card');
card.failures = [];
Platform.endOfMicrotask(function() {
card.addEventListener('ct-examine-failures', function(event) {
deepEqual(event.detail, []);
start();
});
card.shadowRoot.getElementById('examine').dispatchEvent(new CustomEvent('tap'));
});
});
})()
</script>
......@@ -7,8 +7,11 @@ found in the LICENSE file.
<link rel="import" href="ct-builder-grid.html">
<link rel="import" href="ct-commit-list.html">
<link rel="import" href="ct-test-list.html">
<link rel="import" href="../bower_components/paper-dialog/paper-dialog.html">
<link rel="import" href="../bower_components/paper-dialog/paper-dialog-transition.html">
<link rel="import" href="../bower_components/paper-input/paper-input.html">
<polymer-element name="ct-failure-card" attributes="group commits tree">
<polymer-element name="ct-failure-card" attributes="group commits tree bug">
<template>
<style>
:host {
......@@ -75,8 +78,20 @@ found in the LICENSE file.
<template if="{{ group.isSnoozed }}">
<paper-button id="snooze" on-tap="{{ unsnooze }}" label="Unsnooze"></paper-button>
</template>
<paper-button id="link-bug" on-tap="{{ linkBug }}" label="Link Bug"></paper-button>
<template if="{{ group.bug !== undefined }}">
<div>
<a href="{{ group.bug }}">
{{ group.bugLabel }}</a>
</div>
</template>
</div>
<paper-dialog heading="Enter bug number" transition="paper-transition-center" id="bugDialog">
<paper-input label="Bug# or URL" floatingLabel id="bug"></paper-input>
<paper-button label="OK" on-tap="{{ saveBug }}" affirmative autofocus id="dialogOk"></paper-button>
</paper-dialog>
</template>
<script>
Polymer({
group: null,
......@@ -99,7 +114,16 @@ found in the LICENSE file.
if (!this.group)
return undefined;
return this.group.commitList(this.commits);
}
},
linkBug: function() {
this.$.bug.value = this.group.bug;
this.$.bugDialog.toggle();
},
saveBug: function() {
this.group.setBug(this.$.bug.value);
},
});
</script>
</polymer-element>
<!--
Copyright 2014 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<link rel="import" href="../ct-failure-card.html">
<link rel="import" href="../../model/ct-failure-group.html">
<script>
(function () {
var assert = chai.assert;
describe('ct-failure-group', function() {
var group;
var card;
beforeEach(function(done) {
card = document.createElement('ct-failure-card');
group = new CTFailureGroup('key', []);
card.group = group;
setTimeout(done);
});
describe('failure group UI', function(done) {
it('examine should dispatch event', function() {
card.addEventListener('ct-examine-failures', function(event) {
assert.deepEqual(event.detail.failures, []);
setTimeout(done);
});
card.shadowRoot.getElementById('examine').dispatchEvent(new CustomEvent('tap'));
});
it('adding a bug number should show link', function(done) {
group.setBug(123);
setTimeout(function() {
var links = card.shadowRoot.querySelectorAll('a');
assert.lengthOf(links, 1);
assert.match(links[0].href, /crbug.com\/123/);
setTimeout(done);
});
});
it('should not show link without a bug number', function() {
var links = card.shadowRoot.querySelectorAll('a');
assert.lengthOf(links, 0);
});
it('clicking link bug should show dialog', function(done) {
card.shadowRoot.getElementById('link-bug').dispatchEvent(new CustomEvent('tap'));
setTimeout(function() {
var dialog = card.shadowRoot.getElementById('bugDialog');
assert.isTrue(dialog.opened);
var bugField = card.shadowRoot.getElementById('bug');
bugField.value = '999';
card.shadowRoot.getElementById('dialogOk').dispatchEvent(new CustomEvent('tap'));
setTimeout(function() {
assert.equal(group.bug, 'http://crbug.com/999');
assert.equal(group.bugLabel, 'Bug 999');
assert.equal(group._annotation.bug, 'http://crbug.com/999');
setTimeout(done);
});
});
});
it('entering URLs should work for bugs', function(done) {
card.shadowRoot.getElementById('link-bug').dispatchEvent(new CustomEvent('tap'));
setTimeout(function() {
var dialog = card.shadowRoot.getElementById('bugDialog');
assert.isTrue(dialog.opened);
var bugField = card.shadowRoot.getElementById('bug');
bugField.value = 'http://foo.com/?id=888';
card.shadowRoot.getElementById('dialogOk').dispatchEvent(new CustomEvent('tap'));
setTimeout(function() {
assert.equal(group.bug, 'http://foo.com/?id=888');
assert.equal(group.bugLabel, 'Bug 888');
assert.equal(group._annotation.bug, 'http://foo.com/?id=888');
setTimeout(done);
});
});
});
});
});
})()
</script>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment