ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From onechipore...@apache.org
Subject [1/3] ambari git commit: AMBARI-14741. Ambari Web Unit Test failure on trunk (App.WizardStep8Controller) (onechiporenko)
Date Wed, 20 Jan 2016 17:21:10 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 9f76f6019 -> ddf479ef9


http://git-wip-us.apache.org/repos/asf/ambari/blob/ddf479ef/ambari-web/test/controllers/wizard/step9_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard/step9_test.js b/ambari-web/test/controllers/wizard/step9_test.js
index 70365bb..2eb8709 100644
--- a/ambari-web/test/controllers/wizard/step9_test.js
+++ b/ambari-web/test/controllers/wizard/step9_test.js
@@ -24,6 +24,7 @@ require('controllers/installer');
 require('controllers/wizard/step9_controller');
 require('utils/helper');
 require('utils/ajax/ajax');
+var testHelpers = require('test/helpers');
 
 var modelSetup = require('test/init_model_test');
 var c, obj;
@@ -54,6 +55,7 @@ describe('App.InstallerStep9Controller', function () {
     modelSetup.setupStackServiceComponent();
     c = getController();
     obj = App.InstallerController.create();
+    App.ajax.send.restore();
     sinon.stub(App.ajax, 'send', function() {
       return {
         then: function() { 
@@ -72,7 +74,6 @@ describe('App.InstallerStep9Controller', function () {
 
   afterEach(function () {
     modelSetup.cleanStackServiceComponent();
-    App.ajax.send.restore();
   });
 
   App.TestAliases.testAsComputedEqual(getController(), 'showRetry', 'content.cluster.status', 'INSTALL FAILED');
@@ -1340,17 +1341,6 @@ describe('App.InstallerStep9Controller', function () {
 
   describe('#launchStartServicesErrorCallback', function () {
 
-    beforeEach(function() {
-      sinon.stub(App, 'get', function(k) {
-        if ('testMode' === k) return true;
-        return Em.get(App, k);
-      });
-    });
-
-    afterEach(function() {
-      App.get.restore();
-    });
-
     it('Main progress bar on the screen should be finished (100%) with red color', function () {
       var hosts = Em.A([Em.Object.create({name: 'host1', progress: '33', status: 'info'}), Em.Object.create({name: 'host2', progress: '33', status: 'info'})]);
       c.reopen({hosts: hosts, content: {controllerName: 'installerController', cluster: {status: 'PENDING', name: 'c1'}}});
@@ -1492,7 +1482,8 @@ describe('App.InstallerStep9Controller', function () {
     it('shouldn\'t call App.ajax.send if no currentOpenTaskId', function () {
       c.set('currentOpenTaskId', null);
       c.loadCurrentTaskLog();
-      expect(App.ajax.send.called).to.equal(false);
+      var args = testHelpers.findAjaxRequest('name', 'background_operations.get_by_task');
+      expect(args).not.exists;
     });
 
     it('should call App.ajax.send with provided data', function () {
@@ -1500,7 +1491,9 @@ describe('App.InstallerStep9Controller', function () {
       c.set('currentOpenTaskRequestId', 2);
       c.set('content', {cluster: {name: 3}});
       c.loadCurrentTaskLog();
-      expect(App.ajax.send.args[0][0].data).to.eql({taskId: 1, requestId: 2, clusterName: 3});
+      var args = testHelpers.findAjaxRequest('name', 'background_operations.get_by_task');
+      expect(args[0]).exists;
+      expect(args[0].data).to.be.eql({taskId: 1, requestId: 2, clusterName: 3});
     });
   });
 
@@ -1597,14 +1590,6 @@ describe('App.InstallerStep9Controller', function () {
       c.togglePreviousSteps.restore();
     });
 
-    it('should increment numPolls if testMode', function () {
-      App.set('testMode', true);
-      c.set('numPolls', 0);
-      c.doPolling();
-      expect(c.get('numPolls')).to.equal(1);
-      App.set('testMode', false);
-    });
-
     it('should call getLogsByRequest', function () {
       c.set('content', {cluster: {requestId: 1}});
       c.doPolling();
@@ -1635,7 +1620,6 @@ describe('App.InstallerStep9Controller', function () {
       sinon.stub(c, 'loadStep', Em.K);
       sinon.stub(c, 'loadLogData', Em.K);
       sinon.stub(c, 'startPolling', Em.K);
-      sinon.stub(App, 'get', function(k) {if('testMode' === k) return false; return Em.get(App, k);});
     });
 
     afterEach(function () {
@@ -1643,7 +1627,6 @@ describe('App.InstallerStep9Controller', function () {
       c.loadStep.restore();
       c.loadLogData.restore();
       c.startPolling.restore();
-      App.get.restore();
     });
 
     it('isCompleted = true, requestId = 1', function () {

http://git-wip-us.apache.org/repos/asf/ambari/blob/ddf479ef/ambari-web/test/controllers/wizard_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard_test.js b/ambari-web/test/controllers/wizard_test.js
index 1abbfd7..06729dd 100644
--- a/ambari-web/test/controllers/wizard_test.js
+++ b/ambari-web/test/controllers/wizard_test.js
@@ -612,11 +612,9 @@ describe('App.WizardController', function () {
       sinon.stub(wizardController,'showLaunchBootstrapPopup').returns({
         name: 'popup'
       });
-      sinon.stub(App.ajax,'send', Em.K);
     });
     afterEach(function(){
       wizardController.showLaunchBootstrapPopup.restore();
-      App.ajax.send.restore();
     });
     it('should return popup', function () {
       expect(wizardController.launchBootstrap()).to.be.eql({
@@ -680,13 +678,9 @@ describe('App.WizardController', function () {
       sinon.stub(wizardController,'saveClusterStatus', function(data){
         res = JSON.parse(JSON.stringify(data));
       });
-      sinon.stub(App.ajax,'send').returns({
-        then: function() {}
-      });
     });
     afterEach(function(){
       wizardController.saveClusterStatus.restore();
-      App.ajax.send.restore();
     });
     it('should call callbeck with data', function () {
       wizardController.set('content', Em.Object.create({
@@ -1491,7 +1485,7 @@ describe('App.WizardController', function () {
   describe('#loadConfigThemes', function() {
     beforeEach(function () {
       sinon.stub(wizardController, 'loadConfigThemeForServices').returns({
-        always: function(callback) {callback();}
+        always: Em.clb
       });
       sinon.stub(App.themesMapper, 'generateAdvancedTabs').returns(true);
       sinon.stub(App.config, 'loadConfigsFromStack').returns({

http://git-wip-us.apache.org/repos/asf/ambari/blob/ddf479ef/ambari-web/test/helpers.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/helpers.js b/ambari-web/test/helpers.js
index 4c2a671..1bb65d0 100644
--- a/ambari-web/test/helpers.js
+++ b/ambari-web/test/helpers.js
@@ -47,6 +47,83 @@ module.exports = {
         }
       });
     });
+  },
+
+  /**
+   * Get arguments for one <code>App.ajax.send</code> call according to the criteria
+   * Example:
+   * <pre>
+   *  sinon.stub(App.ajax, 'send', Em.K);
+   *  App.ajax.send({
+   *    name: 'n1',
+   *    sender: {},
+   *    data: {
+   *      f1: 'v1',
+   *      f2: 'v2'
+   *    }
+   *  });
+   *  App.ajax.send({
+   *    name: 'n2',
+   *    sender: {}
+   *  });
+   *  var args = findAjaxRequest('name', 'n1');
+   *  console.log(args); // [{name: 'n1', sender: {}, data: {f1: 'v1', f2: 'v2'}}]
+   *  App.ajax.send.restore();
+   * </pre>
+   *
+   * @param {string} property field to find
+   * @param {*} value value to find
+   * @returns {array|null}
+   */
+  findAjaxRequest: function(property, value) {
+    if (Em.typeOf(App.ajax.send.args) !== 'array') {
+      return null;
+    }
+    return App.ajax.send.args.find(function (request) {
+      return Em.get(request[0], property) === value;
+    });
+  },
+
+  /**
+   * Get arguments for several <code>App.ajax.send</code> calls according to the criteria
+   * Example:
+   * <pre>
+   *  sinon.stub(App.ajax, 'send', Em.K);
+   *  App.ajax.send({
+   *    name: 'n1',
+   *    sender: {},
+   *    data: {
+   *      f1: 'v1',
+   *      f2: 'v2'
+   *    }
+   *  });
+   *  App.ajax.send({
+   *    name: 'n2',
+   *    sender: {}
+   *  });
+   *  App.ajax.send({
+   *    name: 'n2',
+   *    sender: {},
+   *    data: {
+   *      d1: 1234
+   *    }
+   *  });
+   *  var args = filterAjaxRequests('name', 'n2');
+   *  console.log(args); // [[{name: 'n1', sender: {}}], [{name: 'n2', sender: {}, data: {d1: 1234}}]]
+   *  App.ajax.send.restore();
+   * </pre>
+   *
+   * @param {string} property field to filter
+   * @param {*} value value to filter
+   * @returns {array}
+   */
+  filterAjaxRequests: function (property, value) {
+    if (Em.typeOf(App.ajax.send.args) !== 'array') {
+      return [];
+    }
+    return App.ajax.send.args.filter(function (request) {
+      return Em.get(request[0], property) === value;
+    });
   }
 
 };
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/ddf479ef/ambari-web/test/mixins/common/table_server_view_mixin_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/mixins/common/table_server_view_mixin_test.js b/ambari-web/test/mixins/common/table_server_view_mixin_test.js
index 05c5ef4..2a9c409 100644
--- a/ambari-web/test/mixins/common/table_server_view_mixin_test.js
+++ b/ambari-web/test/mixins/common/table_server_view_mixin_test.js
@@ -18,6 +18,7 @@
 
 var App = require('app');
 require('mixins/common/table_server_view_mixin');
+require('utils/load_timer');
 
 describe('App.MainConfigHistoryView', function() {
   var view = Em.View.create(App.TableServerViewMixin, {

http://git-wip-us.apache.org/repos/asf/ambari/blob/ddf479ef/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 e35f955..bc9192b 100644
--- a/ambari-web/test/mixins/common/widget_mixin_test.js
+++ b/ambari-web/test/mixins/common/widget_mixin_test.js
@@ -17,12 +17,22 @@
  */
 
 var App = require('app');
+var testHelpers = require('test/helpers');
 
 describe('App.WidgetMixin', function () {
   var mixinClass = Em.Object.extend(App.WidgetMixin, {metrics: [], content: {}});
+  var mixinObject;
+
+  beforeEach(function () {
+    mixinObject = mixinClass.create();
+  });
+
+  afterEach(function () {
+    clearTimeout(mixinObject.get('timeoutId'));
+    mixinObject.destroy();
+  });
 
   describe('#loadMetrics()', function () {
-    var mixinObject = mixinClass.create();
     beforeEach(function () {
       this.mock = sinon.stub(mixinObject, 'getRequestData');
       sinon.stub(App.WidgetLoadAggregator, 'add');
@@ -48,7 +58,6 @@ describe('App.WidgetMixin', function () {
   });
 
   describe("#extractExpressions()", function () {
-    var mixinObject = mixinClass.create();
     var testCases = [
       {
         data: '',
@@ -179,13 +188,7 @@ describe('App.WidgetMixin', function () {
   });
 
   describe("#getServiceComponentMetrics()", function () {
-    var mixinObject = mixinClass.create();
-    before(function () {
-      sinon.stub(App.ajax, 'send');
-    });
-    after(function () {
-      App.ajax.send.restore();
-    });
+
     it("valid request is sent", function () {
       var request = {
         service_name: 'S1',
@@ -206,20 +209,18 @@ describe('App.WidgetMixin', function () {
         ]
       };
       mixinObject.getServiceComponentMetrics(request);
-      expect(App.ajax.send.getCall(0).args[0]).to.eql({
-        name: 'widgets.serviceComponent.metrics.get',
-        sender: mixinObject,
-        data: {
-          serviceName: 'S1',
-          componentName: 'C1',
-          metricPaths: 'w1,w2'
-        }
-      })
+      var args = testHelpers.findAjaxRequest('name', 'widgets.serviceComponent.metrics.get');
+      expect(args[0]).exists;
+      expect(args[0].sender).to.be.eql(mixinObject);
+      expect(args[0].data).to.be.eql({
+        serviceName: 'S1',
+        componentName: 'C1',
+        metricPaths: 'w1,w2'
+      });
     });
   });
 
   describe("#getMetricsSuccessCallback()", function () {
-    var mixinObject = mixinClass.create();
     it("metric is mapped from provided path", function () {
       var data = {
         metrics: {
@@ -243,13 +244,10 @@ describe('App.WidgetMixin', function () {
   });
 
   describe("#getHostComponentMetrics()", function () {
-    var mixinObject = mixinClass.create();
-    before(function () {
-      sinon.stub(App.ajax, 'send');
+    beforeEach(function () {
       sinon.stub(mixinObject, 'computeHostComponentCriteria').returns('criteria')
     });
-    after(function () {
-      App.ajax.send.restore();
+    afterEach(function () {
       mixinObject.computeHostComponentCriteria.restore();
     });
     it("valid request is sent", function () {
@@ -272,20 +270,18 @@ describe('App.WidgetMixin', function () {
         host_component_criteria: 'c1'
       };
       mixinObject.getHostComponentMetrics(request);
-      expect(App.ajax.send.getCall(0).args[0]).to.eql({
-        name: 'widgets.hostComponent.metrics.get',
-        sender: mixinObject,
-        data: {
-          componentName: 'C1',
-          metricPaths: 'w1,w2',
-          hostComponentCriteria: 'criteria'
-        }
-      })
+      var args = testHelpers.findAjaxRequest('name', 'widgets.hostComponent.metrics.get');
+      expect(args[0]).exists;
+      expect(args[0].sender).to.be.eql(mixinObject);
+      expect(args[0].data).to.be.eql({
+        componentName: 'C1',
+        metricPaths: 'w1,w2',
+        hostComponentCriteria: 'criteria'
+      });
     });
   });
 
   describe("#calculateValues()", function () {
-    var mixinObject = mixinClass.create();
 
     beforeEach(function () {
       sinon.stub(mixinObject, 'extractExpressions');
@@ -322,8 +318,6 @@ describe('App.WidgetMixin', function () {
   });
 
   describe("#computeExpression()", function () {
-    var mixinObject = mixinClass.create();
-
     it("expression missing metrics", function () {
       var expressions = ['e.m1'];
       var metrics = [];
@@ -354,14 +348,13 @@ describe('App.WidgetMixin', function () {
   });
 
   describe("#cloneWidget()", function () {
-    var mixinObject = mixinClass.create();
     var popup;
-    before(function () {
+    beforeEach(function () {
       sinon.spy(App, 'showConfirmationPopup');
       sinon.stub(mixinObject, 'postWidgetDefinition', Em.K);
       popup = mixinObject.cloneWidget();
     });
-    after(function () {
+    afterEach(function () {
       App.showConfirmationPopup.restore();
       mixinObject.postWidgetDefinition.restore();
     });
@@ -375,25 +368,19 @@ describe('App.WidgetMixin', function () {
   });
 
   describe("#postWidgetDefinition()", function () {
-    var mixinObject = mixinClass.create();
-
-    before(function () {
-      sinon.spy(App.ajax, 'send');
+    beforeEach(function () {
       sinon.stub(mixinObject, 'collectWidgetData').returns({});
     });
-    after(function () {
-      App.ajax.send.restore();
+    afterEach(function () {
       mixinObject.collectWidgetData.restore();
     });
     it("valid request is sent", function () {
       mixinObject.postWidgetDefinition();
-      expect(App.ajax.send.getCall(0).args[0]).to.eql({
-        name: 'widgets.wizard.add',
-        sender: mixinObject,
-        data: {
-          data: {}
-        },
-        success: 'postWidgetDefinitionSuccessCallback'
+      var args = testHelpers.findAjaxRequest('name', 'widgets.wizard.add');
+      expect(args[0]).exists;
+      expect(args[0].sender).to.be.eql(mixinObject);
+      expect(args[0].data).to.be.eql({
+        data: {}
       });
     });
   });

http://git-wip-us.apache.org/repos/asf/ambari/blob/ddf479ef/ambari-web/test/mixins/common/widgets/export_metrics_mixin_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/mixins/common/widgets/export_metrics_mixin_test.js b/ambari-web/test/mixins/common/widgets/export_metrics_mixin_test.js
index 9e91111..1cc0730 100644
--- a/ambari-web/test/mixins/common/widgets/export_metrics_mixin_test.js
+++ b/ambari-web/test/mixins/common/widgets/export_metrics_mixin_test.js
@@ -20,6 +20,7 @@ var App = require('app');
 
 require('mixins/common/widgets/export_metrics_mixin');
 var fileUtils = require('utils/file_utils');
+var testHelpers = require('test/helpers');
 
 describe('App.ExportMetricsMixin', function () {
 
@@ -72,7 +73,6 @@ describe('App.ExportMetricsMixin', function () {
     ];
 
     beforeEach(function () {
-      sinon.stub(App.ajax, 'send', Em.K);
       obj.reopen({
         targetView: {
           ajaxIndex: 'index',
@@ -85,30 +85,23 @@ describe('App.ExportMetricsMixin', function () {
       });
     });
 
-    afterEach(function () {
-      App.ajax.send.restore();
-    });
-
     cases.forEach(function (item) {
       describe(item.title, function () {
 
         beforeEach(function () {
           obj.set('isExportMenuHidden', item.isExportMenuHidden);
           obj.exportGraphData(item.event);
-          this.ajaxParams = App.ajax.send.firstCall.args[0];
+          this.ajaxParams = testHelpers.findAjaxRequest('name', 'index');
         });
 
         it('isExportMenuHidden is true', function () {
           expect(obj.get('isExportMenuHidden')).to.be.true;
         });
         it('one request was done', function () {
-          expect(App.ajax.send.calledOnce).to.be.true;
-        });
-        it('request to the valid end-point', function () {
-          expect(this.ajaxParams.name).to.equal('index');
+          expect(this.ajaxParams[0]).exists;
         });
         it('ajax-request with correct data', function () {
-          expect(this.ajaxParams.data).to.eql({
+          expect(this.ajaxParams[0].data).to.eql({
             p: 'v',
             isCSV: item.isCSV
           });

http://git-wip-us.apache.org/repos/asf/ambari/blob/ddf479ef/ambari-web/test/mixins/main/host/details/host_components/decommissionable_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/mixins/main/host/details/host_components/decommissionable_test.js b/ambari-web/test/mixins/main/host/details/host_components/decommissionable_test.js
index e0ee689..958874b 100644
--- a/ambari-web/test/mixins/main/host/details/host_components/decommissionable_test.js
+++ b/ambari-web/test/mixins/main/host/details/host_components/decommissionable_test.js
@@ -18,6 +18,7 @@
 
 var App = require('app');
 var uiEffects = require('utils/ui_effects');
+var testHelpers = require('test/helpers');
 
 require('mixins/main/host/details/host_components/decommissionable');
 
@@ -259,13 +260,6 @@ describe('App.Decommissionable', function () {
 
   describe("#getDecommissionStatus()", function() {
 
-    beforeEach(function() {
-      sinon.stub(App.ajax, 'send');
-    });
-    afterEach(function() {
-      App.ajax.send.restore();
-    });
-
     it("App.ajax.send should be called", function() {
       decommissionable.setProperties({
         componentForCheckDecommission: 'C1',
@@ -277,16 +271,13 @@ describe('App.Decommissionable', function () {
         })
       });
       decommissionable.getDecommissionStatus();
-      expect(App.ajax.send.getCall(0).args[0]).to.eql({
-        name: 'host.host_component.decommission_status',
-        sender: decommissionable,
-        data: {
-          hostName: 'host1',
-          componentName: 'C1',
-          serviceName: 'S1'
-        },
-        success: 'getDecommissionStatusSuccessCallback',
-        error: 'getDecommissionStatusErrorCallback'
+      var args = testHelpers.findAjaxRequest('name', 'host.host_component.decommission_status');
+      expect(args[0]).exists;
+      expect(args[0].sender).to.be.eql(decommissionable);
+      expect(args[0].data).to.be.eql({
+        hostName: 'host1',
+        componentName: 'C1',
+        serviceName: 'S1'
       });
     });
   });

http://git-wip-us.apache.org/repos/asf/ambari/blob/ddf479ef/ambari-web/test/mixins/main/host/details/host_components/install_component_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/mixins/main/host/details/host_components/install_component_test.js b/ambari-web/test/mixins/main/host/details/host_components/install_component_test.js
index f2e3513..56d582c 100644
--- a/ambari-web/test/mixins/main/host/details/host_components/install_component_test.js
+++ b/ambari-web/test/mixins/main/host/details/host_components/install_component_test.js
@@ -18,7 +18,7 @@
 
 var App = require('app');
 require('mixins/main/host/details/host_components/install_component');
-
+var testHelpers = require('test/helpers');
 var installComponent;
 
 describe('App.InstallComponent', function () {
@@ -35,12 +35,11 @@ describe('App.InstallComponent', function () {
 
     beforeEach(function() {
       sinon.stub(installComponent, 'updateAndCreateServiceComponent').returns({done: Em.clb});
-      sinon.stub(App.ajax, 'send');
       installComponent.installHostComponentCall('host1', component);
+      this.args = testHelpers.findAjaxRequest('name', 'host.host_component.add_new_component');
     });
     afterEach(function() {
       installComponent.updateAndCreateServiceComponent.restore();
-      App.ajax.send.restore();
     });
 
     it("updateAndCreateServiceComponent should be called", function() {
@@ -48,29 +47,25 @@ describe('App.InstallComponent', function () {
     });
 
     it("App.ajax.send should be called", function() {
-      expect(App.ajax.send.getCall(0).args[0]).to.eql({
-        name: 'host.host_component.add_new_component',
-        sender: installComponent,
-        data: {
-          hostName: 'host1',
-          component: component,
-          data: JSON.stringify({
-            RequestInfo: {
-              "context": Em.I18n.t('requestInfo.installHostComponent') + ' c1'
-            },
-            Body: {
-              host_components: [
-                {
-                  HostRoles: {
-                    component_name: 'C1'
-                  }
+      expect(this.args[0]).exists;
+      expect(this.args[0].sender).to.be.eql(installComponent);
+      expect(this.args[0].data).to.be.eql({
+        hostName: 'host1',
+        component: component,
+        data: JSON.stringify({
+          RequestInfo: {
+            "context": Em.I18n.t('requestInfo.installHostComponent') + ' c1'
+          },
+          Body: {
+            host_components: [
+              {
+                HostRoles: {
+                  component_name: 'C1'
                 }
-              ]
-            }
-          })
-        },
-        success: 'addNewComponentSuccessCallback',
-        error: 'ajaxErrorCallback'
+              }
+            ]
+          }
+        })
       });
     });
   });
@@ -85,32 +80,20 @@ describe('App.InstallComponent', function () {
       })
     };
 
-    beforeEach(function() {
-      sinon.stub(App.ajax, 'send');
-    });
-    afterEach(function() {
-      App.ajax.send.restore();
-    });
-
-
     it("App.ajax.send should be called", function() {
       installComponent.addNewComponentSuccessCallback({}, {}, params);
-      expect(App.ajax.send.getCall(0).args[0]).to.eql({
-        name: 'common.host.host_component.update',
-        sender: App.router.get('mainHostDetailsController'),
-        data: {
-          hostName: 'host1',
-          componentName: 'C1',
-          serviceName: 'S1',
-          component: params.component,
-          "context": Em.I18n.t('requestInfo.installNewHostComponent') + ' c1',
-          HostRoles: {
-            state: 'INSTALLED'
-          },
-          urlParams: "HostRoles/state=INIT"
+      var args = testHelpers.findAjaxRequest('name', 'common.host.host_component.update');
+      expect(args[0]).exists;
+      expect(args[0].data).to.be.eql({
+        hostName: 'host1',
+        componentName: 'C1',
+        serviceName: 'S1',
+        component: params.component,
+        "context": Em.I18n.t('requestInfo.installNewHostComponent') + ' c1',
+        HostRoles: {
+          state: 'INSTALLED'
         },
-        success: 'installNewComponentSuccessCallback',
-        error: 'ajaxErrorCallback'
+        urlParams: "HostRoles/state=INIT"
       });
     });
   });
@@ -118,7 +101,7 @@ describe('App.InstallComponent', function () {
   describe("#ajaxErrorCallback()", function() {
 
     beforeEach(function() {
-      sinon.stub(App.ajax, 'defaultErrorHandler');
+      sinon.stub(App.ajax, 'defaultErrorHandler', Em.K);
     });
     afterEach(function() {
       App.ajax.defaultErrorHandler.restore();
@@ -173,6 +156,8 @@ describe('App.InstallComponent', function () {
         serviceName: 'S1'
       })]);
       sinon.spy(dfd, 'resolve');
+
+      App.ajax.send.restore();
       sinon.stub(App.ajax, 'send').returns({complete: Em.clb});
       this.mock = sinon.stub(App.Service, 'find');
       this.mock.returns([{serviceName: "S1"}]);
@@ -183,7 +168,6 @@ describe('App.InstallComponent', function () {
       App.StackServiceComponent.find.restore();
       dfd.resolve.restore();
       this.mock.restore();
-      App.ajax.send.restore();
     });
 
     it("component already created", function() {
@@ -193,13 +177,12 @@ describe('App.InstallComponent', function () {
 
     it("component not created", function() {
       installComponent.createServiceComponent('C2', dfd);
-      expect(App.ajax.send.getCall(0).args[0]).to.eql({
-        name: 'common.create_component',
-        sender: installComponent,
-        data: {
-          componentName: 'C2',
-          serviceName: 'S1'
-        }
+      var args = testHelpers.findAjaxRequest('name', 'common.create_component');
+      expect(args[0]).exists;
+      expect(args[0].sender).to.be.eql(installComponent);
+      expect(args[0].data).to.be.eql({
+        componentName: 'C2',
+        serviceName: 'S1'
       });
       expect(dfd.resolve.calledOnce).to.be.true;
     });

http://git-wip-us.apache.org/repos/asf/ambari/blob/ddf479ef/ambari-web/test/mixins/wizard/wizardProgressPageController_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/mixins/wizard/wizardProgressPageController_test.js b/ambari-web/test/mixins/wizard/wizardProgressPageController_test.js
index 3d03292..ea0b3f7 100644
--- a/ambari-web/test/mixins/wizard/wizardProgressPageController_test.js
+++ b/ambari-web/test/mixins/wizard/wizardProgressPageController_test.js
@@ -17,6 +17,7 @@
  */
 
 var App = require('app');
+var testHelpers = require('test/helpers');
 
 describe('App.wizardProgressPageControllerMixin', function() {
   var mixedObject = Em.Object.extend(App.wizardProgressPageControllerMixin, {});
@@ -25,15 +26,8 @@ describe('App.wizardProgressPageControllerMixin', function() {
     var mixedObjectInstance;
     beforeEach(function() {
       mixedObjectInstance = mixedObject.create({});
-      sinon.stub(App.ajax, 'send', function(params) {
-        return $.extend(params,{complete: function(callback){
-          callback();
-        }});
-      });
       sinon.stub(mixedObjectInstance, "updateAndCreateServiceComponent").returns({
-        done: function(callback) {
-          return callback();
-        }
+        done: Em.clb
       });
       sinon.spy(mixedObjectInstance, 'onCreateComponent');
       sinon.spy(mixedObjectInstance, 'updateComponent');
@@ -68,7 +62,6 @@ describe('App.wizardProgressPageControllerMixin', function() {
     });
     
     afterEach(function() {
-      App.ajax.send.restore();
       App.StackServiceComponent.find.restore();
       mixedObjectInstance.updateAndCreateServiceComponent.restore();
       mixedObjectInstance.onCreateComponent.restore();
@@ -89,7 +82,7 @@ describe('App.wizardProgressPageControllerMixin', function() {
     describe('no ZooKeeper Servers installed. install on host1, host2. ajax request should be called with appropriate params', function() {
       beforeEach(function () {
         mixedObjectInstance.createComponent('ZOOKEEPER_SERVER', ['host1', 'host2'], 'ZOOKEEPER');
-        this.args = App.ajax.send.args[0][0];
+        this.args = testHelpers.findAjaxRequest('name', 'wizard.step8.register_host_to_component')[0];
         this.queryObject = JSON.parse(this.args.data.data);
       });
       it('hostName is valid array', function () {
@@ -114,7 +107,7 @@ describe('App.wizardProgressPageControllerMixin', function() {
     describe('ZooKeeper Client installed on host1. install on host1, host2. ajax request should be called with appropriate params', function() {
       beforeEach(function () {
         mixedObjectInstance.createComponent('ZOOKEEPER_CLIENT', ['host1', 'host2'], 'ZOOKEEPER');
-        this.args = App.ajax.send.args[0][0];
+        this.args = testHelpers.findAjaxRequest('name', 'wizard.step8.register_host_to_component')[0];
         this.queryObject = JSON.parse(this.args.data.data);
       });
       it('hostName is valid array', function () {
@@ -160,19 +153,14 @@ describe('App.wizardProgressPageControllerMixin', function() {
     
     testsAjax.forEach(function(test) {
       describe('called with params: ' + JSON.stringify(test.callParams), function() {
-        before(function() {
-          sinon.stub(App.ajax, 'send', Em.K);
+        beforeEach(function() {
           var mixedObjectInstance = mixedObject.create({});
           mixedObjectInstance.updateComponent.apply(mixedObjectInstance, test.callParams);
         });
 
-        after(function() {
-          App.ajax.send.restore();
-        });
-        
         test.e.forEach(function(eKey) {
           it('key: {0} should have value: {1}'.format(eKey.key, eKey.value), function() {
-            var args = App.ajax.send.args[0][0];
+            var args = testHelpers.findAjaxRequest('name', 'common.host_components.update')[0];
             expect(args).to.have.deep.property(eKey.key, eKey.value);
           });
         });

http://git-wip-us.apache.org/repos/asf/ambari/blob/ddf479ef/ambari-web/test/models/cluster_states_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/models/cluster_states_test.js b/ambari-web/test/models/cluster_states_test.js
index d8d6adc..d07845f 100644
--- a/ambari-web/test/models/cluster_states_test.js
+++ b/ambari-web/test/models/cluster_states_test.js
@@ -72,7 +72,6 @@ describe('App.clusterStatus', function () {
   describe('#setClusterStatus', function () {
 
     beforeEach(function() {
-      sinon.stub(App, 'get').withArgs('testMode').returns(false);
       sinon.stub(status, 'postUserPref', function() {
         return $.ajax();
       });
@@ -80,7 +79,6 @@ describe('App.clusterStatus', function () {
 
     afterEach(function () {
       status.postUserPref.restore();
-      App.get.restore();
     });
 
     it('should set cluster status in non-test mode', function () {

http://git-wip-us.apache.org/repos/asf/ambari/blob/ddf479ef/ambari-web/test/models/host_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/models/host_test.js b/ambari-web/test/models/host_test.js
index 37092da..d047a70 100644
--- a/ambari-web/test/models/host_test.js
+++ b/ambari-web/test/models/host_test.js
@@ -53,10 +53,6 @@ describe('App.Host', function () {
     }
   ];
 
-  before(function() {
-    App.set('testMode', false);
-  });
-
   App.Host.reopen({
     hostComponents: []
   });

http://git-wip-us.apache.org/repos/asf/ambari/blob/ddf479ef/ambari-web/test/router_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/router_test.js b/ambari-web/test/router_test.js
index cf638d9..de4b77a 100644
--- a/ambari-web/test/router_test.js
+++ b/ambari-web/test/router_test.js
@@ -17,34 +17,13 @@
  */
 
 var App = require('app');
+var testHelpers = require('test/helpers');
 
 require('router');
 
 describe('App.Router', function () {
   var router = App.Router.create();
 
-  describe.skip('#loginSuccessCallback()', function() {
-
-    beforeEach(function () {
-      sinon.stub(App.usersMapper, 'map');
-      sinon.stub(router, 'setUserLoggedIn');
-      sinon.stub(App.ajax, 'send');
-    });
-
-    afterEach(function() {
-      App.usersMapper.map.restore();
-      router.setUserLoggedIn.restore();
-      App.ajax.send.restore();
-    });
-
-    it('should log in user and load views', function () {
-      var userName = 'test';
-      router.loginSuccessCallback({},{},{loginName: userName});
-      expect(router.setUserLoggedIn.calledOnce).to.be.true;
-      expect(router.setUserLoggedIn.calledWith(userName)).to.be.true;
-    })
-  });
-
   describe('#initAdmin()', function () {
 
     var cases = [
@@ -373,20 +352,11 @@ describe('App.Router', function () {
   });
 
   describe("#transitionToAdminView()", function () {
-    beforeEach(function () {
-      sinon.stub(App.ajax, 'send');
-    });
-    afterEach(function () {
-      App.ajax.send.restore();
-    });
+
     it("valid request is sent", function () {
       router.transitionToAdminView();
-      expect(App.ajax.send.calledWith({
-        name: 'ambari.service.load_server_version',
-        sender: router,
-        success: 'adminViewInfoSuccessCallback',
-        error: 'adminViewInfoErrorCallback'
-      })).to.be.true;
+      var args = testHelpers.findAjaxRequest('name', 'ambari.service.load_server_version');
+      expect(args[0]).to.exists;
     });
   });
 
@@ -457,7 +427,6 @@ describe('App.Router', function () {
     });
 
     afterEach(function () {
-      App.ajax.send.restore();
       router.getCurrentLocationUrl.restore();
       router.redirectByURL.restore();
       this.mockGetCurrentLocationUrl.restore();
@@ -500,6 +469,7 @@ describe('App.Router', function () {
         beforeEach(function () {
           mockCurrentUrl = 'http://localhost:3333/#/some/hash';
           router.set('location.lastSetURL', test.lastSetURL);
+          App.ajax.send.restore(); // default ajax-mock can't be used here
           sinon.stub(App.ajax, 'send', function() {
             if (!test.isResolved) {
               router.onAuthenticationError(test.responseData);

http://git-wip-us.apache.org/repos/asf/ambari/blob/ddf479ef/ambari-web/test/utils/ajax/ajax_queue_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/utils/ajax/ajax_queue_test.js b/ambari-web/test/utils/ajax/ajax_queue_test.js
index 3c7ac85..89c7f61 100644
--- a/ambari-web/test/utils/ajax/ajax_queue_test.js
+++ b/ambari-web/test/utils/ajax/ajax_queue_test.js
@@ -26,14 +26,12 @@ describe('App.ajaxQueue', function () {
     ajaxQueue = App.ajaxQueue.create();
     sinon.spy(ajaxQueue, 'runNextRequest');
     sinon.spy(ajaxQueue, 'finishedCallback');
-    sinon.spy(App.ajax, 'send');
   });
 
   afterEach(function() {
     ajaxQueue.clear();
     ajaxQueue.runNextRequest.restore();
     ajaxQueue.finishedCallback.restore();
-    App.ajax.send.restore();
   });
 
   describe('#clear', function() {
@@ -100,12 +98,6 @@ describe('App.ajaxQueue', function () {
       ajaxQueue.runNextRequest();
       expect(ajaxQueue.finishedCallback.called).to.equal(true);
     });
-    it('if abortOnError is false queue shouldn\'t be interrupted', function() {
-      ajaxQueue.clear();
-      ajaxQueue.set('abortOnError', false);
-      ajaxQueue.addRequest({name:'some_fake', sender: Em.Object.create()}).addRequest({name: 'some_fake2', sender: Em.Object.create()}).start();
-      expect(ajaxQueue.runNextRequest.callCount).to.equal(3); // One for empty-queue
-    });
   });
 
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/ddf479ef/ambari-web/test/utils/ajax/ajax_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/utils/ajax/ajax_test.js b/ambari-web/test/utils/ajax/ajax_test.js
index 693829c..b0749df 100644
--- a/ambari-web/test/utils/ajax/ajax_test.js
+++ b/ambari-web/test/utils/ajax/ajax_test.js
@@ -22,18 +22,13 @@ require('utils/ajax/ajax');
 describe('App.ajax', function() {
 
   beforeEach(function() {
+    App.ajax.send.restore();
+    sinon.spy(App.ajax, 'send'); // no sense to test stubbed function, so going to spy on it
     App.set('apiPrefix', '/api/v1');
     App.set('clusterName', 'tdk');
   });
 
   describe('#send', function() {
-    beforeEach(function() {
-      sinon.spy($, 'ajax');
-    });
-
-    afterEach(function() {
-      $.ajax.restore();
-    });
     it('Without sender', function() {
       expect(App.ajax.send({})).to.equal(null);
       expect($.ajax.called).to.equal(false);
@@ -110,14 +105,6 @@ describe('App.ajax', function() {
 
   describe('#formatRequest', function() {
 
-    beforeEach(function () {
-      sinon.stub(App, 'get').withArgs('testMode').returns(false);
-    });
-
-    afterEach(function () {
-      App.get.restore();
-    });
-
     var tests = [
       {
         urlObj: {

http://git-wip-us.apache.org/repos/asf/ambari/blob/ddf479ef/ambari-web/test/utils/batch_scheduled_requests_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/utils/batch_scheduled_requests_test.js b/ambari-web/test/utils/batch_scheduled_requests_test.js
index f564824..c282350 100644
--- a/ambari-web/test/utils/batch_scheduled_requests_test.js
+++ b/ambari-web/test/utils/batch_scheduled_requests_test.js
@@ -131,75 +131,4 @@ describe('batch_scheduled_requests', function() {
 
   });
 
-  describe('#restartHostComponents', function() {
-
-    beforeEach(function() {
-      sinon.spy($, 'ajax');
-      sinon.stub(App, 'get', function(k) {
-        if ('testMode' === k) return true;
-        return Em.get(App, k);
-      });
-    });
-
-    afterEach(function() {
-      $.ajax.restore();
-      App.get.restore();
-    });
-
-    var tests = Em.A([
-      {
-        hostComponentList: Em.A([
-          Em.Object.create({
-            componentName: 'NAMENODE',
-            hostName: 'h1'
-          }),
-          Em.Object.create({
-            componentName: 'NAMENODE',
-            hostName: 'h2'
-          })
-        ]),
-        e: {
-          ajaxCalledOnce: true,
-          resource_filters: [{"service_name": "HDFS", "component_name":"NAMENODE","hosts":"h1,h2"}]
-        },
-        m: '1 component on 2 hosts'
-      },
-      {
-        hostComponentList: Em.A([
-          Em.Object.create({
-            componentName: 'NAMENODE',
-            hostName: 'h1'
-          }),
-          Em.Object.create({
-            componentName: 'NAMENODE',
-            hostName: 'h2'
-          }),
-          Em.Object.create({
-            componentName: 'HBASE_MASTER',
-            hostName: 'h2'
-          })
-        ]),
-        e: {
-          ajaxCalledOnce: true,
-          resource_filters: [{"service_name": "HDFS", "component_name":"NAMENODE","hosts":"h1,h2"},{"service_name": "HBASE", "component_name":"HBASE_MASTER","hosts":"h2"}]
-        },
-        m: '1 component on 2 hosts, 1 on 1 host'
-      }
-    ]);
-
-    tests.forEach(function(test) {
-      it(test.m, function() {
-        batchUtils.restartHostComponents(test.hostComponentList);
-        expect($.ajax.calledOnce).to.equal(test.e.ajaxCalledOnce);
-        expect( JSON.parse($.ajax.args[0][0].data)['Requests/resource_filters']).to.eql(test.e.resource_filters);
-      });
-    });
-
-    it('Empty data', function() {
-      batchUtils.restartHostComponents([]);
-      expect($.ajax.called).to.equal(false);
-    });
-
-  });
-
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/ddf479ef/ambari-web/test/utils/host_progress_popup_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/utils/host_progress_popup_test.js b/ambari-web/test/utils/host_progress_popup_test.js
index 1d143a7..dea2666 100644
--- a/ambari-web/test/utils/host_progress_popup_test.js
+++ b/ambari-web/test/utils/host_progress_popup_test.js
@@ -302,11 +302,9 @@ describe('App.HostPopup', function () {
 
   describe('#abortRequest', function () {
     beforeEach(function () {
-      sinon.stub(App.ajax, 'send', Em.K);
       sinon.spy(App, 'showConfirmationPopup');
     });
     afterEach(function () {
-      App.ajax.send.restore();
       App.showConfirmationPopup.restore();
     });
     it('should show confirmation popup', function () {

http://git-wip-us.apache.org/repos/asf/ambari/blob/ddf479ef/ambari-web/test/utils/updater_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/utils/updater_test.js b/ambari-web/test/utils/updater_test.js
index 1f0c90f..947411d 100644
--- a/ambari-web/test/utils/updater_test.js
+++ b/ambari-web/test/utils/updater_test.js
@@ -18,84 +18,87 @@
 
 var App = require('app');
 require('utils/updater');
-describe('utils/updater', function() {
-  describe('#App.updater', function() {
-    beforeEach(function() {
-      this.clock = sinon.useFakeTimers();
-      sinon.stub(App.router, "get").returns('test');
-    });
+describe('utils/updater', function () {
+  beforeEach(function () {
+    this.clock = sinon.useFakeTimers();
+    sinon.stub(App.router, "get").returns('test');
+    App.updater.run.restore();
+    sinon.spy(App.updater, 'run');
+    App.updater.immediateRun.restore();
+    sinon.spy(App.updater, 'immediateRun');
+  });
 
-    var tests = {
-      t1: {
-        obj: Em.Object.create({
-          method: sinon.spy(),
-          isWorking: true
-        }),
-        m: 'method called once with default interval in 15 000 ms'
-      },
-      t2: {
-        obj: Em.Object.create({
-          method: function() {}
-        }),
-        m: 'should return false if key name is invalid or absent'
-      },
-      t3: {
-        obj: Em.Object.create({
-          method2: sinon.spy(),
-          isWorking: true
-        }),
-        m: 'method should be called immediately'
-      },
-      t4: {
-        obj: Em.Object.create({
-          method3: sinon.spy(),
-          isWorking: true
-        }),
-        m: 'method call should be ignored if `isWorking` set to false'
-      },
-      t5: {
-        obj: Em.Object.create({
-          method4: sinon.spy(),
-          isWorking: true
-        }),
-        m: 'method call should be ignored if urlPattern is not matching router location'
-      }
-    };
+  var tests = {
+    t1: {
+      obj: Em.Object.create({
+        method: sinon.spy(),
+        isWorking: true
+      }),
+      m: 'method called once with default interval in 15 000 ms'
+    },
+    t2: {
+      obj: Em.Object.create({
+        method: function () {
+        }
+      }),
+      m: 'should return false if key name is invalid or absent'
+    },
+    t3: {
+      obj: Em.Object.create({
+        method2: sinon.spy(),
+        isWorking: true
+      }),
+      m: 'method should be called immediately'
+    },
+    t4: {
+      obj: Em.Object.create({
+        method3: sinon.spy(),
+        isWorking: true
+      }),
+      m: 'method call should be ignored if `isWorking` set to false'
+    },
+    t5: {
+      obj: Em.Object.create({
+        method4: sinon.spy(),
+        isWorking: true
+      }),
+      m: 'method call should be ignored if urlPattern is not matching router location'
+    }
+  };
 
-    it(tests.t1.m, function() {
-      App.updater.run(tests.t1.obj, 'method', 'isWorking');
-      this.clock.tick(15000);
-      expect(tests.t1.obj.method.called).to.be.ok;
-    });
+  it(tests.t1.m, function () {
+    App.updater.run(tests.t1.obj, 'method', 'isWorking');
+    this.clock.tick(3600000 * 1.5);
+    expect(tests.t1.obj.method.called).to.be.ok;
+  });
 
-    it(tests.t2.m, function() {
-      var methodCall = App.updater.run(tests.t2.obj, 'method', 'isWorking');
-      expect(methodCall).to.be.false;
-    });
+  it(tests.t2.m, function () {
+    var methodCall = App.updater.run(tests.t2.obj, 'method', 'isWorking');
+    expect(methodCall).to.be.false;
+  });
 
-    it(tests.t3.m, function() {
-      App.updater.run(tests.t3.obj, 'method2', 'isWorking');
-      App.updater.immediateRun('method2');
-      expect(tests.t3.obj.method2.called).to.be.ok;
-    });
+  it(tests.t3.m, function () {
+    App.updater.run(tests.t3.obj, 'method2', 'isWorking');
+    App.updater.immediateRun('method2');
+    expect(tests.t3.obj.method2.called).to.be.ok;
+  });
 
-    it(tests.t4.m, function() {
-      App.updater.run(tests.t4.obj, 'method3', 'isWorking');
-      this.clock.tick(10000);
-      tests.t4.obj.set('isWorking', false);
-      this.clock.tick(5000);
-      expect(tests.t4.obj.method3.called).to.be.false;
-    });
+  it(tests.t4.m, function () {
+    App.updater.run(tests.t4.obj, 'method3', 'isWorking');
+    this.clock.tick(10000);
+    tests.t4.obj.set('isWorking', false);
+    this.clock.tick(5000);
+    expect(tests.t4.obj.method3.called).to.be.false;
+  });
 
-    it(tests.t5.m, function () {
-      App.updater.run(tests.t5.obj, 'method4', 'isWorking', 15000, 'pattern');
-      this.clock.tick(15000);
-      expect(tests.t5.obj.method4.called).to.be.false;
-    });
+  it(tests.t5.m, function () {
+    App.updater.run(tests.t5.obj, 'method4', 'isWorking', 15000, 'pattern');
+    this.clock.tick(15000);
+    expect(tests.t5.obj.method4.called).to.be.false;
+  });
 
-    afterEach(function() {
-      this.clock.restore();
-      App.router.get.restore();
-    });
+  afterEach(function () {
+    this.clock.restore();
+    App.router.get.restore();
   });
-});
+});
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/ddf479ef/ambari-web/test/views/common/chart/linear_time_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/chart/linear_time_test.js b/ambari-web/test/views/common/chart/linear_time_test.js
index 377e392..40f11ac 100644
--- a/ambari-web/test/views/common/chart/linear_time_test.js
+++ b/ambari-web/test/views/common/chart/linear_time_test.js
@@ -18,6 +18,7 @@
 
 var App = require('app');
 require('views/common/chart/linear_time');
+var testHelpers = require('test/helpers');
 
 describe('App.ChartLinearTimeView', function () {
 
@@ -464,6 +465,7 @@ describe('App.ChartLinearTimeView.LoadAggregator', function () {
       sinon.stub(aggregator, 'formatRequestData', function(_request){
         return _request.fields;
       });
+      App.ajax.send.restore();
       sinon.stub(App.ajax, 'send', function(){
         return {
           done: Em.K,
@@ -473,7 +475,6 @@ describe('App.ChartLinearTimeView.LoadAggregator', function () {
     });
     afterEach(function () {
       aggregator.groupRequests.restore();
-      App.ajax.send.restore();
       aggregator.formatRequestData.restore();
     });
     it("valid request is sent", function () {
@@ -486,13 +487,12 @@ describe('App.ChartLinearTimeView.LoadAggregator', function () {
         }
       };
       aggregator.runRequests(requests);
-      expect(App.ajax.send.getCall(0).args[0]).to.eql({
-        name: 'r1',
-        sender: context,
-        data: {
-          fields: ['f3', 'f4'],
-          hostName: 'host1'
-        }
+      var args = testHelpers.findAjaxRequest('name', 'r1');
+      expect(args[0]).exists;
+      expect(args[0].sender).to.be.eql(context);
+      expect(args[0].data).to.be.eql({
+        fields: ['f3', 'f4'],
+        hostName: 'host1'
       });
     });
   });

http://git-wip-us.apache.org/repos/asf/ambari/blob/ddf479ef/ambari-web/test/views/common/configs/config_history_flow_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/configs/config_history_flow_test.js b/ambari-web/test/views/common/configs/config_history_flow_test.js
index df777e9..0733bd8 100644
--- a/ambari-web/test/views/common/configs/config_history_flow_test.js
+++ b/ambari-web/test/views/common/configs/config_history_flow_test.js
@@ -18,7 +18,7 @@
 
 var App = require('app');
 require('views/common/configs/config_history_flow');
-
+var testHelpers = require('test/helpers');
 
 describe.skip('App.ConfigHistoryFlowView', function () {
 
@@ -299,7 +299,7 @@ describe.skip('App.ConfigHistoryFlowView', function () {
       App.tooltip.restore();
     });
 
-    it('App.tooltip is called on�e', function () {
+    it('App.tooltip is called on�e', function () {
       expect(App.tooltip.calledOnce).to.be.true;
     });
   });
@@ -624,16 +624,12 @@ describe.skip('App.ConfigHistoryFlowView', function () {
   describe('#sendRevertCall()', function () {
 
     beforeEach(function () {
-      sinon.stub(App.ajax, 'send', Em.K);
       view.sendRevertCall(Em.Object.create());
     });
 
-    afterEach(function () {
-      App.ajax.send.restore();
-    });
-
     it('request is sent', function () {
-      expect(App.ajax.send.calledOnce).to.be.true;
+      var args = testHelpers.findAjaxRequest('name', 'service.serviceConfigVersion.revert');
+      expect(args).exists;
     });
   });
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/ddf479ef/ambari-web/test/views/common/controls_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/controls_view_test.js b/ambari-web/test/views/common/controls_view_test.js
index a097151..b3ace8c 100644
--- a/ambari-web/test/views/common/controls_view_test.js
+++ b/ambari-web/test/views/common/controls_view_test.js
@@ -19,6 +19,7 @@
 var App = require('app');
 require('views/common/controls_view');
 var validator = require('utils/validator');
+var testHelpers = require('test/helpers');
 
 describe('App.ServiceConfigRadioButtons', function () {
 
@@ -793,23 +794,23 @@ describe('App.CheckDBConnectionView', function () {
         getConnectionProperty: Em.K,
         masterHostName: 'host1'
       });
-      sinon.stub(App.ajax, 'send');
       this.mock = sinon.stub(App.Service, 'find');
     });
     afterEach(function () {
-      App.ajax.send.restore();
       this.mock.restore();
     });
 
     it("service not installed", function() {
       this.mock.returns(Em.Object.create({isLoaded: false}));
       view.createCustomAction();
-      expect(App.ajax.send.getCall(0).args[0].name).to.equal('custom_action.create');
+      var args = testHelpers.findAjaxRequest('name', 'custom_action.create');
+      expect(args[0]).exists;
     });
     it("service is installed", function() {
       this.mock.returns(Em.Object.create({isLoaded: true}));
       view.createCustomAction();
-      expect(App.ajax.send.getCall(0).args[0].name).to.equal('cluster.custom_action.create');
+      var args = testHelpers.findAjaxRequest('name', 'cluster.custom_action.create');
+      expect(args[0]).exists;
     });
   });
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/ddf479ef/ambari-web/test/views/common/quick_link_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/quick_link_view_test.js b/ambari-web/test/views/common/quick_link_view_test.js
index b9aecee..7f9d1ed 100644
--- a/ambari-web/test/views/common/quick_link_view_test.js
+++ b/ambari-web/test/views/common/quick_link_view_test.js
@@ -18,6 +18,7 @@
 
 var App = require('app');
 require('views/common/quick_view_link_view');
+var testHelpers = require('test/helpers');
 
 describe('App.QuickViewLinks', function () {
 
@@ -111,20 +112,12 @@ describe('App.QuickViewLinks', function () {
   });
 
   describe("#loadTags()", function () {
-    beforeEach(function () {
-      sinon.stub(App.ajax, 'send');
-    });
-    afterEach(function () {
-      App.ajax.send.restore();
-    });
+
     it("call $.ajax", function () {
       quickViewLinks.loadTags();
-      expect(App.ajax.send.calledWith({
-        name: 'config.tags',
-        sender: quickViewLinks,
-        success: 'loadTagsSuccess',
-        error: 'loadTagsError'
-      })).to.be.true;
+      var args = testHelpers.findAjaxRequest('name', 'config.tags');
+      expect(args[0]).exists;
+      expect(args[0].sender).to.be.eql(quickViewLinks);
     });
   });
 
@@ -132,9 +125,7 @@ describe('App.QuickViewLinks', function () {
     beforeEach(function () {
       sinon.stub(quickViewLinks, 'setConfigProperties', function () {
         return {
-          done: function (callback) {
-            callback();
-          }
+          done: Em.clb
         }
       });
       sinon.stub(quickViewLinks, 'getQuickLinksHosts');
@@ -233,7 +224,6 @@ describe('App.QuickViewLinks', function () {
 
   describe("#getQuickLinksHosts()", function () {
     beforeEach(function () {
-      sinon.stub(App.ajax, 'send');
       sinon.stub(App.HostComponent, 'find').returns([
         Em.Object.create({
           isMaster: true,
@@ -242,35 +232,30 @@ describe('App.QuickViewLinks', function () {
       ]);
     });
     afterEach(function () {
-      App.ajax.send.restore();
       App.HostComponent.find.restore();
     });
     it("call $.ajax", function () {
       quickViewLinks.getQuickLinksHosts();
-      expect(App.ajax.send.calledWith({
-        name: 'hosts.for_quick_links',
-        sender: quickViewLinks,
-        data: {
-          clusterName: App.get('clusterName'),
-          masterHosts: 'host1',
-          urlParams: ''
-        },
-        success: 'setQuickLinksSuccessCallback'
-      })).to.be.true;
+      var args = testHelpers.findAjaxRequest('name', 'hosts.for_quick_links');
+      expect(args[0]).exists;
+      expect(args[0].sender).to.be.eql(quickViewLinks);
+      expect(args[0].data).to.be.eql({
+        clusterName: App.get('clusterName'),
+        masterHosts: 'host1',
+        urlParams: ''
+      });
     });
     it("call $.ajax, HBASE service", function () {
       quickViewLinks.set('content.serviceName', 'HBASE');
       quickViewLinks.getQuickLinksHosts();
-      expect(App.ajax.send.calledWith({
-        name: 'hosts.for_quick_links',
-        sender: quickViewLinks,
-        data: {
-          clusterName: App.get('clusterName'),
-          masterHosts: 'host1',
-          urlParams: ',host_components/metrics/hbase/master/IsActiveMaster'
-        },
-        success: 'setQuickLinksSuccessCallback'
-      })).to.be.true;
+      var args = testHelpers.findAjaxRequest('name', 'hosts.for_quick_links');
+      expect(args[0]).exists;
+      expect(args[0].sender).to.be.eql(quickViewLinks);
+      expect(args[0].data).to.be.eql({
+        clusterName: App.get('clusterName'),
+        masterHosts: 'host1',
+        urlParams: ',host_components/metrics/hbase/master/IsActiveMaster'
+      });
     });
   });
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/ddf479ef/ambari-web/test/views/common/widget/gauge_widget_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/widget/gauge_widget_view_test.js b/ambari-web/test/views/common/widget/gauge_widget_view_test.js
index 6ed4828..2ba4816 100644
--- a/ambari-web/test/views/common/widget/gauge_widget_view_test.js
+++ b/ambari-web/test/views/common/widget/gauge_widget_view_test.js
@@ -20,14 +20,24 @@ var App = require('app');
 require('views/common/widget/gauge_widget_view');
 
 describe('App.GaugeWidgetView', function () {
-  var view = App.GaugeWidgetView.create({
-    value: 0,
-    content: {
-      properties: {
-        warning_threshold: 0,
-        critical_threshold: 0
+
+  var view;
+
+  beforeEach(function () {
+    view = App.GaugeWidgetView.create({
+      value: 0,
+      content: {
+        properties: {
+          warning_threshold: 0,
+          critical_threshold: 0
+        }
       }
-    }
+    });
+  });
+
+  afterEach(function () {
+    clearTimeout(view.get('timeoutId'));
+    view.destroy();
   });
 
   describe("#chartView.contentColor()", function() {

http://git-wip-us.apache.org/repos/asf/ambari/blob/ddf479ef/ambari-web/test/views/common/widget/graph_widget_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/widget/graph_widget_view_test.js b/ambari-web/test/views/common/widget/graph_widget_view_test.js
index e34c081..31c9db0 100644
--- a/ambari-web/test/views/common/widget/graph_widget_view_test.js
+++ b/ambari-web/test/views/common/widget/graph_widget_view_test.js
@@ -21,7 +21,17 @@ require('views/common/widget/graph_widget_view');
 var fileUtils = require('utils/file_utils');
 
 describe('App.GraphWidgetView', function () {
-  var view = App.GraphWidgetView.create();
+
+  var view;
+
+  beforeEach(function () {
+    view = App.GraphWidgetView.create();
+  });
+
+  afterEach(function () {
+    clearTimeout(view.get('timeoutId'));
+    view.destroy();
+  });
 
   describe("#adjustData()", function() {
     var testCases = [

http://git-wip-us.apache.org/repos/asf/ambari/blob/ddf479ef/ambari-web/test/views/common/widget/number_widget_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/widget/number_widget_view_test.js b/ambari-web/test/views/common/widget/number_widget_view_test.js
index 3a55314..f82819e 100644
--- a/ambari-web/test/views/common/widget/number_widget_view_test.js
+++ b/ambari-web/test/views/common/widget/number_widget_view_test.js
@@ -20,14 +20,24 @@ var App = require('app');
 require('views/common/widget/number_widget_view');
 
 describe('App.NumberWidgetView', function () {
-  var view = App.NumberWidgetView.create({
-    value: 0,
-    content: {
-      properties: {
-        warning_threshold: 0,
-        critical_threshold: 0
+
+  var view;
+
+  beforeEach(function () {
+    view = App.NumberWidgetView.create({
+      value: 0,
+      content: {
+        properties: {
+          warning_threshold: 0,
+          critical_threshold: 0
+        }
       }
-    }
+    });
+  });
+
+  afterEach(function () {
+    clearTimeout(view.get('timeoutId'));
+    view.destroy();
   });
 
   describe("#contentColor()", function() {

http://git-wip-us.apache.org/repos/asf/ambari/blob/ddf479ef/ambari-web/test/views/main/admin/stack_upgrade/upgrade_group_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/admin/stack_upgrade/upgrade_group_view_test.js b/ambari-web/test/views/main/admin/stack_upgrade/upgrade_group_view_test.js
index 2aed7e9..3adb874 100644
--- a/ambari-web/test/views/main/admin/stack_upgrade/upgrade_group_view_test.js
+++ b/ambari-web/test/views/main/admin/stack_upgrade/upgrade_group_view_test.js
@@ -21,9 +21,19 @@ var App = require('app');
 require('views/main/admin/stack_upgrade/upgrade_group_view');
 
 describe('App.upgradeGroupView', function () {
-  var view = App.upgradeGroupView.create({
-    content: Em.Object.create({}),
-    failedStatuses: ['FAILED']
+  var view;
+
+  beforeEach(function () {
+    view = App.upgradeGroupView.create({
+      content: Em.Object.create({}),
+      failedStatuses: ['FAILED']
+    });
+  });
+
+  afterEach(function () {
+    clearTimeout(view.get('timer'));
+    clearTimeout(view.get('upgradeItemTimer'));
+    view.destroy();
   });
 
   describe("#toggleExpanded()", function () {

http://git-wip-us.apache.org/repos/asf/ambari/blob/ddf479ef/ambari-web/test/views/main/admin/stack_upgrade/upgrade_wizard_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/admin/stack_upgrade/upgrade_wizard_view_test.js b/ambari-web/test/views/main/admin/stack_upgrade/upgrade_wizard_view_test.js
index 25182a1..6349dfe 100644
--- a/ambari-web/test/views/main/admin/stack_upgrade/upgrade_wizard_view_test.js
+++ b/ambari-web/test/views/main/admin/stack_upgrade/upgrade_wizard_view_test.js
@@ -19,12 +19,13 @@
 
 var App = require('app');
 require('views/main/admin/stack_upgrade/upgrade_wizard_view');
+var testHelpers = require('test/helpers');
 
-describe('App.upgradeWizardView', function () {
-  var view = App.upgradeWizardView.create({
+function getView() {
+  var v = App.upgradeWizardView.create({
     failedStatuses: ['FAILED']
   });
-  view.reopen({
+  v.reopen({
     controller: Em.Object.create({
       finalizeContext: 'Confirm Finalize',
       upgradeData: Em.Object.create(),
@@ -35,21 +36,29 @@ describe('App.upgradeWizardView', function () {
       }
     })
   });
-  view.removeObserver('App.clusterName', view, 'startPolling');
+  v.removeObserver('App.clusterName', v, 'startPolling');
+  return v;
+}
+
+describe('App.upgradeWizardView', function () {
+  var view;
 
   beforeEach(function () {
+    App.ajax.send.restore();
     sinon.stub(App.ajax, 'send').returns({
       complete: Em.clb
     });
+    view = getView();
   });
 
   afterEach(function () {
-    App.ajax.send.restore();
+    clearTimeout(view.get('upgradeItemTimer'));
+    view.destroy();
   });
 
-  App.TestAliases.testAsComputedOr(view, 'isManualProceedDisabled', ['!isManualDone', 'controller.requestInProgress']);
+  App.TestAliases.testAsComputedOr(getView(), 'isManualProceedDisabled', ['!isManualDone', 'controller.requestInProgress']);
 
-  App.TestAliases.testAsComputedEqualProperties(view, 'isFinalizeItem', 'manualItem.context', 'controller.finalizeContext');
+  App.TestAliases.testAsComputedEqualProperties(getView(), 'isFinalizeItem', 'manualItem.context', 'controller.finalizeContext');
 
   describe("#upgradeGroups", function () {
     it("upgradeGroups is null", function () {
@@ -107,9 +116,7 @@ describe('App.upgradeWizardView', function () {
     beforeEach(function () {
       sinon.stub(view.get('controller'), 'loadUpgradeData', function () {
         return {
-          done: function (callback) {
-            callback();
-          }
+          done: Em.clb
         }
       });
       sinon.stub(view, 'doPolling', Em.K);
@@ -135,10 +142,10 @@ describe('App.upgradeWizardView', function () {
   });
 
   describe("#willInsertElement()", function () {
-    before(function () {
+    beforeEach(function () {
       sinon.stub(view, 'startPolling', Em.K);
     });
-    after(function () {
+    afterEach(function () {
       view.startPolling.restore();
     });
     it("call startPolling()", function () {
@@ -159,9 +166,7 @@ describe('App.upgradeWizardView', function () {
     beforeEach(function () {
       sinon.stub(view.get('controller'), 'loadUpgradeData', function () {
         return {
-          done: function (callback) {
-            callback();
-          }
+          done: Em.clb
         }
       });
       sinon.spy(view, 'doPolling');
@@ -231,6 +236,13 @@ describe('App.upgradeWizardView', function () {
   });
 
   describe("#manualItem", function () {
+
+    beforeEach(function () {
+      view.reopen({
+        activeGroup: Em.Object.create()
+      });
+    });
+
     it("no running item", function () {
       view.set('activeGroup.upgradeItems', []);
       view.propertyDidChange('manualItem');
@@ -252,6 +264,13 @@ describe('App.upgradeWizardView', function () {
   });
 
   describe("#failedItem", function () {
+
+    beforeEach(function () {
+      view.reopen({
+        activeGroup: Em.Object.create()
+      });
+    });
+
     it("no running item", function () {
       view.set('activeGroup.upgradeItems', []);
       view.propertyDidChange('failedItem');
@@ -265,6 +284,13 @@ describe('App.upgradeWizardView', function () {
   });
 
   describe("#runningItem", function () {
+
+    beforeEach(function () {
+      view.reopen({
+        activeGroup: Em.Object.create()
+      });
+    });
+
     it("no running item", function () {
       view.set('activeGroup.upgradeItems', []);
       view.propertyDidChange('runningItem');
@@ -395,7 +421,7 @@ describe('App.upgradeWizardView', function () {
     });
   });
 
-  App.TestAliases.testAsComputedAnd(view, 'isDowngradeAvailable', ['!controller.isDowngrade', 'controller.downgradeAllowed']);
+  App.TestAliases.testAsComputedAnd(getView(), 'isDowngradeAvailable', ['!controller.isDowngrade', 'controller.downgradeAllowed']);
 
   describe("#taskDetails", function () {
     it("runningItem present", function () {
@@ -429,10 +455,10 @@ describe('App.upgradeWizardView', function () {
   });
 
   describe("#toggleDetails()", function () {
-    before(function () {
+    beforeEach(function () {
       sinon.stub(view, 'toggleProperty', Em.K);
     });
-    after(function () {
+    afterEach(function () {
       view.toggleProperty.restore();
     });
     it("isDetailsOpened is toggled", function () {
@@ -442,6 +468,11 @@ describe('App.upgradeWizardView', function () {
   });
 
   describe("#upgradeStatusLabel", function () {
+
+    beforeEach(function () {
+      Em.setFullPath(view, 'controller.upgradeData.Upgrade', {});
+    });
+
     [
       {
         data: {
@@ -604,19 +635,19 @@ describe('App.upgradeWizardView', function () {
     beforeEach(function () {
       sinon.stub(view.get('controller'), 'getUpgradeItem', function () {
         return {
-          complete: function (callback) {
-            callback();
-          }
+          complete: Em.clb
         }
       });
       sinon.spy(view, 'doUpgradeItemPolling');
       this.clock = sinon.useFakeTimers();
     });
+
     afterEach(function () {
       view.get('controller').getUpgradeItem.restore();
       view.doUpgradeItemPolling.restore();
       this.clock.restore();
     });
+
     it("running item details", function () {
       view.reopen({
         runningItem: {},
@@ -628,24 +659,24 @@ describe('App.upgradeWizardView', function () {
       this.clock.tick(App.bgOperationsUpdateInterval);
       expect(view.doUpgradeItemPolling.calledTwice).to.be.true;
     });
+
     it("failed item details", function () {
       view.reopen({
         failedItem: {},
         runningItem: null
       });
       view.set('isDetailsOpened', true);
-      view.doUpgradeItemPolling();
       expect(view.get('controller').getUpgradeItem.calledOnce).to.be.true;
       this.clock.tick(App.bgOperationsUpdateInterval);
       expect(view.doUpgradeItemPolling.calledTwice).to.be.true;
     });
+
     it("details not opened", function () {
       view.set('isDetailsOpened', false);
       //doUpgradeItemPolling triggered by observer
-      expect(view.get('controller').getUpgradeItem.calledOnce).to.be.false;
-      this.clock.tick(App.bgOperationsUpdateInterval);
-      expect(view.doUpgradeItemPolling.calledOnce).to.be.true;
+      expect(view.get('controller').getUpgradeItem.called).to.be.false;
     });
+
   });
 
   describe('#getSkippedServiceChecks()', function () {
@@ -689,17 +720,25 @@ describe('App.upgradeWizardView', function () {
           view.propertyDidChange('isFinalizeItem');
         });
 
-        it('request is sent ' + item.ajaxSendCallCount + ' times', function (){
-          expect(App.ajax.send.callCount).to.equal(item.ajaxSendCallCount);
-        });
-
         it('areSkippedServiceChecksLoaded is ' + item.areSkippedServiceChecksLoaded, function () {
           expect(view.get('controller.areSkippedServiceChecksLoaded')).to.equal(item.areSkippedServiceChecksLoadedResult);
         });
 
         if (item.ajaxSendCallCount) {
+          it('request is sent ' + item.ajaxSendCallCount + ' times', function (){
+            var args = testHelpers.findAjaxRequest('name', 'admin.upgrade.service_checks');
+            expect(args).to.have.property('length').equal(item.ajaxSendCallCount);
+          });
+
           it('upgradeId is 1', function () {
-            expect(App.ajax.send.firstCall.args[0].data.upgradeId).to.equal(1);
+            var args = testHelpers.findAjaxRequest('name', 'admin.upgrade.service_checks');
+            expect(args[0].data.upgradeId).to.equal(1);
+          });
+        }
+        else {
+          it('request is not sent times', function () {
+            var args = testHelpers.findAjaxRequest('name', 'admin.upgrade.service_checks');
+            expect(args).not.exists;
           });
         }
       });
@@ -809,9 +848,7 @@ describe('App.upgradeWizardView', function () {
     beforeEach(function () {
       sinon.stub(view.get('controller'), 'getUpgradeItem', function () {
         return {
-          complete: function (callback) {
-            callback();
-          }
+          complete: Em.clb
         }
       });
       view.set('controller.areSlaveComponentFailuresHostsLoaded', false);
@@ -841,9 +878,7 @@ describe('App.upgradeWizardView', function () {
     beforeEach(function () {
       sinon.stub(view.get('controller'), 'getUpgradeItem', function () {
         return {
-          complete: function (callback) {
-            callback();
-          }
+          complete: Em.clb
         }
       });
       view.set('controller.areServiceCheckFailuresServicenamesLoaded', false);

http://git-wip-us.apache.org/repos/asf/ambari/blob/ddf479ef/ambari-web/test/views/main/admin/stack_upgrade/version_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/admin/stack_upgrade/version_view_test.js b/ambari-web/test/views/main/admin/stack_upgrade/version_view_test.js
index c4eaa74..511c549 100644
--- a/ambari-web/test/views/main/admin/stack_upgrade/version_view_test.js
+++ b/ambari-web/test/views/main/admin/stack_upgrade/version_view_test.js
@@ -19,16 +19,26 @@
 
 var App = require('app');
 require('views/main/admin/stack_upgrade/upgrade_wizard_view');
+var testHelpers = require('test/helpers');
 
 describe('App.mainAdminStackVersionsView', function () {
-  var view = App.MainAdminStackVersionsView.create({
-    controller: {
-      currentVersion: {
-        repository_version: "2.2.1.0",
-        runningCheckRequests: []
-      },
-      load: Em.K
-    }
+  var view;
+
+  beforeEach(function () {
+    view = App.MainAdminStackVersionsView.create({
+      controller: {
+        currentVersion: {
+          repository_version: "2.2.1.0",
+          runningCheckRequests: []
+        },
+        load: Em.K
+      }
+    });
+  });
+
+  afterEach(function () {
+    clearTimeout(view.get('updateTimer'));
+    view.destroy();
   });
 
   describe("#filterBy()", function () {
@@ -226,10 +236,10 @@ describe('App.mainAdminStackVersionsView', function () {
   });
 
   describe("#didInsertElement()", function() {
-    before(function () {
+    beforeEach(function () {
       sinon.stub(view, 'observesCategories', Em.K);
     });
-    after(function () {
+    afterEach(function () {
       view.observesCategories.restore();
     });
     it("observesCategories is called once", function() {
@@ -300,11 +310,11 @@ describe('App.mainAdminStackVersionsView', function () {
   });
 
   describe("#filterVersions()", function() {
-    before(function () {
+    beforeEach(function () {
       sinon.stub(view, 'filterBy').returns([{id: 1}]);
       sinon.stub(view, 'observesCategories', Em.K);
     });
-    after(function () {
+    afterEach(function () {
       view.filterBy.restore();
       view.observesCategories.restore();
     });
@@ -316,49 +326,54 @@ describe('App.mainAdminStackVersionsView', function () {
   });
 
   describe("#goToVersions()", function() {
+    var data = {
+      components: [{
+        'RootServiceComponents': {
+          'component_version': '1.9.0'
+        }
+      }, {
+        'RootServiceComponents': {
+          'component_version': '2.1.0'
+        }
+      }, {
+        'RootServiceComponents': {
+          'component_version': '2.0.0'
+        }
+      }]
+    };
     before(function () {
       sinon.spy(App, 'showConfirmationPopup');
       sinon.stub(window.location, 'replace', Em.K);
-      var data = {
-        components: [{
-          'RootServiceComponents': {
-            'component_version': '1.9.0'
-          }
-        }, {
-          'RootServiceComponents': {
-            'component_version': '2.1.0'
-          }
-        }, {
-          'RootServiceComponents': {
-            'component_version': '2.0.0'
-          }
-        }]
-      };
-      sinon.stub(App.ajax, 'send').returns({
-        then: function(callback) {
-          callback(data);
-        }
-      });
     });
     after(function () {
       App.showConfirmationPopup.restore();
       window.location.replace.restore();
+    });
+
+    beforeEach(function () {
       App.ajax.send.restore();
+      sinon.stub(App.ajax, 'send').returns({
+        then: function(callback) {
+          callback(data);
+        }
+      });
     });
+
     it("should go to link using the version retrieved by query", function() {
       var popup = view.goToVersions();
       expect(App.showConfirmationPopup.calledOnce).to.be.true;
       popup.onPrimary();
-      expect(App.ajax.send.calledOnce).to.be.true;
+      var args = testHelpers.findAjaxRequest('name', 'ambari.service.load_server_version');
+      expect(args[0]).exists;
       expect(window.location.replace.calledWith('/views/ADMIN_VIEW/2.1.0/INSTANCE/#/stackVersions')).to.be.true;
     });
   });
 
   describe("#willInsertElement()", function() {
-    before(function () {
+    beforeEach(function () {
       sinon.stub(view, 'poll', Em.K);
     });
-    after(function () {
+    afterEach(function () {
       view.poll.restore();
     });
     it("poll is called once", function() {

http://git-wip-us.apache.org/repos/asf/ambari/blob/ddf479ef/ambari-web/test/views/main/dashboard/widget_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/dashboard/widget_test.js b/ambari-web/test/views/main/dashboard/widget_test.js
index e27d0f7..6450d1c 100644
--- a/ambari-web/test/views/main/dashboard/widget_test.js
+++ b/ambari-web/test/views/main/dashboard/widget_test.js
@@ -72,20 +72,13 @@ describe('App.DashboardWidgetView', function () {
         complete: Em.K
       });
     });
+
     afterEach(function () {
       dashboardWidgetView.get('parentView').widgetsMapper.restore();
       dashboardWidgetView.get('parentView').getUserPref.restore();
     });
-    it("testMode is on", function () {
-      App.set('testMode', true);
-      dashboardWidgetView.set('id', '1');
-      dashboardWidgetView.deleteWidget();
-      expect(dashboardWidgetView.get('parentView').widgetsMapper.calledWith('1')).to.be.true;
-      expect(dashboardWidgetView.get('parentView.visibleWidgets')).to.be.empty;
-      expect(dashboardWidgetView.get('parentView.hiddenWidgets')).to.not.be.empty;
-    });
+
     it("testMode is off", function () {
-      App.set('testMode', false);
       dashboardWidgetView.set('parentView.persistKey', 'key');
       dashboardWidgetView.deleteWidget();
       expect(dashboardWidgetView.get('parentView').getUserPref.calledWith('key')).to.be.true;

http://git-wip-us.apache.org/repos/asf/ambari/blob/ddf479ef/ambari-web/test/views/main/dashboard/widgets/namenode_cpu_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/dashboard/widgets/namenode_cpu_test.js b/ambari-web/test/views/main/dashboard/widgets/namenode_cpu_test.js
index 347d5d0..cb5da49 100644
--- a/ambari-web/test/views/main/dashboard/widgets/namenode_cpu_test.js
+++ b/ambari-web/test/views/main/dashboard/widgets/namenode_cpu_test.js
@@ -26,19 +26,28 @@ require('views/main/dashboard/widgets/namenode_cpu');
 
 describe('App.NameNodeCpuPieChartView', function() {
 
-  var model = Em.Object.create({
-    used: null,
-    max: null
-  });
-  var nameNodeCpuPieChartView = App.NameNodeCpuPieChartView.create({
-    model_type: null,
-    model: model,
-    modelFieldUsed: 'used',
-    modelFieldMax: 'max',
-    widgetHtmlId: 'fake'
+  var model;
+  var nameNodeCpuPieChartView;
+
+  beforeEach(function () {
+    model = Em.Object.create({
+      used: null,
+      max: null
+    });
+    nameNodeCpuPieChartView = App.NameNodeCpuPieChartView.create({
+      model_type: null,
+      model: model,
+      modelFieldUsed: 'used',
+      modelFieldMax: 'max',
+      widgetHtmlId: 'fake'
+    });
+    nameNodeCpuPieChartView.calc();
   });
 
-  nameNodeCpuPieChartView.calc();
+  afterEach(function () {
+    nameNodeCpuPieChartView.destroy();
+    clearTimeout(nameNodeCpuPieChartView.get('intervalId'));
+  });
 
   describe('#calcIsPieExists', function() {
     var tests = [

http://git-wip-us.apache.org/repos/asf/ambari/blob/ddf479ef/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 eb27237..ca0837a 100644
--- a/ambari-web/test/views/main/dashboard/widgets_test.js
+++ b/ambari-web/test/views/main/dashboard/widgets_test.js
@@ -232,20 +232,13 @@ describe('App.MainDashboardWidgetsView', function () {
         });
         sinon.stub(view, 'widgetsMapper').returns(widget);
       });
+
       afterEach(function () {
         view.getUserPref.restore();
         view.widgetsMapper.restore();
       });
-      it("testMode is on", function () {
-        App.set('testMode', true);
-        plusButtonFilterView.set('hiddenWidgets', [widget]);
-        plusButtonFilterView.applyFilter();
-        expect(view.getUserPref.called).to.be.false;
-        expect(plusButtonFilterView.get('visibleWidgets')).not.to.be.empty;
-        expect(plusButtonFilterView.get('hiddenWidgets')).to.be.empty;
-      });
+
       it("testMode is off", function () {
-        App.set('testMode', false);
         plusButtonFilterView.applyFilter();
         expect(view.getUserPref.calledOnce).to.be.true;
       });
@@ -350,18 +343,13 @@ describe('App.MainDashboardWidgetsView', function () {
       sinon.stub(view, 'translateToReal', Em.K);
       sinon.stub(view, 'getUserPref').returns({complete: Em.K});
     });
+
     afterEach(function () {
       view.translateToReal.restore();
       view.getUserPref.restore();
     });
 
-    it("testMode is true", function () {
-      App.set('testMode', true);
-      view.setOnLoadVisibleWidgets();
-      expect(view.translateToReal.calledOnce).to.be.true;
-    });
     it("testMode is false", function () {
-      App.set('testMode', false);
       view.setOnLoadVisibleWidgets();
       expect(view.getUserPref.calledOnce).to.be.true;
     });

http://git-wip-us.apache.org/repos/asf/ambari/blob/ddf479ef/ambari-web/test/views/main/host/details/host_component_views/datanode_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/host/details/host_component_views/datanode_view_test.js b/ambari-web/test/views/main/host/details/host_component_views/datanode_view_test.js
index a217495..e7b7eef 100644
--- a/ambari-web/test/views/main/host/details/host_component_views/datanode_view_test.js
+++ b/ambari-web/test/views/main/host/details/host_component_views/datanode_view_test.js
@@ -18,6 +18,7 @@
 
 var App = require('app');
 require('views/main/host/details/host_component_views/datanode_view');
+var testHelpers = require('test/helpers');
 
 describe('App.DataNodeComponentView', function () {
   var view = App.DataNodeComponentView.create({
@@ -30,11 +31,9 @@ describe('App.DataNodeComponentView', function () {
 
     beforeEach(function () {
       this.stub = sinon.stub(App.HDFSService, 'find');
-      sinon.stub(App.ajax, 'send');
     });
 
     afterEach(function () {
-      App.ajax.send.restore();
       this.stub.restore();
     });
 
@@ -47,7 +46,9 @@ describe('App.DataNodeComponentView', function () {
         })
       ]);
       view.getDNDecommissionStatus();
-      expect(App.ajax.send.getCall(0).args[0].data).to.eql({
+      var args = testHelpers.findAjaxRequest('name', 'host.host_component.decommission_status_datanode');
+      expect(args[0]).exists;
+      expect(args[0].data).to.be.eql({
         "hostName": "host1",
         "componentName": "NAMENODE"
       });
@@ -62,7 +63,9 @@ describe('App.DataNodeComponentView', function () {
         })
       ]);
       view.getDNDecommissionStatus();
-      expect(App.ajax.send.getCall(0).args[0].data).to.eql({
+      var args = testHelpers.findAjaxRequest('name', 'host.host_component.decommission_status_datanode');
+      expect(args[0]).exists;
+      expect(args[0].data).to.be.eql({
         "hostName": "host1",
         "componentName": "NAMENODE"
       });
@@ -77,7 +80,9 @@ describe('App.DataNodeComponentView', function () {
         })
       ]);
       view.getDNDecommissionStatus();
-      expect(App.ajax.send.getCall(0).args[0].data).to.eql({
+      var args = testHelpers.findAjaxRequest('name', 'host.host_component.decommission_status_datanode');
+      expect(args[0]).exists;
+      expect(args[0].data).to.be.eql({
         "hostName": "host2",
         "componentName": "NAMENODE"
       });

http://git-wip-us.apache.org/repos/asf/ambari/blob/ddf479ef/ambari-web/test/views/main/host/details/host_component_views/decommissionable_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/host/details/host_component_views/decommissionable_test.js b/ambari-web/test/views/main/host/details/host_component_views/decommissionable_test.js
index b5cbbe5..caeaab0 100644
--- a/ambari-web/test/views/main/host/details/host_component_views/decommissionable_test.js
+++ b/ambari-web/test/views/main/host/details/host_component_views/decommissionable_test.js
@@ -21,6 +21,7 @@ require('models/host_component');
 require('views/main/host/details/host_component_view');
 require('mixins');
 require('mixins/main/host/details/host_components/decommissionable');
+var testHelpers = require('test/helpers');
 
 var hostComponentView;
 
@@ -223,18 +224,14 @@ describe('App.Decommissionable', function() {
   });
 
   describe("#getDesiredAdminState()", function() {
-    beforeEach(function () {
-      sinon.stub(App.ajax, 'send', Em.K);
-    });
-    afterEach(function () {
-      App.ajax.send.restore();
-    });
+
     it("content is null", function() {
       hostComponentView = Em.View.create(App.Decommissionable, {
         content: null
       });
       hostComponentView.getDesiredAdminState();
-      expect(App.ajax.send.called).to.be.false;
+      var args = testHelpers.findAjaxRequest('name', 'host.host_component.slave_desired_admin_state');
+      expect(args).not.exists;
     });
     it("content is correct", function() {
       hostComponentView = Em.View.create(App.Decommissionable, {
@@ -244,16 +241,13 @@ describe('App.Decommissionable', function() {
         })
       });
       hostComponentView.getDesiredAdminState();
-      expect(App.ajax.send.calledWith({
-        name: 'host.host_component.slave_desired_admin_state',
-        sender: hostComponentView,
-        data: {
-          hostName: 'host1',
-          componentName: 'C1'
-        },
-        success: 'getDesiredAdminStateSuccessCallback',
-        error: 'getDesiredAdminStateErrorCallback'
-      })).to.be.true;
+      var args = testHelpers.findAjaxRequest('name', 'host.host_component.slave_desired_admin_state');
+      expect(args[0]).exists;
+      expect(args[0].sender).to.be.eql(hostComponentView);
+      expect(args[0].data).to.be.eql({
+        hostName: 'host1',
+        componentName: 'C1'
+      });
     });
   });
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/ddf479ef/ambari-web/test/views/main/service/services/ranger_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/service/services/ranger_test.js b/ambari-web/test/views/main/service/services/ranger_test.js
index c348b03..a7c683f 100644
--- a/ambari-web/test/views/main/service/services/ranger_test.js
+++ b/ambari-web/test/views/main/service/services/ranger_test.js
@@ -31,16 +31,6 @@ describe('App.MainDashboardServiceRangerView', function () {
 
   describe('#didInsertElement', function () {
 
-    beforeEach(function () {
-      sinon.stub(App.updater, 'run', Em.K);
-      sinon.stub(App.updater, 'immediateRun', Em.K);
-    });
-
-    afterEach(function () {
-      App.updater.run.restore();
-      App.updater.immediateRun.restore();
-    });
-
     it('should run updater', function () {
       view.didInsertElement();
       expect(App.updater.run.calledOnce).to.be.true;


Mime
View raw message