Bläddra i källkod

AMBARI-15908. Default Error Handler Popup doesn't show correct request type (onechiporenko)

Oleg Nechiporenko 9 år sedan
förälder
incheckning
94c23298ad

+ 1 - 1
ambari-web/app/controllers/main/host/details.js

@@ -2261,7 +2261,7 @@ App.MainHostDetailsController = Em.Controller.extend(App.SupportClientConfigsDow
       else {
         completeCallback();
         deleteError.xhr.responseText = "{\"message\": \"" + deleteError.xhr.statusText + "\"}";
-        App.ajax.defaultErrorHandler(deleteError.xhr, deleteError.url, deleteError.method, deleteError.xhr.status);
+        App.ajax.defaultErrorHandler(deleteError.xhr, deleteError.url, deleteError.type, deleteError.xhr.status);
       }
     });
   },

+ 1 - 1
ambari-web/app/controllers/main/service/item.js

@@ -1394,7 +1394,7 @@ App.MainServiceItemController = Em.Controller.extend(App.SupportClientConfigsDow
   },
 
   deleteServiceCallErrorCallback: function (jqXHR, ajaxOptions, error, opt) {
-    App.ajax.defaultErrorHandler(jqXHR, opt.url, opt.method, jqXHR.status);
+    App.ajax.defaultErrorHandler(jqXHR, opt.url, opt.type, jqXHR.status);
   }
 
 });

+ 1 - 1
ambari-web/app/controllers/wizard.js

@@ -1233,7 +1233,7 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, App.ThemesMappingM
   },
 
   loadHostsErrorCallback: function (jqXHR, ajaxOptions, error, opt) {
-    App.ajax.defaultErrorHandler(jqXHR, opt.url, opt.method, jqXHR.status);
+    App.ajax.defaultErrorHandler(jqXHR, opt.url, opt.type, jqXHR.status);
   },
 
   /**

+ 1 - 1
ambari-web/app/mixins/common/reload_popup.js

@@ -32,7 +32,7 @@ App.ReloadPopupMixin = Em.Mixin.create({
     if (jqXHR.status) {
       this.closeReloadPopup();
       if (params.shouldUseDefaultHandler) {
-        App.ajax.defaultErrorHandler(jqXHR, opt.url, opt.method, jqXHR.status);
+        App.ajax.defaultErrorHandler(jqXHR, opt.url, opt.type, jqXHR.status);
       }
     } else {
       var times = Em.isNone(params.times) ? App.get('maxRetries') : params.times,

+ 1 - 1
ambari-web/app/mixins/common/widgets/export_metrics_mixin.js

@@ -76,7 +76,7 @@ App.ExportMetricsMixin = Em.Mixin.create({
   },
 
   exportGraphDataErrorCallback: function (jqXHR, ajaxOptions, error, opt) {
-    App.ajax.defaultErrorHandler(jqXHR, opt.url, opt.method, jqXHR.status);
+    App.ajax.defaultErrorHandler(jqXHR, opt.url, opt.type, jqXHR.status);
   },
 
   prepareCSV: function (data) {

+ 1 - 1
ambari-web/app/mixins/main/host/details/host_components/install_component.js

@@ -90,7 +90,7 @@ App.InstallComponent = Em.Mixin.create({
    * @method ajaxErrorCallback
    */
   ajaxErrorCallback: function (request, ajaxOptions, error, opt, params) {
-    App.ajax.defaultErrorHandler(request, opt.url, opt.method);
+    App.ajax.defaultErrorHandler(request, opt.url, opt.type);
   },
 
   /**

+ 1 - 1
ambari-web/app/mixins/wizard/assign_master_components.js

@@ -793,7 +793,7 @@ App.AssignMasterComponents = Em.Mixin.create({
    * @method loadRecommendationsErrorCallback
    */
   loadRecommendationsErrorCallback: function (jqXHR, ajaxOptions, error, opt) {
-    App.ajax.defaultErrorHandler(jqXHR, opt.url, opt.method, jqXHR.status);
+    App.ajax.defaultErrorHandler(jqXHR, opt.url, opt.type, jqXHR.status);
   },
 
   /**

+ 1 - 1
ambari-web/app/mixins/wizard/wizardProgressPageController.js

@@ -377,7 +377,7 @@ App.wizardProgressPageControllerMixin = Em.Mixin.create(App.InstallComponent, {
   },
 
   onSingleRequestError: function (jqXHR, ajaxOptions, error, opt) {
-    App.ajax.defaultErrorHandler(jqXHR, opt.url, opt.method, jqXHR.status);
+    App.ajax.defaultErrorHandler(jqXHR, opt.url, opt.type, jqXHR.status);
     this.set('status', 'FAILED');
     this.set('isLoaded', true);
     this.set('showRetry', true);

+ 1 - 1
ambari-web/test/controllers/main/service/add_controller_test.js

@@ -295,7 +295,7 @@ describe('App.AddServiceController', function() {
     });
 
     it('should execute default error handler', function () {
-      addServiceController.loadHostsErrorCallback({status: '500'}, 'textStatus', 'errorThrown', {url: 'url', method: 'GET'});
+      addServiceController.loadHostsErrorCallback({status: '500'}, 'textStatus', 'errorThrown', {url: 'url', type: 'GET'});
       expect(App.ajax.defaultErrorHandler.calledOnce).to.be.true;
       expect(App.ajax.defaultErrorHandler.calledWith({status: '500'}, 'url', 'GET', '500')).to.be.true;
     });

+ 0 - 5
ambari-web/test/mixins/common/reload_popup_test.js

@@ -134,7 +134,6 @@ describe('App.ReloadPopupMixin', function () {
       sinon.stub(App.ajax, 'defaultErrorHandler', Em.K);
       sinon.stub(obj, 'showReloadPopup', Em.K);
       sinon.stub(App, 'get').withArgs('maxRetries').returns(3);
-      sinon.spy(window, 'setTimeout');
     });
 
     afterEach(function () {
@@ -142,7 +141,6 @@ describe('App.ReloadPopupMixin', function () {
       App.ajax.defaultErrorHandler.restore();
       obj.showReloadPopup.restore();
       App.get.restore();
-      window.setTimeout.restore();
     });
 
     cases.forEach(function (item) {
@@ -170,9 +168,6 @@ describe('App.ReloadPopupMixin', function () {
         it('showReloadPopup is called needed number of times', function () {
           expect(obj.showReloadPopup.callCount).to.equal(item.showReloadPopupCallCount);
         });
-        it('setTimeout is called needed number of times', function () {
-          expect(window.setTimeout.callCount).to.equal(item.setTimeoutCount);
-        });
       });
     });
 

+ 0 - 8
ambari-web/test/mixins/common/widget_mixin_test.js

@@ -590,25 +590,17 @@ describe('App.WidgetLoadAggregator', function () {
   var aggregator = App.WidgetLoadAggregator;
 
   describe("#add()", function () {
-    beforeEach(function () {
-      sinon.spy(window, 'setTimeout');
-    });
-    afterEach(function () {
-      window.setTimeout.restore();
-    });
     it("timeout started", function () {
       aggregator.set('timeoutId', 'timeId');
       aggregator.get('requests').clear();
       aggregator.add({});
       expect(aggregator.get('requests')).to.not.be.empty;
-      expect(window.setTimeout.called).to.be.false;
     });
     it("timeout started (2)", function () {
       aggregator.set('timeoutId', null);
       aggregator.get('requests').clear();
       aggregator.add({});
       expect(aggregator.get('requests')).to.not.be.empty;
-      expect(window.setTimeout.calledOnce).to.be.true;
     });
   });
 

+ 1 - 1
ambari-web/test/mixins/common/widgets/export_metrics_mixin_test.js

@@ -243,7 +243,7 @@ describe('App.ExportMetricsMixin', function () {
           status: 404
         }, null, '', {
           url: 'url',
-          method: 'GET'
+          type: 'GET'
         });
       expect(App.ajax.defaultErrorHandler.calledOnce).to.be.true;
       expect(App.ajax.defaultErrorHandler.calledWith({

+ 1 - 1
ambari-web/test/mixins/main/host/details/host_components/install_component_test.js

@@ -108,7 +108,7 @@ describe('App.InstallComponent', function () {
     });
 
     it("App.ajax.defaultErrorHandler should be called", function() {
-      installComponent.ajaxErrorCallback({}, {}, 'error', {method: 'method1', url: 'url1'}, {});
+      installComponent.ajaxErrorCallback({}, {}, 'error', {type: 'method1', url: 'url1'}, {});
       expect(App.ajax.defaultErrorHandler.calledWith({}, 'url1', 'method1')).to.be.true;
     });
   });

+ 0 - 13
ambari-web/test/views/main/admin/stack_upgrade/version_view_test.js

@@ -408,19 +408,6 @@ describe('App.mainAdminStackVersionsView', function () {
     });
   });
 
-  describe("#doPolling()", function() {
-    before(function () {
-      sinon.spy(window, 'setTimeout');
-    });
-    after(function () {
-      window.setTimeout.restore();
-    });
-    it("setTimeout is called once", function() {
-      view.doPolling();
-      expect(window.setTimeout.calledOnce).to.be.true;
-    });
-  });
-
   describe("#poll()", function() {
     beforeEach(function () {
       this.mock = sinon.stub(App.router, 'get');

+ 33 - 25
ambari-web/test/views/wizard/step7/assign_master_view_test.js

@@ -27,23 +27,23 @@ function getView() {
   });
 }
 
-describe('App.AssignMasterOnStep7View', function() {
+describe('App.AssignMasterOnStep7View', function () {
 
-  beforeEach(function() {
+  beforeEach(function () {
     view = getView();
   });
 
   describe("#willInsertElement()", function () {
 
-    beforeEach(function() {
+    beforeEach(function () {
       sinon.stub(view, 'setAlertMessage');
     });
 
-    afterEach(function() {
+    afterEach(function () {
       view.setAlertMessage.restore();
     });
 
-    it("setAlertMessage should be called", function() {
+    it("setAlertMessage should be called", function () {
       view.willInsertElement();
       expect(view.setAlertMessage.calledOnce).to.be.true;
     });
@@ -51,32 +51,32 @@ describe('App.AssignMasterOnStep7View', function() {
 
   describe("#getDependentComponents()", function () {
 
-    beforeEach(function() {
+    beforeEach(function () {
       sinon.stub(App.StackServiceComponent, 'find').returns(Em.Object.create({
         dependencies: [{
           scope: 'host',
           componentName: 'C1'
         }]
       }));
-      sinon.stub(App.format, 'role', function(arg) {
+      sinon.stub(App.format, 'role', function (arg) {
         return arg;
       });
     });
 
-    afterEach(function() {
+    afterEach(function () {
       App.StackServiceComponent.find.restore();
       App.format.role.restore();
     });
 
-    it("should return dependent components", function() {
+    it("should return dependent components", function () {
       expect(view.getDependentComponents([{}])).to.be.eql(['C1']);
     });
   });
 
   describe("#setAlertMessage()", function () {
 
-    beforeEach(function() {
-      sinon.stub(App.format, 'role', function(arg) {
+    beforeEach(function () {
+      sinon.stub(App.format, 'role', function (arg) {
         return arg;
       });
       sinon.stub(view, 'getDependentComponents').returns(['c1']);
@@ -84,17 +84,20 @@ describe('App.AssignMasterOnStep7View', function() {
       this.mock = sinon.stub(App, 'get');
     });
 
-    afterEach(function() {
+    afterEach(function () {
       App.format.role.restore();
       view.getDependentComponents.restore();
       stringUtils.getFormattedStringFromArray.restore();
       this.mock.restore();
     });
 
-    it("isManualKerberos false, single master", function() {
-      var expected = Em.I18n.t('installer.step7.assign.master.body')
-        .format('c1', Em.I18n.t('common.host').toLowerCase(), Em.I18n.t('it')) +
-        '<br/>' + Em.I18n.t('installer.step7.assign.master.dependent.component.body').format('');
+    it("isManualKerberos false, single master", function () {
+
+      var expected = [
+        Em.I18n.t('installer.step7.assign.master.body').format('c1', Em.I18n.t('common.host').toLowerCase(), Em.I18n.t('it')),
+        Em.I18n.t('installer.step7.assign.master.dependent.component.body').format('')
+      ].join('<br/>');
+
       view.set('controller.mastersToCreate', ['c1']);
       this.mock.returns(false);
 
@@ -102,10 +105,13 @@ describe('App.AssignMasterOnStep7View', function() {
       expect(view.get('alertMessage')).to.be.equal(expected);
     });
 
-    it("isManualKerberos false, multiple masters", function() {
-      var expected = Em.I18n.t('installer.step7.assign.master.body')
-          .format('c1,c2', Em.I18n.t('common.hosts').toLowerCase(), Em.I18n.t('then')) +
-        '<br/>' + Em.I18n.t('installer.step7.assign.master.dependent.component.body').format('');
+    it("isManualKerberos false, multiple masters", function () {
+
+      var expected = [
+        Em.I18n.t('installer.step7.assign.master.body').format('c1,c2', Em.I18n.t('common.hosts').toLowerCase(), Em.I18n.t('then')),
+        Em.I18n.t('installer.step7.assign.master.dependent.component.body').format('')
+      ].join('<br/>');
+
       view.set('controller.mastersToCreate', ['c1', 'c2']);
       this.mock.returns(false);
 
@@ -113,11 +119,13 @@ describe('App.AssignMasterOnStep7View', function() {
       expect(view.get('alertMessage')).to.be.equal(expected);
     });
 
-    it("isManualKerberos true, single master", function() {
-      var expected = Em.I18n.t('installer.step7.assign.master.body')
-          .format('c1', Em.I18n.t('common.host').toLowerCase(), Em.I18n.t('it')) +
-        '<br/>' + Em.I18n.t('installer.step7.assign.master.dependent.component.body').format('') +
-        '<br/>' + Em.I18n.t('common.warn.message').format(Em.I18n.t('common.important') + ': ' + Em.I18n.t('installer.step8.kerberors.warning'));
+    it("isManualKerberos true, single master", function () {
+
+      var expected = [
+        Em.I18n.t('installer.step7.assign.master.body').format('c1', Em.I18n.t('common.host').toLowerCase(), Em.I18n.t('it')),
+        Em.I18n.t('installer.step7.assign.master.dependent.component.body').format(''),
+        Em.I18n.t('common.warn.message').format(Em.I18n.t('common.important') + ': ' + Em.I18n.t('installer.step8.kerberors.warning'))
+      ].join('<br/>');
 
       view.set('controller.mastersToCreate', ['c1']);
       this.mock.returns(true);