ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexantone...@apache.org
Subject ambari git commit: AMBARI-14967. Incorrect behavior of period combobox/metrics on Dashboard page after resetting all widgets to default (alexantonenko)
Date Tue, 09 Feb 2016 10:40:17 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.2 a8fd4a660 -> 4d930ba02


AMBARI-14967. Incorrect behavior of period combobox/metrics on Dashboard page after resetting
all widgets to default (alexantonenko)


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

Branch: refs/heads/branch-2.2
Commit: 4d930ba02025d980a8987738cee355fa50f7c027
Parents: a8fd4a6
Author: Alex Antonenko <hiveww@gmail.com>
Authored: Tue Feb 9 12:01:43 2016 +0200
Committer: Alex Antonenko <hiveww@gmail.com>
Committed: Tue Feb 9 12:40:13 2016 +0200

----------------------------------------------------------------------
 ambari-web/app/views/main/dashboard/widgets.js  |  5 ++
 .../test/views/main/dashboard/widgets_test.js   | 74 +++++++++++++++++---
 2 files changed, 70 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/4d930ba0/ambari-web/app/views/main/dashboard/widgets.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/dashboard/widgets.js b/ambari-web/app/views/main/dashboard/widgets.js
index fe9f542..b99d881 100644
--- a/ambari-web/app/views/main/dashboard/widgets.js
+++ b/ambari-web/app/views/main/dashboard/widgets.js
@@ -511,6 +511,11 @@ App.MainDashboardWidgetsView = Em.View.extend(App.UserPref, App.LocalStorage,
Ap
         self.postUserPref(self.get('persistKey'), self.get('initPrefObject'));
         self.setDBProperty(self.get('persistKey'), self.get('initPrefObject'));
       }
+      self.setProperties({
+        currentTimeRangeIndex: 0,
+        customStartTime: null,
+        customEndTime: null
+      });
       self.translateToReal(self.get('initPrefObject'));
     });
   },

http://git-wip-us.apache.org/repos/asf/ambari/blob/4d930ba0/ambari-web/test/views/main/dashboard/widgets_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/dashboard/widgets_test.js b/ambari-web/test/views/main/dashboard/widgets_test.js
index b0e2f14..63025a0 100644
--- a/ambari-web/test/views/main/dashboard/widgets_test.js
+++ b/ambari-web/test/views/main/dashboard/widgets_test.js
@@ -442,15 +442,71 @@ describe('App.MainDashboardWidgetsView', function () {
   });
 
   describe("#resetAllWidgets()", function () {
-    before(function () {
-      sinon.stub(App, 'showConfirmationPopup', Em.K);
-    });
-    after(function () {
-      App.showConfirmationPopup.restore();
-    });
-    it("", function () {
-      view.resetAllWidgets();
-      expect(App.showConfirmationPopup.calledOnce).to.be.true;
+
+    var cases = [
+      {
+        testMode: true,
+        postUserPrefCallCount: 0,
+        setDBPropertyCallCount: 0,
+        title: 'test mode'
+      },
+      {
+        testMode: false,
+        postUserPrefCallCount: 1,
+        setDBPropertyCallCount: 1,
+        title: 'real cluster'
+      }
+    ];
+
+    cases.forEach(function (item) {
+
+      describe(item.title, function () {
+
+        beforeEach(function () {
+          sinon.stub(App, 'showConfirmationPopup', function (callback) {
+            callback();
+          });
+          sinon.stub(App, 'get').withArgs('testMode').returns(item.testMode);
+          sinon.stub(view, 'postUserPref', Em.K);
+          sinon.stub(view, 'setDBProperty', Em.K);
+          sinon.stub(view, 'translateToReal', Em.K);
+          view.setProperties({
+            currentTimeRangeIndex: 1,
+            customStartTime: 1000,
+            customEndTime: 2000
+          });
+          view.resetAllWidgets();
+        });
+
+        afterEach(function () {
+          App.get.restore();
+          App.showConfirmationPopup.restore();
+          view.postUserPref.restore();
+          view.setDBProperty.restore();
+          view.translateToReal.restore();
+        });
+
+        it('persist reset', function () {
+          expect(view.postUserPref.callCount).to.equal(item.postUserPrefCallCount);
+        });
+        it('local storage reset', function () {
+          expect(view.setDBProperty.callCount).to.equal(item.setDBPropertyCallCount);
+        });
+        it('time range reset', function () {
+          expect(view.get('currentTimeRangeIndex')).to.equal(0);
+        });
+        it('custom start time reset', function () {
+          expect(view.get('customStartTime')).to.be.null;
+        });
+        it('custom end time reset', function () {
+          expect(view.get('customEndTime')).to.be.null;
+        });
+        it('default settings application', function () {
+          expect(view.translateToReal.callCount).to.equal(1);
+        });
+
+      });
+
     });
   });
 


Mime
View raw message