Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Tools / GardeningServer / ui / test / ct-failure-stream-tests.html
index a34aefe..e89359b 100644 (file)
@@ -26,26 +26,92 @@ describe('ct-failure-stream', function() {
       // ct-failure-stream will give these values to ct-commit-data,
       // which will hit the network unless we figure out how to mock
       // out ct-commit-data in a better way.
-      stream.groups = [new CTFailureGroup('a', []), new CTFailureGroup('b', [])];
+      stream.groups = [new CTFailureGroup('', new CTStepFailureGroupData([])),
+          new CTFailureGroup('', new CTStepFailureGroupData([]))];
       stream.category = 'default';
       setTimeout(function() {
-        var cards = stream.shadowRoot.querySelectorAll('ct-failure-card');
+        var cards = stream.shadowRoot.querySelectorAll('ct-step-failure-card');
         assert.equal(cards.length, 2);
-        assert.equal(cards[0].group.key, 'a');
-        assert.equal(cards[1].group.key, 'b');
         done();
       });
     });
   });
 
   describe('category', function() {
+
     it('should only show failure groups for the specified category', function(done) {
-      stream.groups = [new CTFailureGroup('a', []), new CTFailureGroup('b', [], {snoozeTime: Date.now() + 1000 * 1000})];
+      var failures = [new CTStepFailure('step', 'reason', [{key: 'a', annotation: {snoozeTime: Date.now() + 1000 * 1000}}])];
+      var snoozed = new CTFailureGroup('', new CTStepFailureGroupData(failures));
+      stream.groups = [new CTFailureGroup('', new CTStepFailureGroupData([])), snoozed];
       stream.category = 'snoozed';
       setTimeout(function() {
-        var cards = stream.shadowRoot.querySelectorAll('ct-failure-card');
+        var cards = stream.shadowRoot.querySelectorAll('ct-step-failure-card');
         assert.equal(cards.length, 1);
-        assert.equal(cards[0].group.key, 'b');
+        assert.equal(cards[0].group, snoozed.data);
+        done();
+      });
+    });
+
+    it('should select the correct card type', function(done) {
+      var failures = [new CTStepFailure('step', 'reason', [{key: 'a', annotation: {}}])];
+      var failureGroup = new CTFailureGroup('', new CTStepFailureGroupData(failures));
+      stream.groups = [new CTFailureGroup('', new CTStepFailureGroupData([])), failureGroup];
+      stream.category = 'default';
+      setTimeout(function() {
+        assert(stream.shadowRoot.querySelector('ct-step-failure-card') != null,
+            'missing sheriff card');
+        stream.groups = [new CTFailureGroup('', new CTTrooperFailureGroupData(
+            'details', 'url', {percent_over_median_slo: '6%',
+            percent_over_max_slo: '7%'}, 'cq_latency', ''))];
+        setTimeout(function() {
+          assert(stream.shadowRoot.querySelector('ct-trooper-card') != null,
+              'missing cq-latency card');
+          stream.groups[0].data.type = 'tree_status';
+          setTimeout(function() {
+            assert(stream.shadowRoot.querySelector('ct-trooper-card') !=
+                null, 'missing tree-status card');
+            stream.groups[0].data.type = 'cycle_time';
+            setTimeout(function() {
+              assert(stream.shadowRoot.querySelector('ct-trooper-card') !=
+                  null, 'missing cycle-time card');
+              done();
+            });
+          });
+        });
+      });
+    });
+
+    it('adding a bug number should show bugs link', function(done) {
+      var cl = new CTCommitListMock();
+      var group = new CTFailureGroup('', new CTStepFailureGroupData([
+          new CTStepFailure('autobot', 'unknown', {someBuilder: {key: 'a', failingBuildCount: 2}},
+              {'blink':158547}, {'blink':158544}),
+        ], cl));
+      group.setBug(123);
+
+      stream.groups = [group];
+      stream.category = 'default';
+
+      setTimeout(function() {
+        var links = stream.shadowRoot.querySelectorAll('.bugs a');
+        assert.lengthOf(links, 1);
+        assert.match(links[0].href, /crbug.com\/123/);
+        done();
+      });
+    });
+
+    it('should not show bugs link without a bug number', function(done) {
+      var cl = new CTCommitListMock();
+      var group = new CTFailureGroup('', new CTStepFailureGroupData([
+        new CTStepFailure('autobot', 'unknown', {someBuilder: {key: 'a'}}, {'blink':158547},
+                      {'blink':158544})], cl));
+
+      stream.groups = [group];
+      stream.category = 'default';
+
+      setTimeout(function() {
+        var links = stream.shadowRoot.querySelectorAll('.bugs');
+        assert.lengthOf(links, 0);
         done();
       });
     });