ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From atk...@apache.org
Subject [1/2] ambari git commit: AMBARI-9470 Cover Stack Versions page with unit tests. (atkach)
Date Thu, 05 Feb 2015 09:26:44 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 0dd8d0932 -> 300890e87


AMBARI-9470 Cover Stack Versions page with unit tests. (atkach)


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

Branch: refs/heads/trunk
Commit: 9876a036cef5ff2e7e4144281d4ba27817c3dff4
Parents: 0dd8d09
Author: Andrii Tkach <atkach@hortonworks.com>
Authored: Wed Feb 4 17:34:28 2015 +0200
Committer: Andrii Tkach <atkach@hortonworks.com>
Committed: Thu Feb 5 11:26:08 2015 +0200

----------------------------------------------------------------------
 ambari-web/app/assets/test/tests.js             |   1 +
 .../main/admin/stack_and_upgrade_controller.js  |   4 +-
 ambari-web/app/messages.js                      |   2 +-
 .../main/admin/stack_upgrade/services_view.js   |   2 +-
 .../admin/stack_upgrade/upgrade_task_view.js    |   2 +-
 .../stack_upgrade/upgrade_version_box_view.js   |   8 +-
 .../admin/stack_upgrade/upgrade_wizard_view.js  |   4 +-
 .../main/admin/stack_upgrade/versions_view.js   |  31 ++-
 .../admin/stack_and_upgrade_controller_test.js  | 216 ++++++++++++++-
 .../admin/stack_upgrade/services_view_test.js   |  73 +++++
 .../stack_upgrade/upgrade_task_view_test.js     |  68 ++++-
 .../upgrade_version_box_view_test.js            | 160 +++++++++++
 .../stack_upgrade/upgrade_wizard_view_test.js   | 271 ++++++++++++++++++-
 .../admin/stack_upgrade/version_view_test.js    | 163 ++++++++++-
 14 files changed, 963 insertions(+), 42 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/9876a036/ambari-web/app/assets/test/tests.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/assets/test/tests.js b/ambari-web/app/assets/test/tests.js
index d2cf0e7..963528b 100644
--- a/ambari-web/app/assets/test/tests.js
+++ b/ambari-web/app/assets/test/tests.js
@@ -172,6 +172,7 @@ var files = ['test/init_model_test',
   'test/views/main/admin/stack_upgrade/upgrade_task_view_test',
   'test/views/main/admin/stack_upgrade/upgrade_wizard_view_test',
   'test/views/main/admin/stack_upgrade/version_view_test',
+  'test/views/main/admin/stack_upgrade/services_view_test',
   'test/views/main/dashboard/config_history_view_test',
   'test/views/main/dashboard/widget_test',
   'test/views/main/dashboard/widgets_test',

http://git-wip-us.apache.org/repos/asf/ambari/blob/9876a036/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js b/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js
index 55ac9c3..f3230b1 100644
--- a/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js
+++ b/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js
@@ -94,7 +94,7 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage,
    * @type {String}
    */
   realStackUrl: function () {
-    return App.apiPrefix + '/clusters/' + App.get('clusterName') +
+    return App.get('apiPrefix') + '/clusters/' + App.get('clusterName') +
       '/stack_versions?fields=*,repository_versions/*,repository_versions/operating_systems/repositories/*';
   }.property('App.clusterName'),
 
@@ -103,7 +103,7 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage,
    * @type {String}
    */
   realUpdateUrl: function () {
-    return App.apiPrefix + '/clusters/' + App.get('clusterName') + '/stack_versions?fields=ClusterStackVersions/*';
+    return App.get('apiPrefix') + '/clusters/' + App.get('clusterName') + '/stack_versions?fields=ClusterStackVersions/*';
   }.property('App.clusterName'),
 
   init: function () {

http://git-wip-us.apache.org/repos/asf/ambari/blob/9876a036/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index 9fba91c..e8fb097 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -1279,7 +1279,7 @@ Em.I18n.translations = {
   'admin.stackVersions.filter.upgradeReady': "Upgrade Ready ({0})",
   'admin.stackVersions.filter.installed': "Installed ({0})",
   'admin.stackVersions.filter.current': "Current ({0})",
-  'admin.stackVersions.filter.upgrading': "Upgrade In Process ({0})",
+  'admin.stackVersions.filter.upgrading': "Upgrade/Downgrade In Process ({0})",
   'admin.stackVersions.filter.upgraded': "Ready to Finalize ({0})",
 
   'admin.stackVersions.editRepositories.info': 'Provide Base URLs for the Operating Systems you are configuring. Uncheck all other Operating Systems.',

http://git-wip-us.apache.org/repos/asf/ambari/blob/9876a036/ambari-web/app/views/main/admin/stack_upgrade/services_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/admin/stack_upgrade/services_view.js b/ambari-web/app/views/main/admin/stack_upgrade/services_view.js
index c2fd7fb..3d8e6dc 100644
--- a/ambari-web/app/views/main/admin/stack_upgrade/services_view.js
+++ b/ambari-web/app/views/main/admin/stack_upgrade/services_view.js
@@ -39,7 +39,7 @@ App.MainAdminStackServicesView = Em.View.extend({
    */
   goToAddService: function (event) {
     if (event.context == "KERBEROS") {
-      App.get('router.mainAdminKerberosController').checkAndStartKerberosWizard();
+      App.router.get('mainAdminKerberosController').checkAndStartKerberosWizard();
     } else {
       App.router.get('addServiceController').set('serviceToInstall', event.context);
       App.get('router').transitionTo('main.serviceAdd');

http://git-wip-us.apache.org/repos/asf/ambari/blob/9876a036/ambari-web/app/views/main/admin/stack_upgrade/upgrade_task_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/admin/stack_upgrade/upgrade_task_view.js b/ambari-web/app/views/main/admin/stack_upgrade/upgrade_task_view.js
index 467e72c..ee67f79 100644
--- a/ambari-web/app/views/main/admin/stack_upgrade/upgrade_task_view.js
+++ b/ambari-web/app/views/main/admin/stack_upgrade/upgrade_task_view.js
@@ -33,7 +33,7 @@ App.upgradeTaskView = Em.View.extend({
    */
   showContent: function () {
     return this.get('outsideView') || this.get('content.isExpanded');
-  }.property('content.isExpanded'),
+  }.property('content.isExpanded', 'outsideView'),
 
   /**
    * @type {boolean}

http://git-wip-us.apache.org/repos/asf/ambari/blob/9876a036/ambari-web/app/views/main/admin/stack_upgrade/upgrade_version_box_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/admin/stack_upgrade/upgrade_version_box_view.js b/ambari-web/app/views/main/admin/stack_upgrade/upgrade_version_box_view.js
index 9227965..2f6c753 100644
--- a/ambari-web/app/views/main/admin/stack_upgrade/upgrade_version_box_view.js
+++ b/ambari-web/app/views/main/admin/stack_upgrade/upgrade_version_box_view.js
@@ -53,15 +53,14 @@ App.UpgradeVersionBoxView = Em.View.extend({
    * @type {string}
    */
   versionClass: function () {
-    return this.get('content.status') == 'CURRENT'
-      ? 'current-version-box' : '';
+    return this.get('content.status') === 'CURRENT' ? 'current-version-box' : '';
   }.property('content.status'),
 
   /**
    * @type {boolean}
    */
   isOutOfSync: function () {
-    return this.get('content.status') == 'OUT_OF_SYNC';
+    return this.get('content.status') === 'OUT_OF_SYNC';
   }.property('content.status'),
 
   /**
@@ -276,8 +275,7 @@ App.UpgradeVersionBoxView = Em.View.extend({
    * @method filterHostsByStack
    */
   filterHostsByStack: function (version, state) {
-    if (!version || !state)
-      return;
+    if (!version || !state) return;
     App.router.get('mainHostController').filterByStack(version, state);
     App.router.get('mainHostController').set('showFilterConditionsFirstLoad', true);
     App.router.transitionTo('hosts.index');

http://git-wip-us.apache.org/repos/asf/ambari/blob/9876a036/ambari-web/app/views/main/admin/stack_upgrade/upgrade_wizard_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/admin/stack_upgrade/upgrade_wizard_view.js b/ambari-web/app/views/main/admin/stack_upgrade/upgrade_wizard_view.js
index ea3c203..64187fa 100644
--- a/ambari-web/app/views/main/admin/stack_upgrade/upgrade_wizard_view.js
+++ b/ambari-web/app/views/main/admin/stack_upgrade/upgrade_wizard_view.js
@@ -120,7 +120,7 @@ App.upgradeWizardView = Em.View.extend({
 
   /**
    * details of currently active task
-   * @type {object|undefined}
+   * @type {object|null}
    */
   taskDetails: function () {
     if (this.get('runningItem')) {
@@ -129,6 +129,8 @@ App.upgradeWizardView = Em.View.extend({
       return this.get('failedItem').get('tasks').find(function (task) {
         return this.get('failedStatuses').contains(task.get('status'));
       }, this);
+    } else {
+      return null;
     }
   }.property('failedItem.tasks.@each.status', 'runningItem.tasks.@each.status'),
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/9876a036/ambari-web/app/views/main/admin/stack_upgrade/versions_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/admin/stack_upgrade/versions_view.js b/ambari-web/app/views/main/admin/stack_upgrade/versions_view.js
index c385e34..c287254 100644
--- a/ambari-web/app/views/main/admin/stack_upgrade/versions_view.js
+++ b/ambari-web/app/views/main/admin/stack_upgrade/versions_view.js
@@ -158,9 +158,10 @@ App.MainAdminStackVersionsView = Em.View.extend({
 
   /**
    * route to versions in Admin View
+   * @return {App.ModalPopup}
    */
   goToVersions: function () {
-    App.showConfirmationPopup(function () {
+    return App.showConfirmationPopup(function () {
       window.location.replace('/views/ADMIN_VIEW/1.0.0/INSTANCE/#/stackVersions');
     },
     Em.I18n.t('admin.stackVersions.manageVersions.popup.body'),
@@ -179,23 +180,31 @@ App.MainAdminStackVersionsView = Em.View.extend({
    * stop polling upgrade state
    */
   willDestroyElement: function () {
-    clearTimeout(this.get('updateTimer'));
+    window.clearTimeout(this.get('updateTimer'));
   },
 
   /**
-   * poll Upgrade state
+   * set timer for polling
    */
   doPolling: function () {
     var self = this;
-    this.set('updateTimer', setTimeout(function () {
-      //skip call if Upgrade wizard opened
-      if (App.router.get('updateController').get('isWorking')) {
-        self.get('controller').load().done(function () {
-          self.set('controller.isLoaded', true);
-          self.doPolling();
-        });
-      }
+    this.set('updateTimer', window.setTimeout(function () {
+      self.poll();
     }, App.bgOperationsUpdateInterval));
+  },
+
+  /**
+   * poll data
+   */
+  poll: function () {
+    var self = this;
+    //skip call if Upgrade wizard opened
+    if (App.router.get('updateController').get('isWorking')) {
+      this.get('controller').load().done(function () {
+        self.set('controller.isLoaded', true);
+        self.doPolling();
+      });
+    }
   }
 
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/9876a036/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js b/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js
index f47219c..c95c7d0 100644
--- a/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js
+++ b/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js
@@ -27,6 +27,88 @@ describe('App.MainAdminStackAndUpgradeController', function() {
     setDBProperty: Em.K
   });
 
+  describe("#realRepoUrl", function() {
+    before(function () {
+      this.mock = sinon.stub(App, 'get');
+    });
+    after(function () {
+      this.mock.restore();
+    });
+    it("", function() {
+      this.mock.withArgs('apiPrefix').returns('apiPrefix');
+      this.mock.withArgs('stackVersionURL').returns('stackVersionURL');
+      controller.propertyDidChange('realRepoUrl');
+      expect(controller.get('realRepoUrl')).to.equal('apiPrefixstackVersionURL/repository_versions?fields=*,operating_systems/*,operating_systems/repositories/*');
+    });
+  });
+
+  describe("#realStackUrl", function() {
+    before(function () {
+      this.mock = sinon.stub(App, 'get');
+    });
+    after(function () {
+      this.mock.restore();
+    });
+    it("", function() {
+      this.mock.withArgs('apiPrefix').returns('apiPrefix');
+      this.mock.withArgs('clusterName').returns('clusterName');
+      controller.propertyDidChange('realStackUrl');
+      expect(controller.get('realStackUrl')).to.equal('apiPrefix/clusters/clusterName/stack_versions?fields=*,repository_versions/*,repository_versions/operating_systems/repositories/*');
+    });
+  });
+
+  describe("#realUpdateUrl", function() {
+    before(function () {
+      this.mock = sinon.stub(App, 'get');
+    });
+    after(function () {
+      this.mock.restore();
+    });
+    it("", function() {
+      this.mock.withArgs('apiPrefix').returns('apiPrefix');
+      this.mock.withArgs('clusterName').returns('clusterName');
+      controller.propertyDidChange('realUpdateUrl');
+      expect(controller.get('realUpdateUrl')).to.equal('apiPrefix/clusters/clusterName/stack_versions?fields=ClusterStackVersions/*');
+    });
+  });
+
+  describe("#load()", function() {
+    before(function(){
+      sinon.stub(controller, 'loadUpgradeData').returns({
+        done: function(callback) {callback();}
+      });
+      sinon.stub(controller, 'loadStackVersionsToModel').returns({
+        done: function(callback) {callback();}
+      });
+      sinon.stub(controller, 'loadRepoVersionsToModel').returns({
+        done: function(callback) {callback();}
+      });
+      sinon.stub(App.StackVersion, 'find').returns([Em.Object.create({
+        state: 'CURRENT',
+        repositoryVersion: {
+          repositoryVersion: '2.2',
+          displayName: 'HDP-2.2'
+        }
+      })]);
+    });
+    after(function(){
+      controller.loadUpgradeData.restore();
+      controller.loadStackVersionsToModel.restore();
+      controller.loadRepoVersionsToModel.restore();
+      App.StackVersion.find.restore();
+    });
+    it("", function() {
+      controller.load();
+      expect(controller.loadUpgradeData.calledWith(true)).to.be.true;
+      expect(controller.loadStackVersionsToModel.calledWith(true)).to.be.true;
+      expect(controller.loadRepoVersionsToModel.calledOnce).to.be.true;
+      expect(controller.get('currentVersion')).to.eql({
+        "repository_version": "2.2",
+        "repository_name": "HDP-2.2"
+      });
+    });
+  });
+
   describe("#loadUpgradeData()", function() {
     beforeEach(function () {
       sinon.stub(App.ajax, 'send').returns({
@@ -405,6 +487,11 @@ describe('App.MainAdminStackAndUpgradeController', function() {
       App.clusterStatus.setClusterStatus.restore();
       controller.setDBProperty.restore();
     });
+    it("upgradeState is not COMPLETED", function() {
+      App.set('upgradeState', 'UPGRADING');
+      controller.finish();
+      expect(App.clusterStatus.setClusterStatus.called).to.be.false;
+    });
     it("upgradeState is COMPLETED", function() {
       App.set('upgradeState', 'COMPLETED');
       controller.finish();
@@ -413,12 +500,7 @@ describe('App.MainAdminStackAndUpgradeController', function() {
       expect(controller.setDBProperty.calledWith('upgradeState', 'INIT')).to.be.true;
       expect(controller.setDBProperty.calledWith('currentVersion', undefined)).to.be.true;
       expect(App.get('upgradeState')).to.equal('INIT');
-      expect(App.clusterStatus.setClusterStatus.calledOnce).to.be.false;
-    });
-    it("upgradeState is not COMPLETED", function() {
-      App.set('upgradeState', 'UPGRADING');
-      controller.finish();
-      expect(App.clusterStatus.setClusterStatus.called).to.be.false;
+      expect(App.clusterStatus.setClusterStatus.calledOnce).to.be.true;
     });
   });
 
@@ -606,4 +688,126 @@ describe('App.MainAdminStackAndUpgradeController', function() {
       expect(controller.prepareRepoForSaving(repo)).to.eql(result);
     });
   });
+
+  describe("#saveRepoOS()", function() {
+    before(function(){
+      this.mock = sinon.stub(controller, 'validateRepoVersions');
+      sinon.stub(controller, 'prepareRepoForSaving', Em.K);
+      sinon.stub(App.ajax, 'send').returns({success: Em.K});
+    });
+    after(function(){
+      this.mock.restore();
+      controller.prepareRepoForSaving.restore();
+      App.ajax.send.restore();
+    });
+    it("validation errors present", function() {
+      this.mock.returns({
+        done: function(callback) {callback([1]);}
+      });
+      controller.saveRepoOS(Em.Object.create({repoVersionId: 1}), true);
+      expect(controller.validateRepoVersions.calledWith(Em.Object.create({repoVersionId: 1}), true)).to.be.true;
+      expect(controller.prepareRepoForSaving.called).to.be.false;
+      expect(App.ajax.send.called).to.be.false;
+    });
+    it("no validation errors", function() {
+      this.mock.returns({
+        done: function(callback) {callback([]);}
+      });
+      controller.saveRepoOS(Em.Object.create({repoVersionId: 1}), true);
+      expect(controller.validateRepoVersions.calledWith(Em.Object.create({repoVersionId: 1}), true)).to.be.true;
+      expect(controller.prepareRepoForSaving.calledWith(Em.Object.create({repoVersionId: 1}))).to.be.true;
+      expect(App.ajax.send.calledOnce).to.be.true;
+    });
+  });
+
+  describe("#validateRepoVersions()", function () {
+    before(function () {
+      sinon.stub(App.ajax, 'send').returns({success: Em.K, error: Em.K});
+    });
+    after(function () {
+      App.ajax.send.restore();
+    });
+    it("skip validation", function () {
+      controller.validateRepoVersions(Em.Object.create({repoVersionId: 1}), true);
+      expect(App.ajax.send.called).to.be.false;
+    });
+    it("do validation", function () {
+      var repo = Em.Object.create({
+        repoVersionId: 1,
+        operatingSystems: [
+          Em.Object.create({
+            isSelected: true,
+            repositories: [
+              Em.Object.create()
+            ]
+          })
+        ]
+      });
+      controller.validateRepoVersions(repo, false);
+      expect(App.ajax.send.calledOnce).to.be.true;
+    });
+  });
+
+  describe("#showProgressPopup()", function () {
+    var mock = {
+      initPopup: Em.K
+    };
+    before(function () {
+      sinon.stub(App.router, 'get').withArgs('highAvailabilityProgressPopupController').returns(mock);
+      sinon.spy(mock, 'initPopup');
+    });
+    after(function () {
+      App.router.get.restore();
+      mock.initPopup.restore();
+    });
+    it("", function () {
+      controller.showProgressPopup(Em.Object.create());
+      expect(mock.initPopup.calledOnce).to.be.true;
+    });
+  });
+
+  describe("#getUrl()", function() {
+    beforeEach(function(){
+      controller.reopen({
+        realStackUrl: 'realStackUrl',
+        realRepoUrl: 'realRepoUrl',
+        realUpdateUrl: 'realUpdateUrl'
+      });
+    });
+    it("full load is true, stack is null", function() {
+      expect(controller.getUrl(null, true)).to.equal('realRepoUrl');
+    });
+    it("full load is true, stack is valid", function() {
+      expect(controller.getUrl({}, true)).to.equal('realStackUrl');
+    });
+    it("full load is false, stack is valid", function() {
+      expect(controller.getUrl({}, false)).to.equal('realUpdateUrl');
+    });
+  });
+
+  describe("#loadStackVersionsToModel()", function () {
+    before(function () {
+      sinon.stub(App.HttpClient, 'get');
+    });
+    after(function () {
+      App.HttpClient.get.restore();
+    });
+    it("", function () {
+      controller.loadStackVersionsToModel();
+      expect(App.HttpClient.get.calledOnce).to.be.true;
+    });
+  });
+
+  describe("#loadRepoVersionsToModel()", function () {
+    before(function () {
+      sinon.stub(App.HttpClient, 'get');
+    });
+    after(function () {
+      App.HttpClient.get.restore();
+    });
+    it("", function () {
+      controller.loadRepoVersionsToModel();
+      expect(App.HttpClient.get.calledOnce).to.be.true;
+    });
+  });
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/9876a036/ambari-web/test/views/main/admin/stack_upgrade/services_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/admin/stack_upgrade/services_view_test.js b/ambari-web/test/views/main/admin/stack_upgrade/services_view_test.js
new file mode 100644
index 0000000..153d5c7
--- /dev/null
+++ b/ambari-web/test/views/main/admin/stack_upgrade/services_view_test.js
@@ -0,0 +1,73 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+var App = require('app');
+require('views/main/admin/stack_upgrade/services_view');
+
+describe('App.MainAdminStackServicesView', function () {
+  var view = App.MainAdminStackServicesView.create();
+
+  describe("#services", function () {
+    before(function () {
+      sinon.stub(App.StackService, 'find').returns([
+        Em.Object.create({serviceName: 'S1', isInstalled: false}),
+        Em.Object.create({serviceName: 'S2', isInstalled: false})
+      ]);
+      sinon.stub(App.Service, 'find').returns([
+        Em.Object.create({serviceName: 'S1'})
+      ]);
+    });
+    after(function () {
+      App.StackService.find.restore();
+      App.Service.find.restore();
+    });
+    it("", function () {
+      view.propertyDidChange('services');
+      expect(view.get('services')).to.eql([
+        Em.Object.create({serviceName: 'S1', isInstalled: true}),
+        Em.Object.create({serviceName: 'S2', isInstalled: false})
+      ])
+    });
+  });
+
+  describe("#goToAddService()" , function() {
+    var mock = Em.Object.create({
+      checkAndStartKerberosWizard: Em.K
+    });
+    beforeEach(function() {
+      sinon.stub(App.get('router'), 'transitionTo', Em.K);
+      sinon.stub(App.router, 'get').returns(mock);
+      sinon.spy(mock, 'checkAndStartKerberosWizard');
+    });
+    afterEach(function() {
+      App.get('router').transitionTo.restore();
+      App.router.get.restore();
+      mock.checkAndStartKerberosWizard.restore();
+    });
+    it("routes to Add Service Wizard", function() {
+      view.goToAddService({context: "serviceName"});
+      expect(App.get('router').transitionTo.calledWith('main.serviceAdd')).to.be.true;
+      expect(mock.get('serviceToInstall')).to.be.equal("serviceName");
+    });
+    it("routes to Security Wizard", function() {
+      view.goToAddService({context: "KERBEROS"});
+      expect(mock.checkAndStartKerberosWizard.calledOnce).to.be.true;
+    });
+  });
+});

http://git-wip-us.apache.org/repos/asf/ambari/blob/9876a036/ambari-web/test/views/main/admin/stack_upgrade/upgrade_task_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/admin/stack_upgrade/upgrade_task_view_test.js b/ambari-web/test/views/main/admin/stack_upgrade/upgrade_task_view_test.js
index ca1d8ba..30035bf 100644
--- a/ambari-web/test/views/main/admin/stack_upgrade/upgrade_task_view_test.js
+++ b/ambari-web/test/views/main/admin/stack_upgrade/upgrade_task_view_test.js
@@ -26,6 +26,7 @@ describe('App.upgradeTaskView', function () {
     taskDetailsProperties: ['prop1']
   });
   view.removeObserver('content.isExpanded', view, 'doPolling');
+  view.removeObserver('outsideView', view, 'doPolling');
 
   describe("#logTabId", function() {
     it("", function() {
@@ -74,18 +75,47 @@ describe('App.upgradeTaskView', function () {
       view.doPolling.restore();
       this.clock.restore();
     });
-    it("isExpanded false", function () {
+    it("isExpanded = false, outsideView = false", function () {
       view.set('content.isExpanded', false);
+      view.set('outsideView', false);
       view.doPolling();
       expect(view.getTaskDetails.called).to.be.false;
     });
-    it("isExpanded true", function () {
+    it("isExpanded = true", function () {
       view.set('content.isExpanded', true);
+      view.set('outsideView', false);
       view.doPolling();
       expect(view.getTaskDetails.calledOnce).to.be.true;
       this.clock.tick(App.bgOperationsUpdateInterval);
       expect(view.doPolling.calledTwice).to.be.true;
     });
+    it("outsideView = true", function () {
+      view.set('outsideView', true);
+      view.set('content.isExpanded', false);
+      view.doPolling();
+      expect(view.getTaskDetails.calledOnce).to.be.true;
+      this.clock.tick(App.bgOperationsUpdateInterval);
+      expect(view.doPolling.calledTwice).to.be.true;
+    });
+  });
+
+  describe("#didInsertElement()", function() {
+    beforeEach(function () {
+      sinon.stub(view, 'doPolling', Em.K);
+    });
+    afterEach(function () {
+      view.doPolling.restore();
+    });
+    it("outsideView = true", function() {
+      view.set('outsideView', true);
+      view.didInsertElement();
+      expect(view.doPolling.calledOnce).to.be.true;
+    });
+    it("outsideView = false", function() {
+      view.set('outsideView', false);
+      view.didInsertElement();
+      expect(view.doPolling.called).to.be.false;
+    });
   });
 
   describe("#getTaskDetails()", function () {
@@ -95,6 +125,7 @@ describe('App.upgradeTaskView', function () {
     });
     afterEach(function () {
       App.ajax.send.restore();
+      view.set('content', Em.Object.create());
     });
     it("call App.ajax.send()", function () {
       view.set('content.id', 1);
@@ -110,6 +141,11 @@ describe('App.upgradeTaskView', function () {
         success: 'getTaskDetailsSuccessCallback'
       });
     });
+    it("call App.ajax.send()", function () {
+      view.set('content', null);
+      view.getTaskDetails();
+      expect(App.ajax.send.called).to.be.false;
+    });
   });
 
   describe("#getTaskDetailsSuccessCallback()", function () {
@@ -214,4 +250,32 @@ describe('App.upgradeTaskView', function () {
       expect(mockWindow.document.close.calledOnce).to.be.true;
     });
   });
+
+  describe("#showContent", function() {
+    it("outsideView = false, content.isExpanded = false", function() {
+      view.set('outsideView', false);
+      view.set('content.isExpanded', false);
+      view.propertyDidChange('showContent');
+      expect(view.get('showContent')).to.be.false;
+    });
+    it("outsideView = true, content.isExpanded = false", function() {
+      view.set('outsideView', true);
+      view.set('content.isExpanded', false);
+      view.propertyDidChange('showContent');
+      expect(view.get('showContent')).to.be.true;
+    });
+    it("outsideView = false, content.isExpanded = true", function() {
+      view.set('outsideView', false);
+      view.set('content.isExpanded', true);
+      view.propertyDidChange('showContent');
+      expect(view.get('showContent')).to.be.true;
+    });
+    it("outsideView = true, content.isExpanded = true", function() {
+      view.set('outsideView', true);
+      view.set('content.isExpanded', true);
+      view.propertyDidChange('showContent');
+      expect(view.get('showContent')).to.be.true;
+    });
+  });
+
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/9876a036/ambari-web/test/views/main/admin/stack_upgrade/upgrade_version_box_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/admin/stack_upgrade/upgrade_version_box_view_test.js b/ambari-web/test/views/main/admin/stack_upgrade/upgrade_version_box_view_test.js
index 69134bb..867c96a 100644
--- a/ambari-web/test/views/main/admin/stack_upgrade/upgrade_version_box_view_test.js
+++ b/ambari-web/test/views/main/admin/stack_upgrade/upgrade_version_box_view_test.js
@@ -61,4 +61,164 @@ describe('App.UpgradeVersionBoxView', function () {
       expect(view.get('isUpgrading')).to.be.false;
     });
   });
+
+  describe("#installProgress", function () {
+    beforeEach(function () {
+      sinon.stub(App.db, 'get').returns(1);
+      this.mock = sinon.stub(App.router, 'get');
+    });
+    afterEach(function () {
+      App.db.get.restore();
+      this.mock.restore();
+    });
+    it("request absent", function () {
+      this.mock.returns([]);
+      view.propertyDidChange('installProgress');
+      expect(view.get('installProgress')).to.equal(0);
+    });
+    it("request present", function () {
+      this.mock.returns([Em.Object.create({progress: 100})]);
+      view.propertyDidChange('installProgress');
+      expect(view.get('installProgress')).to.equal(100);
+    });
+  });
+
+  describe("#versionClass", function () {
+    it("status CURRENT", function () {
+      view.set('content.status', 'CURRENT');
+      view.propertyDidChange('versionClass');
+      expect(view.get('versionClass')).to.equal('current-version-box');
+    });
+    it("status INSTALLED", function () {
+      view.set('content.status', 'INSTALLED');
+      view.propertyDidChange('versionClass');
+      expect(view.get('versionClass')).to.equal('');
+    });
+  });
+
+  describe("#isOutOfSync", function () {
+    it("status OUT_OF_SYNC", function () {
+      view.set('content.status', 'OUT_OF_SYNC');
+      view.propertyDidChange('isOutOfSync');
+      expect(view.get('isOutOfSync')).to.be.true;
+    });
+  });
+
+  describe("#didInsertElement()", function () {
+    beforeEach(function () {
+      sinon.stub(App, 'tooltip').returns(1);
+    });
+    afterEach(function () {
+      App.tooltip.restore();
+    });
+    it("init tooltips", function () {
+      view.didInsertElement();
+      expect(App.tooltip.callCount).to.equal(4);
+    });
+  });
+
+  describe("#runAction()", function () {
+    beforeEach(function () {
+      sinon.stub(view.get('controller'), 'upgrade').returns(1);
+    });
+    afterEach(function () {
+      view.get('controller').upgrade.restore();
+    });
+    it("action = null", function () {
+      view.runAction({context: Em.Object.create({action: null})});
+      expect(view.get('controller').upgrade.called).to.be.false;
+    });
+    it("action = 'upgrade'", function () {
+      view.set('content', 'content');
+      view.runAction({context: Em.Object.create({action: 'upgrade'})});
+      expect(view.get('controller').upgrade.calledWith('content')).to.be.true;
+    });
+  });
+
+  describe("#editRepositories()", function () {
+    beforeEach(function () {
+      sinon.stub(App.RepositoryVersion, 'find').returns(Em.Object.create({
+        operatingSystems: []
+      }));
+      sinon.stub(App.ModalPopup, 'show', Em.K);
+    });
+    afterEach(function () {
+      App.RepositoryVersion.find.restore();
+      App.ModalPopup.show.restore();
+    });
+    it("show popup", function () {
+      view.editRepositories();
+      expect(App.ModalPopup.show.calledOnce).to.be.true;
+    });
+  });
+
+  describe("#showHosts()", function () {
+    beforeEach(function () {
+      sinon.spy(App.ModalPopup, 'show');
+      sinon.stub(view, 'filterHostsByStack', Em.K);
+    });
+    afterEach(function () {
+      App.ModalPopup.show.restore();
+      view.filterHostsByStack.restore();
+    });
+    it("no hosts", function () {
+      view.showHosts({contexts: [
+       'status', 'version', []
+      ]});
+      expect(App.ModalPopup.show.called).to.be.false;
+    });
+    it("one host", function () {
+      var popup = view.showHosts({contexts: [
+        {id: 1}, 'version', ['host1']
+      ]});
+      expect(App.ModalPopup.show.calledOnce).to.be.true;
+      popup.onPrimary();
+      expect(view.filterHostsByStack.calledWith('version', 1)).to.be.true;
+    });
+  });
+
+  describe("#filterHostsByStack()", function () {
+    var mock = {
+      set: Em.K,
+      filterByStack: Em.K
+    };
+    beforeEach(function () {
+      sinon.stub(App.router, 'get').withArgs('mainHostController').returns(mock);
+      sinon.stub(App.router, 'transitionTo', Em.K);
+      sinon.spy(mock, 'set');
+      sinon.spy(mock, 'filterByStack');
+    });
+    afterEach(function () {
+      App.router.get.restore();
+      App.router.transitionTo.restore();
+      mock.set.restore();
+      mock.filterByStack.restore();
+    });
+    it("version and state are valid", function () {
+      view.filterHostsByStack('version', 'state');
+      expect(mock.set.calledWith('showFilterConditionsFirstLoad', true)).to.be.true;
+      expect(mock.filterByStack.calledWith('version', 'state')).to.be.true;
+      expect(App.router.transitionTo.calledWith('hosts.index')).to.be.true;
+    });
+    it("version is null", function () {
+      view.filterHostsByStack(null, 'state');
+      expect(mock.set.called).to.be.false;
+      expect(mock.filterByStack.called).to.be.false;
+      expect(App.router.transitionTo.called).to.be.false;
+    });
+    it("state is null", function () {
+      view.filterHostsByStack('version', null);
+      expect(mock.set.called).to.be.false;
+      expect(mock.filterByStack.called).to.be.false;
+      expect(App.router.transitionTo.called).to.be.false;
+    });
+    it("state and version are null", function () {
+      view.filterHostsByStack(null, null);
+      expect(mock.set.called).to.be.false;
+      expect(mock.filterByStack.called).to.be.false;
+      expect(App.router.transitionTo.called).to.be.false;
+    });
+  });
+
+
 });
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/9876a036/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 f6cdc11..06de5ca 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
@@ -26,15 +26,48 @@ describe('App.upgradeWizardView', function () {
   });
   view.reopen({
     controller: Em.Object.create({
+      upgradeData: Em.Object.create(),
       loadUpgradeData: Em.K,
       setUpgradeItemStatus: Em.K
-    }),
-    activeGroup: Em.Object.create()
+    })
   });
   view.removeObserver('App.clusterName', view, 'startPolling');
 
-  describe("#overallProgress", function() {
-    it("progress is 1.9", function() {
+  describe("#upgradeGroups", function () {
+    it("upgradeGroups is null", function () {
+      view.set('controller.upgradeData.upgradeGroups', null);
+      view.propertyDidChange('upgradeGroups');
+      expect(view.get('upgradeGroups')).to.be.empty;
+    });
+    it("upgradeGroups is valid", function () {
+      view.set('controller.upgradeData.upgradeGroups', [1]);
+      view.propertyDidChange('upgradeGroups');
+      expect(view.get('upgradeGroups')).to.eql([1]);
+    });
+  });
+
+  describe("#activeGroup", function () {
+    after(function () {
+      view.reopen({
+        activeGroup: Em.Object.create()
+      });
+    });
+    it("", function () {
+      view.reopen({
+        activeStatuses: ['IN_PROGRESS'],
+        upgradeGroups: [Em.Object.create({
+          status: 'IN_PROGRESS'
+        })]
+      });
+      view.propertyDidChange('activeGroup');
+      expect(view.get('activeGroup')).to.eql(Em.Object.create({
+        status: 'IN_PROGRESS'
+      }));
+    });
+  });
+
+  describe("#overallProgress", function () {
+    it("progress is 1.9", function () {
       view.set('controller.upgradeData', {
         Upgrade: {
           progress_percent: 1.9
@@ -42,7 +75,7 @@ describe('App.upgradeWizardView', function () {
       });
       expect(view.get('overallProgress')).to.equal(1);
     });
-    it("progress is 1", function() {
+    it("progress is 1", function () {
       view.set('controller.upgradeData', {
         Upgrade: {
           progress_percent: 1
@@ -52,7 +85,7 @@ describe('App.upgradeWizardView', function () {
     });
   });
 
-  describe("#startPolling()", function() {
+  describe("#startPolling()", function () {
     beforeEach(function () {
       sinon.stub(view.get('controller'), 'loadUpgradeData', function () {
         return {
@@ -68,13 +101,13 @@ describe('App.upgradeWizardView', function () {
       view.get('controller').loadUpgradeData.restore();
       view.doPolling.restore();
     });
-    it("clusterName is null", function() {
+    it("clusterName is null", function () {
       App.set('clusterName', null);
       view.startPolling();
       expect(view.doPolling.called).to.be.false;
       expect(view.get('isLoaded')).to.be.false;
     });
-    it("clusterName set", function() {
+    it("clusterName set", function () {
       App.set('clusterName', 'c1');
       view.startPolling();
       expect(view.get('controller').loadUpgradeData.calledOnce).to.be.true;
@@ -319,16 +352,232 @@ describe('App.upgradeWizardView', function () {
     });
   });
 
-  describe("#isDowngradeAvailable", function() {
-    it("downgrade available", function() {
+  describe("#isDowngradeAvailable", function () {
+    it("downgrade available", function () {
       view.set('controller.isDowngrade', false);
       view.propertyDidChange('isDowngradeAvailable');
       expect(view.get('isDowngradeAvailable')).to.be.true;
     });
-    it("downgrade unavailable", function() {
+    it("downgrade unavailable", function () {
       view.set('controller.isDowngrade', true);
       view.propertyDidChange('isDowngradeAvailable');
       expect(view.get('isDowngradeAvailable')).to.be.false;
     });
   });
+
+  describe("#taskDetails", function () {
+    it("runningItem present", function () {
+      view.reopen({
+        runningItem: Em.Object.create({
+          tasks: [{status: "IN_PROGRESS"}]
+        })
+      });
+      view.propertyDidChange('taskDetails');
+      expect(view.get('taskDetails')).to.eql({status: "IN_PROGRESS"});
+    });
+    it("failedItem present", function () {
+      view.reopen({
+        failedItem: Em.Object.create({
+          tasks: [Em.Object.create({status: "FAILED"})]
+        }),
+        failedStatuses: ['FAILED'],
+        runningItem: null
+      });
+      view.propertyDidChange('taskDetails');
+      expect(view.get('taskDetails').get('status')).to.equal('FAILED');
+    });
+    it("failedItem and runningItem are absent", function () {
+      view.reopen({
+        failedItem: null,
+        runningItem: null
+      });
+      view.propertyDidChange('taskDetails');
+      expect(view.get('taskDetails')).to.be.null;
+    });
+  });
+
+  describe("#isFinalizeItem", function () {
+    it("", function () {
+      view.reopen({
+        manualItem: {
+          context: 'Confirm Finalize'
+        }
+      });
+      view.propertyDidChange('isFinalizeItem');
+      expect(view.get('isFinalizeItem')).to.be.true;
+    });
+  });
+
+  describe("#toggleDetails()", function () {
+    before(function () {
+      sinon.stub(view, 'toggleProperty', Em.K);
+    });
+    after(function () {
+      view.toggleProperty.restore();
+    });
+    it("", function () {
+      view.toggleDetails();
+      expect(view.toggleProperty.calledWith('isDetailsOpened')).to.be.true;
+    });
+  });
+
+  describe("#upgradeStatusLabel", function () {
+    var testCases = [
+      {
+        data: {
+          status: 'QUEUED',
+          isDowngrade: false
+        },
+        result: Em.I18n.t('admin.stackUpgrade.state.inProgress')
+      },
+      {
+        data: {
+          status: 'PENDING',
+          isDowngrade: false
+        },
+        result: Em.I18n.t('admin.stackUpgrade.state.inProgress')
+      },
+      {
+        data: {
+          status: 'IN_PROGRESS',
+          isDowngrade: false
+        },
+        result: Em.I18n.t('admin.stackUpgrade.state.inProgress')
+      },
+      {
+        data: {
+          status: 'COMPLETED',
+          isDowngrade: false
+        },
+        result: Em.I18n.t('admin.stackUpgrade.state.completed')
+      },
+      {
+        data: {
+          status: 'ABORTED',
+          isDowngrade: false
+        },
+        result: Em.I18n.t('admin.stackUpgrade.state.paused')
+      },
+      {
+        data: {
+          status: 'TIMEDOUT',
+          isDowngrade: false
+        },
+        result: Em.I18n.t('admin.stackUpgrade.state.paused')
+      },
+      {
+        data: {
+          status: 'FAILED',
+          isDowngrade: false
+        },
+        result: Em.I18n.t('admin.stackUpgrade.state.paused')
+      },
+      {
+        data: {
+          status: 'HOLDING_FAILED',
+          isDowngrade: false
+        },
+        result: Em.I18n.t('admin.stackUpgrade.state.paused')
+      },
+      {
+        data: {
+          status: 'HOLDING_TIMEDOUT',
+          isDowngrade: false
+        },
+        result: Em.I18n.t('admin.stackUpgrade.state.paused')
+      },
+      {
+        data: {
+          status: 'HOLDING',
+          isDowngrade: false
+        },
+        result: Em.I18n.t('admin.stackUpgrade.state.paused')
+      },
+      {
+        data: {
+          status: '',
+          isDowngrade: false
+        },
+        result: ''
+      },
+      {
+        data: {
+          status: 'QUEUED',
+          isDowngrade: true
+        },
+        result: Em.I18n.t('admin.stackUpgrade.state.inProgress.downgrade')
+      },
+      {
+        data: {
+          status: 'PENDING',
+          isDowngrade: true
+        },
+        result: Em.I18n.t('admin.stackUpgrade.state.inProgress.downgrade')
+      },
+      {
+        data: {
+          status: 'IN_PROGRESS',
+          isDowngrade: true
+        },
+        result: Em.I18n.t('admin.stackUpgrade.state.inProgress.downgrade')
+      },
+      {
+        data: {
+          status: 'COMPLETED',
+          isDowngrade: true
+        },
+        result: Em.I18n.t('admin.stackUpgrade.state.completed.downgrade')
+      },
+      {
+        data: {
+          status: 'ABORTED',
+          isDowngrade: true
+        },
+        result: Em.I18n.t('admin.stackUpgrade.state.paused.downgrade')
+      },
+      {
+        data: {
+          status: 'TIMEDOUT',
+          isDowngrade: true
+        },
+        result: Em.I18n.t('admin.stackUpgrade.state.paused.downgrade')
+      },
+      {
+        data: {
+          status: 'FAILED',
+          isDowngrade: true
+        },
+        result: Em.I18n.t('admin.stackUpgrade.state.paused.downgrade')
+      },
+      {
+        data: {
+          status: 'HOLDING_FAILED',
+          isDowngrade: true
+        },
+        result: Em.I18n.t('admin.stackUpgrade.state.paused.downgrade')
+      },
+      {
+        data: {
+          status: 'HOLDING_TIMEDOUT',
+          isDowngrade: true
+        },
+        result: Em.I18n.t('admin.stackUpgrade.state.paused.downgrade')
+      },
+      {
+        data: {
+          status: 'HOLDING',
+          isDowngrade: true
+        },
+        result: Em.I18n.t('admin.stackUpgrade.state.paused.downgrade')
+      }
+    ].forEach(function (test) {
+        it('status = ' + test.data.status + ", isDowngrade = " + test.data.isDowngrade, function () {
+          view.set('controller.upgradeData.Upgrade.request_status', test.data.status);
+          view.set('controller.isDowngrade', test.data.isDowngrade);
+          view.propertyDidChange('upgradeStatusLabel');
+          expect(view.get('upgradeStatusLabel')).to.equal(test.result);
+        });
+      });
+  });
+
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/9876a036/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 83d69ee..2226b78 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
@@ -25,7 +25,8 @@ describe('App.mainAdminStackVersionsView', function () {
     controller: {
       currentVersion: {
         repository_version: "2.2.1.0"
-      }
+      },
+      load: Em.K
     }
   });
 
@@ -178,4 +179,164 @@ describe('App.mainAdminStackVersionsView', function () {
         });
       });
   });
+
+  describe("#didInsertElement()", function() {
+    before(function () {
+      sinon.stub(view, 'observesCategories', Em.K);
+    });
+    after(function () {
+      view.observesCategories.restore();
+    });
+    it("", function() {
+      view.didInsertElement();
+      expect(view.observesCategories.calledOnce).to.be.true;
+    });
+  });
+
+  describe("#observesCategories()", function () {
+    var mock = {format: Em.K};
+    before(function () {
+      sinon.stub(Em.I18n, 't').returns(mock);
+      sinon.stub(mock, 'format').returns('label');
+      sinon.stub(view, 'filterBy').returns([]);
+      sinon.stub(view, 'filterVersions');
+    });
+    after(function () {
+      Em.I18n.t.restore();
+      mock.format.restore();
+      view.filterBy.restore();
+      view.filterVersions.restore();
+    });
+    it("", function () {
+      view.set('categories', [
+        Em.Object.create({
+          labelKey: 'labelKey',
+          value: 'value',
+          isSelected: false
+        })
+      ]);
+      view.observesCategories();
+      expect(view.get('categories')[0].get('label')).to.equal('label');
+      expect(view.filterVersions.calledOnce).to.be.true;
+    });
+  });
+
+  describe("#selectCategory()", function() {
+    before(function () {
+      sinon.stub(view, 'filterVersions');
+    });
+    after(function () {
+      view.filterVersions.restore();
+    });
+    it("", function() {
+      var event = {
+        context: Em.Object.create({
+          isSelected: false
+        })
+      };
+      view.set('categories', [
+        Em.Object.create({
+          isSelected: true
+        }),
+        event.context
+      ]);
+      view.selectCategory(event);
+      expect(view.get('categories')[0].get('isSelected')).to.be.false;
+      expect(event.context.get('isSelected')).to.be.true;
+      expect(view.filterVersions.calledWith(event.context)).to.be.true;
+    });
+  });
+
+  describe("#filterVersions()", function() {
+    before(function () {
+      sinon.stub(view, 'filterBy').returns([{id: 1}]);
+      sinon.stub(view, 'observesCategories', Em.K);
+    });
+    after(function () {
+      view.filterBy.restore();
+      view.observesCategories.restore();
+    });
+    it("", function() {
+      view.set('repoVersions', [Em.Object.create({id: 1})]);
+      view.filterVersions();
+      expect(view.get('repoVersions')[0].get('isVisible')).to.be.true;
+    });
+  });
+
+  describe("#goToVersions()", function() {
+    before(function () {
+      sinon.spy(App, 'showConfirmationPopup', Em.K);
+      sinon.stub(window.location, 'replace', Em.K);
+    });
+    after(function () {
+      App.showConfirmationPopup.restore();
+      window.location.replace.restore();
+    });
+    it("", function() {
+      var popup = view.goToVersions();
+      expect(App.showConfirmationPopup.calledOnce).to.be.true;
+      popup.onPrimary();
+      expect(window.location.replace.calledWith('/views/ADMIN_VIEW/1.0.0/INSTANCE/#/stackVersions')).to.be.true;
+    });
+  });
+
+  describe("#willInsertElement()", function() {
+    before(function () {
+      sinon.stub(view, 'doPolling', Em.K);
+    });
+    after(function () {
+      view.doPolling.restore();
+    });
+    it("", function() {
+      view.willInsertElement();
+      expect(view.doPolling.calledOnce).to.be.true;
+    });
+  });
+
+  describe("#willDestroyElement()", function() {
+    before(function () {
+      sinon.stub(window, 'clearTimeout', Em.K);
+    });
+    after(function () {
+      window.clearTimeout.restore();
+    });
+    it("", function() {
+      view.willDestroyElement();
+      expect(window.clearTimeout.calledOnce).to.be.true;
+    });
+  });
+
+  describe("#doPolling()", function() {
+    before(function () {
+      sinon.stub(window, 'setTimeout', Em.K);
+    });
+    after(function () {
+      window.setTimeout.restore();
+    });
+    it("", function() {
+      view.doPolling();
+      expect(window.setTimeout.calledOnce).to.be.true;
+    });
+  });
+
+  describe("#poll()", function() {
+    beforeEach(function () {
+      this.mock = sinon.stub(App.router, 'get');
+      sinon.stub(view.get('controller'), 'load').returns({done: Em.K});
+    });
+    afterEach(function () {
+      this.mock.restore();
+      view.get('controller').load.restore();
+    });
+    it("update is working", function() {
+      this.mock.returns(Em.Object.create({isWorking: true}));
+      view.poll();
+      expect(view.get('controller').load.calledOnce).to.be.true;
+    });
+    it("update is not working", function() {
+      this.mock.returns(Em.Object.create({isWorking: false}));
+      view.poll();
+      expect(view.get('controller').load.called).to.be.false;
+    });
+  });
 });


Mime
View raw message