فهرست منبع

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

Alex Antonenko 9 سال پیش
والد
کامیت
cb3b3ed444
2فایلهای تغییر یافته به همراه41 افزوده شده و 6 حذف شده
  1. 5 0
      ambari-web/app/views/main/dashboard/widgets.js
  2. 36 6
      ambari-web/test/views/main/dashboard/widgets_test.js

+ 5 - 0
ambari-web/app/views/main/dashboard/widgets.js

@@ -504,6 +504,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'));
     });
   },

+ 36 - 6
ambari-web/test/views/main/dashboard/widgets_test.js

@@ -449,16 +449,46 @@ describe('App.MainDashboardWidgetsView', function () {
   });
 
   describe("#resetAllWidgets()", function () {
-    before(function () {
-      sinon.stub(App, 'showConfirmationPopup', Em.K);
+
+    beforeEach(function () {
+      sinon.stub(App, 'showConfirmationPopup', Em.clb);
+      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();
     });
-    after(function () {
+
+    afterEach(function () {
       App.showConfirmationPopup.restore();
+      view.postUserPref.restore();
+      view.setDBProperty.restore();
+      view.translateToReal.restore();
     });
-    it("showConfirmationPopup is called once", function () {
-      view.resetAllWidgets();
-      expect(App.showConfirmationPopup.calledOnce).to.be.true;
+
+    it('persist reset', function () {
+      expect(view.postUserPref.calledOnce).to.be.true;
+    });
+    it('local storage reset', function () {
+      expect(view.setDBProperty.calledOnce).to.be.true;
+    });
+    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.calledOnce).to.be.true;
+    });
+
   });
 
   describe('#checkServicesChange', function () {