ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexantone...@apache.org
Subject [3/4] ambari git commit: AMBARI-17918. Incorrect enhanced metrics graphs behaviour after switching to time range with no data (alexantonenko)
Date Wed, 27 Jul 2016 12:56:08 GMT
AMBARI-17918. Incorrect enhanced metrics graphs behaviour after switching to time range with
no data (alexantonenko)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/b96213e5
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/b96213e5
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/b96213e5

Branch: refs/heads/trunk
Commit: b96213e507abe04bc129acde2ff682df2a38f94e
Parents: 0a846a7
Author: Alex Antonenko <hiveww@gmail.com>
Authored: Wed Jul 27 15:24:44 2016 +0300
Committer: Alex Antonenko <hiveww@gmail.com>
Committed: Wed Jul 27 15:56:00 2016 +0300

----------------------------------------------------------------------
 .../app/mixins/common/widgets/widget_mixin.js   |   6 +-
 .../test/mixins/common/widget_mixin_test.js     | 102 +++++++++++++------
 2 files changed, 76 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/b96213e5/ambari-web/app/mixins/common/widgets/widget_mixin.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/common/widgets/widget_mixin.js b/ambari-web/app/mixins/common/widgets/widget_mixin.js
index 0ff7f29..5ec4dd6 100644
--- a/ambari-web/app/mixins/common/widgets/widget_mixin.js
+++ b/ambari-web/app/mixins/common/widgets/widget_mixin.js
@@ -334,11 +334,11 @@ App.WidgetMixin = Ember.Mixin.create({
         graph.set('hasData', false);
         this.set('isExportButtonHidden', true);
         graph._showMessage('info', this.t('graphs.noData.title'), this.t('graphs.noDataAtTime.message'));
-        this.set('metrics', this.get('metrics').reject(function (item) {
-          return this.get('content.metrics').someProperty('name', item.name);
-        }, this));
       }
     }
+    this.set('metrics', this.get('metrics').reject(function (item) {
+      return this.get('content.metrics').someProperty('name', item.name);
+    }, this));
   },
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/b96213e5/ambari-web/test/mixins/common/widget_mixin_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/mixins/common/widget_mixin_test.js b/ambari-web/test/mixins/common/widget_mixin_test.js
index b56863c..fe972f9 100644
--- a/ambari-web/test/mixins/common/widget_mixin_test.js
+++ b/ambari-web/test/mixins/common/widget_mixin_test.js
@@ -245,42 +245,86 @@ describe('App.WidgetMixin', function () {
 
   describe("#disableGraph", function () {
     var graph = Em.Object.create({
+        hasData: true,
         _showMessage: Em.K
-      });
-
-    beforeEach(function() {
-      mixinObject.setProperties({
-        childViews: [
-          graph
-        ],
-        graphView: {},
-        metrics: [{name: 'm1'}, {name: 'm2'}],
-        content: {
-          metrics: [{name: 'm2'}]
+      }),
+      cases = [
+        {
+          graphView: null,
+          childViews: [],
+          hasData: true,
+          isExportButtonHidden: false,
+          showMessageCallCount: 0,
+          title: 'no graph'
+        },
+        {
+          graphView: {},
+          childViews: [{}],
+          hasData: true,
+          isExportButtonHidden: false,
+          showMessageCallCount: 0,
+          title: 'no graph view rendered'
+        },
+        {
+          graphView: {},
+          childViews: [
+            {},
+            graph
+          ],
+          hasData: false,
+          isExportButtonHidden: true,
+          showMessageCallCount: 1,
+          title: 'graph view rendered'
         }
-      });
-      sinon.stub(graph, '_showMessage');
-      mixinObject.disableGraph();
-    });
+      ];
 
-    afterEach(function() {
-      graph._showMessage.restore();
-    });
+    cases.forEach(function (item) {
+      describe(item.title, function () {
+        beforeEach(function() {
+          mixinObject.setProperties({
+            isExportButtonHidden: false,
+            childViews: item.childViews,
+            graphView: item.graphView,
+            metrics: [
+              {
+                name: 'm1'
+              },
+              {
+                name: 'm2'
+              }
+            ],
+            content: {
+              metrics: [
+                {
+                  name: 'm2'
+                }
+              ]
+            }
+          });
+          sinon.stub(graph, '_showMessage');
+          mixinObject.disableGraph();
+        });
 
-    it("hasData should be false", function() {
-      expect(graph.get('hasData')).to.be.false;
-    });
+        afterEach(function() {
+          graph._showMessage.restore();
+        });
 
-    it("isExportButtonHidden should be true", function() {
-      expect(mixinObject.get('isExportButtonHidden')).to.be.true;
-    });
+        it('hasData', function() {
+          expect(graph.get('hasData')).to.equal(item.hasData);
+        });
 
-    it("_showMessage should be called", function() {
-      expect(graph._showMessage.calledWith('info', mixinObject.t('graphs.noData.title'),
mixinObject.t('graphs.noDataAtTime.message'))).to.be.true;
-    });
+        it('isExportButtonHidden', function() {
+          expect(mixinObject.get('isExportButtonHidden')).to.equal(item.isExportButtonHidden);
+        });
+
+        it('_showMessage call count', function() {
+          expect(graph._showMessage.callCount).to.equal(item.showMessageCallCount);
+        });
 
-    it("metrics should be filtered", function() {
-      expect(mixinObject.get('metrics').mapProperty('name')).to.be.eql(['m1']);
+        it('metrics should be filtered', function() {
+          expect(mixinObject.get('metrics').mapProperty('name')).to.eql(['m1']);
+        });
+      });
     });
   });
 


Mime
View raw message