瀏覽代碼

AMBARI-14495. Improve Ambari UI UT (p.2) (onechiporenko)

Oleg Nechiporenko 9 年之前
父節點
當前提交
f8213edb4f
共有 23 個文件被更改,包括 1633 次插入1128 次删除
  1. 38 13
      ambari-web/test/controllers/wizard/step10_test.js
  2. 20 10
      ambari-web/test/controllers/wizard/step2_test.js
  3. 136 164
      ambari-web/test/controllers/wizard/step3_test.js
  4. 58 35
      ambari-web/test/controllers/wizard/step4_test.js
  5. 149 68
      ambari-web/test/controllers/wizard/step5_test.js
  6. 29 12
      ambari-web/test/controllers/wizard/step6_test.js
  7. 223 132
      ambari-web/test/controllers/wizard/step7_test.js
  8. 245 193
      ambari-web/test/controllers/wizard/step8_test.js
  9. 53 36
      ambari-web/test/controllers/wizard/step9_test.js
  10. 91 40
      ambari-web/test/controllers/wizard_test.js
  11. 13 13
      ambari-web/test/data/HDP2.2/site_properties_test.js
  12. 13 13
      ambari-web/test/data/HDP2.3/site_properties_test.js
  13. 13 13
      ambari-web/test/data/HDP2/site_properties_test.js
  14. 135 30
      ambari-web/test/mappers/alert_definition_summary_mapper_test.js
  15. 61 22
      ambari-web/test/mappers/configs/service_config_version_mapper_test.js
  16. 218 164
      ambari-web/test/mappers/configs/stack_config_properties_mapper_test.js
  17. 98 82
      ambari-web/test/mappers/configs/themes_mapper_test.js
  18. 9 6
      ambari-web/test/mappers/service_mapper_test.js
  19. 18 6
      ambari-web/test/mappers/stack_mapper_test.js
  20. 4 6
      ambari-web/test/utils/blueprint_test.js
  21. 1 4
      ambari-web/test/utils/helper_test.js
  22. 0 59
      ambari-web/test/views/main/alerts/manage_alert_groups_view_test.js
  23. 8 7
      ambari-web/test/views/main/service/info/summary_test.js

+ 38 - 13
ambari-web/test/controllers/wizard/step10_test.js

@@ -98,14 +98,24 @@ describe('App.WizardStep10Controller', function () {
       }
     ]);
     testsForLoadInstallTime.forEach(function(test) {
-      it('loadMasterComponents: ' + test.loadMasterComponents.toString() + ' loadStartedServices: ' + test.loadStartedServices.toString(), function() {
-        controller.set('content.controllerName', 'installerController');
-        sinon.stub(controller, 'loadMasterComponents', function() {return test.loadMasterComponents;});
-        sinon.stub(controller, 'loadStartedServices', function() {return test.loadStartedServices;});
-        controller.loadStep();
-        expect(controller.loadInstallTime.called).to.equal(test.e);
-        controller.loadMasterComponents.restore();
-        controller.loadStartedServices.restore();
+      describe('loadMasterComponents: ' + test.loadMasterComponents.toString() + ' loadStartedServices: ' + test.loadStartedServices.toString(), function() {
+
+        beforeEach(function () {
+          controller.set('content.controllerName', 'installerController');
+          sinon.stub(controller, 'loadMasterComponents', function() {return test.loadMasterComponents;});
+          sinon.stub(controller, 'loadStartedServices', function() {return test.loadStartedServices;});
+          controller.loadStep();
+        });
+
+        afterEach(function () {
+          controller.loadMasterComponents.restore();
+          controller.loadStartedServices.restore();
+        });
+
+        it('loadInstallTime was ' + (test.e ? '' : 'not') + ' called', function () {
+          expect(controller.loadInstallTime.called).to.equal(test.e);
+        });
+
       });
     });
   });
@@ -426,22 +436,37 @@ describe('App.WizardStep10Controller', function () {
   });
 
   describe('#loadRegisteredHosts', function() {
-    it('should add object to clusterInfo', function() {
-      var masterComponentHosts = [{hostName: 'h1'}, {hostName: 'h2'}, {hostName: 'h3'}],
-        slaveComponentHosts = [{hosts: [{hostName: 'h1'}, {hostName: 'h4'}]}, {hosts: [{hostName: 'h2'}, {hostName: 'h5'}]}],
-        hosts = [{hostName: 'h6'}, {hostName: 'h3'}, {hostName: 'h7'}];
+    var masterComponentHosts = [{hostName: 'h1'}, {hostName: 'h2'}, {hostName: 'h3'}],
+      slaveComponentHosts = [{hosts: [{hostName: 'h1'}, {hostName: 'h4'}]}, {hosts: [{hostName: 'h2'}, {hostName: 'h5'}]}],
+      hosts = [{hostName: 'h6'}, {hostName: 'h3'}, {hostName: 'h7'}];
+    var obj;
+    beforeEach(function () {
       controller.set('content.masterComponentHosts', masterComponentHosts);
       controller.set('content.slaveComponentHosts', slaveComponentHosts);
       controller.set('clusterInfo', []);
       sinon.stub(App.Host, 'find', function() {
         return hosts;
       });
-      var obj = controller.loadRegisteredHosts();
+      obj = controller.loadRegisteredHosts();
+    });
+
+    afterEach(function () {
       App.Host.find.restore();
+    });
+
+    it('id  = 1', function() {
       expect(obj.id).to.equal(1);
+    });
+    it('color = text-info', function () {
       expect(obj.color).to.equal('text-info');
+    });
+    it('displayStatement is valid', function () {
       expect(obj.displayStatement).to.equal(Em.I18n.t('installer.step10.hostsSummary').format(7));
+    });
+    it('status is []', function () {
       expect(obj.status).to.eql([]);
+    });
+    it('clusterInfo.firstObject is valid', function () {
       expect(controller.get('clusterInfo.firstObject')).to.eql(obj);
     });
   });

+ 20 - 10
ambari-web/test/controllers/wizard/step2_test.js

@@ -270,13 +270,17 @@ describe('App.WizardStep2Controller', function () {
 
   describe('#agentUserError', function () {
 
+    beforeEach(function () {
+      this.stub = sinon.stub(App, 'get');
+    });
+
     afterEach(function () {
       App.get.restore();
     });
 
     userErrorTests.forEach(function(test) {
       it('Ambari Agent user account customize enabled', function() {
-        sinon.stub(App, 'get').withArgs('supports.customizeAgentUserAccount').returns(true);
+        this.stub.withArgs('supports.customizeAgentUserAccount').returns(true);
         var controller = App.WizardStep2Controller.create({content: {installOptions: {manualInstall: test.manualInstall, agentUser: test.user}}});
         if(Em.isNone(test.e)) {
           expect(controller.get('agentUserError')).to.be.null;
@@ -289,7 +293,7 @@ describe('App.WizardStep2Controller', function () {
 
     userErrorTests.forEach(function(test) {
       it('Ambari Agent user account customize disabled', function() {
-        sinon.stub(App, 'get').withArgs('supports.customizeAgentUserAccount').returns(false);
+        this.stub.withArgs('supports.customizeAgentUserAccount').returns(false);
         var controller = App.WizardStep2Controller.create({content: {installOptions: {manualInstall: test.manualInstall, agentUser: test.user}}});
         expect(controller.get('agentUserError')).to.be.null;
       });
@@ -428,14 +432,24 @@ describe('App.WizardStep2Controller', function () {
 
   describe('#proceedNext()', function () {
 
+    beforeEach(function () {
+      sinon.stub(c, 'warningPopup', Em.K);
+      sinon.stub(c, 'manualInstallPopup', Em.K);
+      sinon.stub(App.router, 'send', Em.K);
+    });
+
+    afterEach(function () {
+      c.warningPopup.restore();
+      c.manualInstallPopup.restore();
+      App.router.send.restore();
+    });
+
     it('should call warningPopup if not isAllHostNamesValid and no warningConfirmed', function() {
       c.reopen({
         isAllHostNamesValid: function() {
           return false;
-        },
-        warningPopup: Em.K
+        }
       });
-      sinon.spy(c, 'warningPopup');
       var r = c.proceedNext(false);
       expect(r).to.equal(false);
       expect(c.warningPopup.calledOnce).to.equal(true);
@@ -444,17 +458,14 @@ describe('App.WizardStep2Controller', function () {
     it('should call manualInstallPopup if manualInstall is true', function () {
       c.reopen({
         hostNames: '',
-        manualInstall: true,
-        manualInstallPopup: Em.K
+        manualInstall: true
       });
-      sinon.spy(c, 'manualInstallPopup');
       var r = c.proceedNext(true);
       expect(r).to.equal(false);
       expect(c.manualInstallPopup.calledOnce).to.equal(true);
     });
 
     it ('should save hosts and proceed next if manualInstall is false', function() {
-      sinon.stub(App.router, 'send', Em.K);
       c.reopen({
         hostNameArr: ['h1'],
         manualInstall: false,
@@ -468,7 +479,6 @@ describe('App.WizardStep2Controller', function () {
       expect(r).to.equal(true);
       expect(Em.keys(c.get('content.hosts'))).to.eql(['h1']);
       expect(App.router.send.calledWith('next')).to.equal(true);
-      App.router.send.restore();
     });
 
   });

+ 136 - 164
ambari-web/test/controllers/wizard/step3_test.js

@@ -155,23 +155,15 @@ describe('App.WizardStep3Controller', function () {
 
   describe('#isWarningsBoxVisible', function () {
 
-    afterEach(function () {
-      App.get.restore();
+    beforeEach(function () {
+      sinon.stub(App, 'get').withArgs('testMode').returns(false);
     });
 
-    it('for testMode should be always true', function () {
-      sinon.stub(App, 'get', function (k) {
-        if ('testMode' === k) return true;
-        return Em.get(App, k);
-      });
-      expect(c.get('isWarningsBoxVisible')).to.equal(true);
+    afterEach(function () {
+      App.get.restore();
     });
 
     it('for "real" mode should be based on isRegistrationInProgress', function () {
-      sinon.stub(App, 'get', function (k) {
-        if ('testMode' === k) return false;
-        return Em.get(App, k);
-      });
       c.set('isRegistrationInProgress', false);
       expect(c.get('isWarningsBoxVisible')).to.equal(true);
       c.set('isRegistrationInProgress', true);
@@ -218,11 +210,6 @@ describe('App.WizardStep3Controller', function () {
       expect(c.get('isSubmitDisabled')).to.equal(true);
     });
 
-    it('should set isSubmitDisabled to true', function () {
-      c.set('isRetryDisabled', false);
-      c.clearStep();
-      expect(c.get('isRetryDisabled')).to.equal(true);
-    });
   });
 
   describe('#loadStep', function () {
@@ -306,7 +293,7 @@ describe('App.WizardStep3Controller', function () {
       expect(c.get('hosts').everyProperty('bootStatus', 'PENDING')).to.equal(true);
     });
 
-    it('should set bootStatus PENDING on "real" mode and when installOptions.manualInstall is not selected', function () {
+    it('should set bootStatus PENDING on "real" mode and when installOptions.manualInstall is not selected (2)', function () {
       App.set('testMode', true);
       c.set('content', {hosts: {c: {name: 'name'}, d: {name: 'name1'}}});
       c.loadHosts();
@@ -527,29 +514,39 @@ describe('App.WizardStep3Controller', function () {
     });
 
     agentUserCases.forEach(function (item) {
-      it(item.title, function () {
-        var controller = App.WizardStep3Controller.create({
-          content: {
-            installOptions: {
-              sshKey: 'key',
-              sshUser: 'root',
-              sshPort: '123',
-              agentUser: 'user'
-            },
-            hosts: { "host0": { "name": "host0" }, "host1": { "name": "host1" } }
-          }
+      describe(item.title, function () {
+        var controller;
+        beforeEach(function () {
+          controller = App.WizardStep3Controller.create({
+            content: {
+              installOptions: {
+                sshKey: 'key',
+                sshUser: 'root',
+                sshPort: '123',
+                agentUser: 'user'
+              },
+              hosts: { "host0": { "name": "host0" }, "host1": { "name": "host1" } }
+            }
+          });
+          sinon.stub(App, 'get').withArgs('supports.customizeAgentUserAccount').returns(item.customizeAgentUserAccount);
+          controller.setupBootStrap();
         });
-        sinon.stub(App, 'get').withArgs('supports.customizeAgentUserAccount').returns(item.customizeAgentUserAccount);
-        controller.setupBootStrap();
-        App.get.restore();
-        expect(installer.launchBootstrap.firstCall.args[0]).to.equal(JSON.stringify({
-          verbose: true,
-          sshKey: 'key',
-          hosts: ['host0', 'host1'],
-          user: 'root',
-          sshPort: '123',
-          userRunAs: item.userRunAs
-        }));
+
+        afterEach(function () {
+          App.get.restore();
+        });
+
+        it('launchBootstrap is called with correct arguments', function () {
+          expect(installer.launchBootstrap.firstCall.args[0]).to.equal(JSON.stringify({
+            verbose: true,
+            sshKey: 'key',
+            hosts: ['host0', 'host1'],
+            user: 'root',
+            sshPort: '123',
+            userRunAs: item.userRunAs
+          }));
+        });
+
       });
     });
   });
@@ -631,7 +628,7 @@ describe('App.WizardStep3Controller', function () {
       expect(c.get('registrationStartedAt')).to.be.null;
     });
 
-    it('should drop numPolls and registrationStartedAt', function () {
+    it('should drop numPolls and registrationStartedAt (2)', function () {
       c.set('hosts', Em.A([
         {name: 'c1'},
         {name: 'c2'}
@@ -770,7 +767,7 @@ describe('App.WizardStep3Controller', function () {
       expect(c.get('registrationStartedAt')).to.equal(1234);
     });
 
-    it('shouldn\'t do nothing if registrationStartedAt isn\'t null', function () {
+    it('shouldn\'t do nothing if registrationStartedAt isn\'t null (2)', function () {
       c.set('registrationStartedAt', null);
       c.startRegistration();
       expect(c.isHostsRegistered.calledOnce).to.equal(true);
@@ -2276,62 +2273,50 @@ describe('App.WizardStep3Controller', function () {
         });
       });
 
-    it('should set test data if testMode is true', function () {
-      c.reopen({
-        isLoaded: true,
-        hosts: [
-          {},
-          {},
-          {}
-        ],
-        content: {
-          installedHosts: [],
-          installOptions: {
-            manualInstall: true
-          }
-        },
-        setRegistrationInProgress: Em.K
+    describe('should start registration', function () {
+
+      beforeEach(function () {
+        c.reopen({
+          isLoaded: true,
+          hosts: [
+            {},
+            {},
+            {}
+          ],
+          content: {
+            installedHosts: [],
+            installOptions: {
+              manualInstall: true
+            }
+          },
+          setRegistrationInProgress: Em.K,
+          startRegistration: Em.K
+        });
+        sinon.stub(App, 'get', function (k) {
+          if ('testMode' === k) return false;
+          return Em.get(App, k);
+        });
+        sinon.spy(c, 'startRegistration');
+        c.navigateStep();
       });
-      sinon.stub(App, 'get', function (k) {
-        if ('testMode' === k) return true;
-        return Em.get(App, k);
+
+
+      afterEach(function () {
+        App.get.restore();
+        c.startRegistration.restore();
       });
-      c.navigateStep();
-      App.get.restore();
-      expect(c.get('bootHosts.length')).to.equal(c.get('hosts.length'));
-      expect(c.get('bootHosts').everyProperty('cpu', '2')).to.equal(true);
-      expect(c.get('bootHosts').everyProperty('memory', '2000000')).to.equal(true);
-      expect(c.get('isSubmitDisabled')).to.equal(false);
-    });
 
-    it('should start registration', function () {
-      c.reopen({
-        isLoaded: true,
-        hosts: [
-          {},
-          {},
-          {}
-        ],
-        content: {
-          installedHosts: [],
-          installOptions: {
-            manualInstall: true
-          }
-        },
-        setRegistrationInProgress: Em.K,
-        startRegistration: Em.K
+      it('startRegistration is called once', function () {
+        expect(c.startRegistration.calledOnce).to.equal(true);
       });
-      sinon.stub(App, 'get', function (k) {
-        if ('testMode' === k) return false;
-        return Em.get(App, k);
+
+      it('all hosts are bootHosts', function () {
+        expect(c.get('bootHosts.length')).to.equal(c.get('hosts.length'));
+      });
+
+      it('registrationStartedAt is null', function () {
+        expect(c.get('registrationStartedAt')).to.be.null;
       });
-      sinon.spy(c, 'startRegistration');
-      c.navigateStep();
-      App.get.restore();
-      expect(c.startRegistration.calledOnce).to.equal(true);
-      c.startRegistration.restore();
-      expect(c.get('bootHosts.length')).to.equal(c.get('hosts.length'));
-      expect(c.get('registrationStartedAt')).to.be.null;
     });
 
   });
@@ -2506,12 +2491,29 @@ describe('App.WizardStep3Controller', function () {
 
   describe('#getHostInfoSuccessCallback', function () {
 
+    var jsonData = {items: [
+      {Hosts: {host_name: 'h1'}}
+    ]};
+
+    var skipBootstrap = false;
+
     beforeEach(function () {
       sinon.stub(c, 'parseWarnings', Em.K);
       sinon.stub(c, 'stopRegistration', Em.K);
       sinon.stub(c, 'checkHostDiskSpace', Em.K);
       sinon.stub(c, '_setHostDataFromLoadedHostInfo', Em.K);
       sinon.spy(c, '_setHostDataWithSkipBootstrap');
+      sinon.stub(App, 'get', function (k) {
+        if ('skipBootstrap' === k) return skipBootstrap;
+        if ('testMode' === k) return false;
+        return Em.get(App, k);
+      });
+      c.reopen({
+        bootHosts: [Em.Object.create({name: 'h1'})]
+      });
+      sinon.stub(c, 'checkHostOSType', function () {
+        return 'not_null_value';
+      });
     });
 
     afterEach(function () {
@@ -2520,73 +2522,28 @@ describe('App.WizardStep3Controller', function () {
       c.checkHostDiskSpace.restore();
       c._setHostDataFromLoadedHostInfo.restore();
       c._setHostDataWithSkipBootstrap.restore();
+      App.get.restore();
+      c.checkHostOSType.restore();
     });
 
     it('should call _setHostDataWithSkipBootstrap if skipBootstrap is true', function () {
-      sinon.stub(App, 'get', function (k) {
-        if ('skipBootstrap' === k) return true;
-        if ('testMode' === k) return false;
-        return Em.get(App, k);
-      });
-      c.reopen({
-        bootHosts: [Em.Object.create({name: 'h1'})]
-      });
-      var jsonData = {items: [
-        {Hosts: {host_name: 'h1'}}
-      ]};
-      c.getHostInfoSuccessCallback(jsonData);
-      expect(c._setHostDataWithSkipBootstrap.calledOnce).to.equal(true);
-      App.get.restore();
+        skipBootstrap = true;
+        c.getHostInfoSuccessCallback(jsonData);
+        expect(c._setHostDataWithSkipBootstrap.calledOnce).to.equal(true);
     });
 
     it('should add repo warnings', function () {
-
-      var jsonData = {items: [
-        {Hosts: {host_name: 'h1'}}
-      ]};
-
-      sinon.stub(c, 'checkHostOSType', function () {
-        return 'not_null_value';
-      });
-      sinon.stub(App, 'get', function (k) {
-        if ('skipBootstrap' === k) return false;
-        if ('testMode' === k) return false;
-        return Em.get(App, k);
-      });
-
-      c.reopen({
-        bootHosts: [Em.Object.create({name: 'h1'})]
-      });
-
+      skipBootstrap = false;
       c.getHostInfoSuccessCallback(jsonData);
       expect(c.get('repoCategoryWarnings.length')).to.equal(1);
       expect(c.get('repoCategoryWarnings.firstObject.hostsNames').contains('h1')).to.equal(true);
-
-      c.checkHostOSType.restore();
-      App.get.restore();
     });
 
     it('should add disk warnings', function () {
-
-      var jsonData = {items: [
-        {Hosts: {host_name: 'h1'}}
-      ]};
-
-      sinon.stub(App, 'get', function (k) {
-        if ('skipBootstrap' === k) return false;
-        if ('testMode' === k) return false;
-        return Em.get(App, k);
-      });
-
-      c.reopen({
-        bootHosts: [Em.Object.create({name: 'h1'})]
-      });
-
+      skipBootstrap = false;
       c.getHostInfoSuccessCallback(jsonData);
       expect(c.get('diskCategoryWarnings.length')).to.equal(1);
       expect(c.get('diskCategoryWarnings.firstObject.hostsNames').contains('h1')).to.equal(true);
-
-      App.get.restore();
     });
 
   });
@@ -2604,32 +2561,47 @@ describe('App.WizardStep3Controller', function () {
   });
 
   describe('#_setHostDataFromLoadedHostInfo', function () {
-
-    it('should set data from hostInfo', function () {
-      var host = Em.Object.create(),
-        hostInfo = {
-          Hosts: {
-            cpu_count: 2,
-            total_mem: 12345,
-            os_type: 't1',
-            os_arch: 'os1',
-            os_family: 'osf1',
-            ip: '0.0.0.0',
-            disk_info: [
-              {mountpoint: '/boot'},
-              {mountpoint: '/usr'},
-              {mountpoint: '/no-boot'},
-              {mountpoint: '/boot'}
-            ]
-          }
-        };
+    var host;
+    beforeEach(function () {
+      host = Em.Object.create();
+      var hostInfo = {
+        Hosts: {
+          cpu_count: 2,
+          total_mem: 12345,
+          os_type: 't1',
+          os_arch: 'os1',
+          os_family: 'osf1',
+          ip: '0.0.0.0',
+          disk_info: [
+            {mountpoint: '/boot'},
+            {mountpoint: '/usr'},
+            {mountpoint: '/no-boot'},
+            {mountpoint: '/boot'}
+          ]
+        }
+      };
       c._setHostDataFromLoadedHostInfo(host, hostInfo);
+    });
+
+    it('cpu', function () {
       expect(host.get('cpu')).to.equal(2);
+    });
+    it('os_type', function () {
       expect(host.get('os_type')).to.equal('t1');
+    });
+    it('os_arch', function () {
       expect(host.get('os_arch')).to.equal('os1');
+    });
+    it('os_family', function () {
       expect(host.get('os_family')).to.equal('osf1');
+    });
+    it('ip', function () {
       expect(host.get('ip')).to.equal('0.0.0.0');
+    });
+    it('memory', function () {
       expect(host.get('memory')).to.equal('12345.00');
+    });
+    it('disk_info.length', function () {
       expect(host.get('disk_info.length')).to.equal(2);
     });
 

+ 58 - 35
ambari-web/test/controllers/wizard/step4_test.js

@@ -350,14 +350,23 @@ describe('App.WizardStep4Controller', function () {
     });
 
     sparkCases.forEach(function (item) {
-      it(item.title, function () {
-        sinon.stub(App, 'get').withArgs('currentStackName').returns(item.currentStackName).
-          withArgs('currentStackVersionNumber').returns(item.currentStackVersionNumber);
-        controller.set('errorStack', []);
-        controller.set('content', generateSelectedServicesContent(['SPARK']));
-        controller.validate();
-        expect(controller.get('errorStack').someProperty('id', 'sparkWarning')).to.equal(item.sparkWarningExpected);
-        App.get.restore();
+      describe(item.title, function () {
+
+        beforeEach(function () {
+          sinon.stub(App, 'get').withArgs('currentStackName').returns(item.currentStackName).
+            withArgs('currentStackVersionNumber').returns(item.currentStackVersionNumber);
+          controller.set('errorStack', []);
+          controller.set('content', generateSelectedServicesContent(['SPARK']));
+          controller.validate();
+        });
+
+        afterEach(function () {
+          App.get.restore();
+        });
+
+        it('sparkWarning ' + (item.sparkWarningExpected ? 'exists' : 'not exists'), function () {
+          expect(controller.get('errorStack').someProperty('id', 'sparkWarning')).to.equal(item.sparkWarningExpected);
+        });
       });
     });
 
@@ -406,37 +415,43 @@ describe('App.WizardStep4Controller', function () {
       var message = 'Selected services: {0}. {1} errors should be confirmed'
         .format(test.services.join(', '), test.confirmPopupCount);
 
-      it(message, function() {
+      describe(message, function() {
         var runValidations = function() {
           c.serviceDependencyValidation();
           c.fileSystemServiceValidation();
         };
 
-        c.set('content', generateSelectedServicesContent(test.services));
-        runValidations();
-        // errors count validation
-        expect(c.get('errorStack.length')).to.equal(test.confirmPopupCount);
-        // if errors detected than it should be shown
+        beforeEach(function () {
+          c.set('content', generateSelectedServicesContent(test.services));
+          runValidations();
+        });
+
+        it('errors count validation', function () {
+          expect(c.get('errorStack.length')).to.equal(test.confirmPopupCount);
+        });
+
         if (test.errorsExpected) {
-          test.errorsExpected.forEach(function(error, index, errors) {
-            // validate current error
-            var currentErrorObject = c.get('errorStack').findProperty('isShown', false);
-            if (currentErrorObject) {
-              expect(test.errorsExpected).to.contain(currentErrorObject.id);
-              // show current error
-              var popup = c.showError(currentErrorObject);
-              // submit popup
-              popup.onPrimary();
-              // onPrimaryPopupCallback should be called
-              expect(c.onPrimaryPopupCallback.called).to.equal(true);
-              // submit called
-              expect(c.submit.called).to.equal(true);
-              if (c.get('errorStack').length) {
-                // current error isShown flag changed to true
-                expect(currentErrorObject.isShown).to.equal(true);
+          it('if errors detected than it should be shown', function () {
+            test.errorsExpected.forEach(function(error, index, errors) {
+              // validate current error
+              var currentErrorObject = c.get('errorStack').findProperty('isShown', false);
+              if (currentErrorObject) {
+                expect(test.errorsExpected).to.contain(currentErrorObject.id);
+                // show current error
+                var popup = c.showError(currentErrorObject);
+                // submit popup
+                popup.onPrimary();
+                // onPrimaryPopupCallback should be called
+                expect(c.onPrimaryPopupCallback.called).to.equal(true);
+                // submit called
+                expect(c.submit.called).to.equal(true);
+                if (c.get('errorStack').length) {
+                  // current error isShown flag changed to true
+                  expect(currentErrorObject.isShown).to.equal(true);
+                }
+                runValidations();
               }
-              runValidations();
-            }
+            });
           });
         }
       });
@@ -445,6 +460,15 @@ describe('App.WizardStep4Controller', function () {
   });
 
   describe('#needToAddServicePopup', function() {
+
+    beforeEach(function () {
+      sinon.stub(controller, 'submit', Em.K);
+    });
+
+    afterEach(function () {
+      controller.submit.restore();
+    });
+
     Em.A([
         {
           m: 'one service',
@@ -461,12 +485,10 @@ describe('App.WizardStep4Controller', function () {
         }
       ]).forEach(function (test) {
         it(test.m, function () {
-          sinon.stub(controller, 'submit', Em.K);
           controller.set('content', test.content);
           controller.needToAddServicePopup(test.services, '').onPrimary();
           expect(controller.submit.calledOnce).to.equal(true);
           expect(controller.mapProperty('isSelected')).to.eql(test.e);
-          controller.submit.restore();
         });
       });
   });
@@ -765,6 +787,7 @@ describe('App.WizardStep4Controller', function () {
     beforeEach(function() {
       controller.clear();
       controller.set('errorStack', []);
+      this.stub = sinon.stub(App, 'get');
     });
 
     afterEach(function () {
@@ -773,7 +796,7 @@ describe('App.WizardStep4Controller', function () {
 
     cases.forEach(function (item) {
       it(item.title, function () {
-        sinon.stub(App, 'get').withArgs('currentStackName').returns(item.currentStackName).
+        this.stub.withArgs('currentStackName').returns(item.currentStackName).
           withArgs('currentStackVersionNumber').returns(item.currentStackVersionNumber);
         controller.set('content', generateSelectedServicesContent(item.services));
         var spark = controller.findProperty('serviceName', 'SPARK');

+ 149 - 68
ambari-web/test/controllers/wizard/step5_test.js

@@ -293,21 +293,30 @@ describe('App.WizardStep5Controller', function () {
     ]);
 
     tests.forEach(function (test) {
-      it(test.m, function () {
-        sinon.stub(App.StackServiceComponent, 'find', function () {
-          return test.serviceComponents;
+      describe(test.m, function () {
+
+        beforeEach(function () {
+          sinon.stub(App.StackServiceComponent, 'find', function () {
+            return test.serviceComponents;
+          });
+          c.reopen({
+            content: Em.Object.create({
+              controllerName: test.controllerName
+            }),
+            selectedServicesMasters: test.selectedServicesMasters,
+            hosts: test.hosts
+          });
+          c.updateComponent(test.componentName);
         });
-        c.reopen({
-          content: Em.Object.create({
-            controllerName: test.controllerName
-          }),
-          selectedServicesMasters: test.selectedServicesMasters,
-          hosts: test.hosts
+
+        afterEach(function () {
+          App.StackServiceComponent.find.restore();
         });
-        c.updateComponent(test.componentName);
-        App.StackServiceComponent.find.restore();
+
         Em.keys(test.e).forEach(function (k) {
-          expect(c.last(test.componentName).get(k)).to.equal(test.e[k]);
+          it(k, function () {
+            expect(c.last(test.componentName).get(k)).to.equal(test.e[k]);
+          });
         });
 
       });
@@ -372,32 +381,52 @@ describe('App.WizardStep5Controller', function () {
       }
     ]);
     tests.forEach(function (test) {
-      beforeEach(function () {
-        App.reopen({isHaEnabled: test.isHaEnabled});
-      });
-      it(test.m, function () {
-        modelSetup.setupStackServiceComponent();
-        sinon.stub(App.StackService, 'find', function () {
-          return test.services;
+      describe(test.m, function () {
+
+        beforeEach(function () {
+          sinon.stub(App, 'get').withArgs('isHaEnabled').returns(test.isHaEnabled);
+          sinon.stub(App.StackService, 'find', function () {
+            return test.services;
+          });
+          modelSetup.setupStackServiceComponent();
+          c.reopen({
+            content: Em.Object.create({
+              services: test.services,
+              controllerName: test.controllerName,
+              reassign: {component_name: test.component_name}
+            })
+          });
+          c.renderComponents(test.masterComponents);
         });
-        App.set('isHaEnabled', test.isHaEnabled);
-        c.reopen({
-          content: Em.Object.create({
-            services: test.services,
-            controllerName: test.controllerName,
-            reassign: {component_name: test.component_name}
-          })
+
+        afterEach(function () {
+          App.get.restore();
+          App.StackService.find.restore();
+          modelSetup.cleanStackServiceComponent();
         });
-        c.renderComponents(test.masterComponents);
-        App.StackService.find.restore();
-        modelSetup.cleanStackServiceComponent();
-        expect(c.get('selectedServicesMasters').mapProperty('component_name')).to.eql(test.e.selectedServicesMasters);
-        expect(c.get('servicesMasters').mapProperty('component_name')).to.eql(test.e.servicesMasters);
-        expect(c.get('selectedServicesMasters').mapProperty('showRemoveControl')).to.eql(test.e.showRemoveControl);
-        expect(c.get('selectedServicesMasters').mapProperty('serviceComponentId')).to.eql(test.e.serviceComponentId);
-        if (c.get('isReasignController')) {
-          expect(c.get('servicesMasters').mapProperty('isInstalled')).to.eql(test.e.isInstalled);
-        }
+
+        it('all selectedServicesMasters.component_name are valid', function () {
+          expect(c.get('selectedServicesMasters').mapProperty('component_name')).to.eql(test.e.selectedServicesMasters);
+        });
+
+        it('all servicesMasters.component_name are valid', function () {
+          expect(c.get('servicesMasters').mapProperty('component_name')).to.eql(test.e.servicesMasters);
+        });
+
+        it('all showRemoveControl are valid', function () {
+          expect(c.get('selectedServicesMasters').mapProperty('showRemoveControl')).to.eql(test.e.showRemoveControl);
+        });
+
+        it('all serviceComponentId are valid', function () {
+          expect(c.get('selectedServicesMasters').mapProperty('serviceComponentId')).to.eql(test.e.serviceComponentId);
+        });
+
+        it('servicesMasters.@each.isInstalled is valid', function () {
+          if (c.get('isReasignController')) {
+            expect(c.get('servicesMasters').mapProperty('isInstalled')).to.eql(test.e.isInstalled);
+          }
+        });
+
       });
     });
   });
@@ -528,15 +557,34 @@ describe('App.WizardStep5Controller', function () {
       }
     ]);
     tests.forEach(function (test) {
-      it(test.m, function () {
-        c.set('selectedServicesMasters', test.selectedServicesMasters);
-        c.set('hosts', test.hosts);
-        expect(c.removeComponent(test.componentName, test.serviceComponentId)).to.equal(test.e);
+      describe(test.m, function () {
+
+        beforeEach(function () {
+          c.set('selectedServicesMasters', JSON.parse(JSON.stringify(test.selectedServicesMasters)));
+          c.set('hosts', test.hosts);
+          this.result = c.removeComponent(test.componentName, test.serviceComponentId);
+        });
+
+        it('removeComponent returns ' + test.e, function () {
+          expect(this.result).to.equal(test.e);
+        });
+
         if (test.e) {
-          expect(c.get('selectedServicesMasters.lastObject.showRemoveControl')).to.equal(test.showRemoveControl);
-          expect(c.get('selectedServicesMasters.lastObject.showAddControl')).to.equal(test.showAddControl);
-          expect(c.get('componentToRebalance')).to.equal(test.componentName);
-          expect(c.get('lastChangedComponent')).to.equal(test.componentName);
+          it('showRemoveControl is correct', function () {
+            expect(c.get('selectedServicesMasters.lastObject.showRemoveControl')).to.equal(test.showRemoveControl);
+          });
+
+          it('showAddControl is correct', function () {
+            expect(c.get('selectedServicesMasters.lastObject.showAddControl')).to.equal(test.showAddControl);
+          });
+
+          it('componentToRebalance is correct', function () {
+            expect(c.get('componentToRebalance')).to.equal(test.componentName);
+          });
+
+          it('lastChangedComponent is correct', function () {
+            expect(c.get('lastChangedComponent')).to.equal(test.componentName);
+          });
         }
       })
     });
@@ -641,17 +689,26 @@ describe('App.WizardStep5Controller', function () {
           ]
         }
       ]).forEach(function (test) {
-        it(test.m, function () {
-          c.reopen({
-            selectedServicesMasters: test.selectedServicesMasters,
-            hosts: test.hosts
+        describe(test.m, function () {
+          var result;
+          beforeEach(function () {
+            c.reopen({
+              selectedServicesMasters: test.selectedServicesMasters,
+              hosts: test.hosts
+            });
+            result = c.get('masterHostMapping');
           });
-          var result = c.get('masterHostMapping');
-          expect(result.length).to.equal(test.e.length);
-          result.forEach(function (r, i) {
-            expect(r.get('host_name')).to.equal(test.e[i].host_name);
-            expect(r.get('masterServices.length')).to.equal(test.e[i].masterServices.length);
-            expect(r.get('hostInfo')).to.be.an.object;
+
+          it('all needed hosts are mapped', function () {
+            expect(result.length).to.equal(test.e.length);
+          });
+
+          it('all needed hosts have valid data', function () {
+            result.forEach(function (r, i) {
+              expect(r.get('host_name')).to.equal(test.e[i].host_name);
+              expect(r.get('masterServices.length')).to.equal(test.e[i].masterServices.length);
+              expect(r.get('hostInfo')).to.be.an.object;
+            });
           });
         });
       });
@@ -959,13 +1016,20 @@ describe('App.WizardStep5Controller', function () {
           }
         }
       ]).forEach(function (test, i) {
-        it('test #' + i, function () {
-          sinon.stub(App.StackServiceComponent, 'find', function () {
-            return test.stackServiceComponents;
+        describe('test #' + i, function () {
+
+          beforeEach(function () {
+            sinon.stub(App.StackServiceComponent, 'find', function () {
+              return test.stackServiceComponents;
+            });
+            c.set('mastersToMove', test.mastersToMove);
+            c.set('content', {controllerName: test.controllerName});
           });
-          c.set('mastersToMove', test.mastersToMove);
-          c.set('content', {controllerName: test.controllerName});
-          expect(c.createComponentInstallationObject(test.fullComponent, test.hostName, test.savedComponent)).to.eql(test.e);
+
+          it('component-object is valid', function () {
+            expect(c.createComponentInstallationObject(test.fullComponent, test.hostName, test.savedComponent)).to.eql(test.e);
+          });
+
         });
       });
 
@@ -1122,7 +1186,7 @@ describe('App.WizardStep5Controller', function () {
       App.HostComponent.find.restore();
     });
 
-    it('should map messages to generalErrorMessages, generalWarningMessages', function() {
+    describe('should map messages to generalErrorMessages, generalWarningMessages', function() {
 
       var data = [
           {
@@ -1159,14 +1223,31 @@ describe('App.WizardStep5Controller', function () {
           Em.Object.create({selectedHost: 'h2', component_name: 'c2'})
         ];
 
-      c.set('servicesMasters', servicesMasters);
-      c.updateValidationsSuccessCallback({resources: [{items: data}]});
+      beforeEach(function () {
+        c.set('servicesMasters', servicesMasters);
+        c.updateValidationsSuccessCallback({resources: [{items: data}]});
+      });
+
+      it('submitDisabled is false', function () {
+        expect(c.get('submitDisabled')).to.equal(false);
+      });
+
+      it('errorMessage for c1 is `m1`', function () {
+        expect(c.get('servicesMasters').findProperty('component_name', 'c1').get('errorMessage')).to.equal('m1');
+      });
+
+      it('errorMessage for c2 is `m2`', function () {
+        expect(c.get('servicesMasters').findProperty('component_name', 'c2').get('warnMessage')).to.equal('m2');
+      });
+
+      it('no general errors', function () {
+        expect(c.get('generalErrorMessages')).to.be.empty;
+      });
+
+      it('no general warnings', function () {
+        expect(c.get('generalWarningMessages')).to.be.empty;
+      });
 
-      expect(c.get('submitDisabled')).to.equal(false);
-      expect(c.get('servicesMasters').findProperty('component_name', 'c1').get('errorMessage')).to.equal('m1');
-      expect(c.get('servicesMasters').findProperty('component_name', 'c2').get('warnMessage')).to.equal('m2');
-      expect(c.get('generalErrorMessages')).to.be.empty;
-      expect(c.get('generalWarningMessages')).to.be.empty;
     });
 
   });

+ 29 - 12
ambari-web/test/controllers/wizard/step6_test.js

@@ -671,7 +671,7 @@ describe('App.WizardStep6Controller', function () {
   });
 
   describe('#clearError', function () {
-    it('true if is one of checkboxes checked false', function () {
+    it('both checkboxes are checked', function () {
       var hosts = Em.A([
         Em.Object.create({
           checkboxes: Em.A([
@@ -696,6 +696,7 @@ describe('App.WizardStep6Controller', function () {
       controller.clearError();
       expect(controller.get('errorMessage')).to.equal('');
     });
+
     it('true if is one of checkboxes checked false', function () {
       var hosts = Em.A([
         Em.Object.create({
@@ -1553,20 +1554,36 @@ describe('App.WizardStep6Controller', function () {
     });
 
     cases.forEach(function (item) {
-      it(item.controllerName, function () {
-        controller.set('hosts', item.hosts);
-        controller.set('content.controllerName', item.controllerName);
-        controller.callServerSideValidation();
-        expect(controller.get('content.recommendationsHostGroups.blueprint.host_groups.length')).to.equal(expectedHostGroups.length);
-        expect(controller.get('content.recommendationsHostGroups.blueprint_cluster_binding.host_groups.length')).to.equal(expectedHostGroups.length);
-        controller.get('content.recommendationsHostGroups.blueprint.host_groups').forEach(function (group, index) {
-          expect(group.components.mapProperty('name').sort()).to.eql(item.expected[index]);
+      describe(item.controllerName, function () {
+
+        beforeEach(function () {
+          controller.set('hosts', item.hosts);
+          controller.set('content.controllerName', item.controllerName);
+          controller.callServerSideValidation();
         });
+
+        it('blueprint.host_groups count is correct', function () {
+          expect(controller.get('content.recommendationsHostGroups.blueprint.host_groups.length')).to.equal(expectedHostGroups.length);
+        });
+
+        it('blueprint_cluster_binding.host_groups count is correct', function () {
+          expect(controller.get('content.recommendationsHostGroups.blueprint_cluster_binding.host_groups.length')).to.equal(expectedHostGroups.length);
+        });
+
+        it('components are valid for each group', function () {
+          controller.get('content.recommendationsHostGroups.blueprint.host_groups').forEach(function (group, index) {
+            expect(group.components.mapProperty('name').sort()).to.eql(item.expected[index]);
+          });
+        });
+
         expectedHostGroups.forEach(function (group) {
-          var bpGroup = controller.get('content.recommendationsHostGroups.blueprint_cluster_binding.host_groups').findProperty('name', group.name);
-          expect(bpGroup.hosts).to.have.length(1);
-          expect(bpGroup.hosts[0].fqdn).to.equal(group.fqdn);
+          it(group.name, function () {
+            var bpGroup = controller.get('content.recommendationsHostGroups.blueprint_cluster_binding.host_groups').findProperty('name', group.name);
+            expect(bpGroup.hosts).to.have.length(1);
+            expect(bpGroup.hosts[0].fqdn).to.equal(group.fqdn);
+          });
         });
+
       });
     });
 

+ 223 - 132
ambari-web/test/controllers/wizard/step7_test.js

@@ -674,6 +674,7 @@ describe('App.InstallerStep7Controller', function () {
   });
 
   describe('#_setOverrides', function () {
+
     it('shouldn\'t update config if no selectedConfigGroup', function () {
       installerStep7Controller.reopen({
         selectedConfigGroup: null
@@ -682,6 +683,7 @@ describe('App.InstallerStep7Controller', function () {
       var updatedConfig = installerStep7Controller._setOverrides(config, []);
       expect(updatedConfig.get('overrides')).to.be.null;
     });
+
     it('no overrideToAdd', function () {
       var isDefault = true,
         name = 'n1',
@@ -702,6 +704,7 @@ describe('App.InstallerStep7Controller', function () {
       expect(updatedConfig.get('overrides').everyProperty('isEditable', !isDefault)).to.equal(true);
       expect(updatedConfig.get('overrides').everyProperty('parentSCP.flag', 'flag')).to.equal(true);
     });
+
     it('overrideToAdd exists', function () {
       var isDefault = true,
         name = 'n1',
@@ -727,6 +730,7 @@ describe('App.InstallerStep7Controller', function () {
   });
 
   describe('#switchConfigGroupConfigs', function () {
+
     it('if selectedConfigGroup is null, serviceConfigs shouldn\'t be changed', function () {
       installerStep7Controller.reopen({
         selectedConfigGroup: null,
@@ -739,7 +743,9 @@ describe('App.InstallerStep7Controller', function () {
       installerStep7Controller.switchConfigGroupConfigs();
       expect(installerStep7Controller.get('serviceConfigs.configs').everyProperty('overrides.length', 0)).to.equal(true);
     });
-    it('should set configs for serviceConfigs', function () {
+
+    describe('should set configs for serviceConfigs', function () {
+
       var configGroups = [
         Em.Object.create({
           properties: [
@@ -748,27 +754,44 @@ describe('App.InstallerStep7Controller', function () {
           ]
         })
       ];
-      sinon.stub(installerStep7Controller, '_getDisplayedConfigGroups', function () {
-        return configGroups;
+
+      beforeEach(function () {
+        sinon.stub(installerStep7Controller, '_getDisplayedConfigGroups', function () {
+          return configGroups;
+        });
+        sinon.stub(installerStep7Controller, '_setEditableValue', function (config) {
+          config.set('isEditable', true);
+          return config;
+        });
+        installerStep7Controller.reopen({
+          selectedConfigGroup: Em.Object.create({isDefault: true, name: 'g1'}),
+          content: {services: []},
+          selectedService: {configs: Em.A([Em.Object.create({name: 'g1', overrides: [], properties: []}), Em.Object.create({name: 'g2', overrides: []})])},
+          serviceConfigs: {configs: [Em.Object.create({name: 'g1'})]}
+        });
+        installerStep7Controller.switchConfigGroupConfigs();
+        this.configs = installerStep7Controller.get('selectedService.configs');
       });
-      sinon.stub(installerStep7Controller, '_setEditableValue', function (config) {
-        config.set('isEditable', true);
-        return config;
+
+      afterEach(function () {
+        installerStep7Controller._getDisplayedConfigGroups.restore();
+        installerStep7Controller._setEditableValue.restore();
       });
-      installerStep7Controller.reopen({
-        selectedConfigGroup: Em.Object.create({isDefault: true, name: 'g1'}),
-        content: {services: []},
-        selectedService: {configs: Em.A([Em.Object.create({name: 'g1', overrides: [], properties: []}), Em.Object.create({name: 'g2', overrides: []})])},
-        serviceConfigs: {configs: [Em.Object.create({name: 'g1'})]}
+
+      it('g1 has 1 override', function () {
+        expect(this.configs.findProperty('name', 'g1').get('overrides').length).to.equal(1);
       });
-      installerStep7Controller.switchConfigGroupConfigs();
-      var configs = installerStep7Controller.get('selectedService.configs');
-      expect(configs.findProperty('name', 'g1').get('overrides').length).to.equal(1);
-      expect(configs.findProperty('name', 'g2').get('overrides').length).to.equal(1);
-      expect(configs.everyProperty('isEditable', true)).to.equal(true);
-      installerStep7Controller._getDisplayedConfigGroups.restore();
-      installerStep7Controller._setEditableValue.restore();
+
+      it('g2 has 1 override', function () {
+        expect(this.configs.findProperty('name', 'g2').get('overrides').length).to.equal(1);
+      });
+
+      it('all configs are editable', function () {
+        expect(this.configs.everyProperty('isEditable', true)).to.equal(true);
+      });
+
     });
+
   });
 
   describe('#selectProperService', function () {
@@ -792,23 +815,32 @@ describe('App.InstallerStep7Controller', function () {
           e: 'n3'
         }
       ]).forEach(function (test) {
-        it(test.name, function () {
-          sinon.stub(installerStep7Controller, 'selectedServiceObserver', Em.K);
-          installerStep7Controller.reopen({
-            wizardController: Em.Object.create({
-              name: test.name
-            }),
-            stepConfigs: test.stepConfigs
+        describe(test.name, function () {
+
+          beforeEach(function () {
+            sinon.stub(installerStep7Controller, 'selectedServiceObserver', Em.K);
+            installerStep7Controller.reopen({
+              wizardController: Em.Object.create({
+                name: test.name
+              }),
+              stepConfigs: test.stepConfigs
+            });
+            installerStep7Controller.selectProperService();
+          });
+
+          afterEach(function () {
+            installerStep7Controller.selectedServiceObserver.restore();
+          });
+
+          it('selected service name is valid', function () {
+            expect(installerStep7Controller.get('selectedService.name')).to.equal(test.e);
           });
-          installerStep7Controller.selectProperService();
-          expect(installerStep7Controller.get('selectedService.name')).to.equal(test.e);
-          installerStep7Controller.selectedServiceObserver.restore();
         });
       });
   });
 
   describe.skip('#setStepConfigs', function () {
-
+    var serviceConfigs;
     beforeEach(function () {
       installerStep7Controller.reopen({
         content: {services: []},
@@ -818,45 +850,39 @@ describe('App.InstallerStep7Controller', function () {
           }
         })
       });
+      sinon.stub(installerStep7Controller, 'renderConfigs', function () {
+        return serviceConfigs;
+      });
+      this.stub = sinon.stub(App, 'get');
     });
 
     afterEach(function () {
       installerStep7Controller.renderConfigs.restore();
+      App.get.restore();
     });
 
     it('if wizard isn\'t addService, should set output of installerStep7Controller.renderConfigs', function () {
-      var serviceConfigs = Em.A([
+      serviceConfigs = Em.A([
         {serviceName:'HDFS', configs: []},
         {}
       ]);
-      sinon.stub(installerStep7Controller, 'renderConfigs', function () {
-        return serviceConfigs;
-      });
       installerStep7Controller.set('wizardController.name', 'installerController');
       installerStep7Controller.setStepConfigs([], []);
       expect(installerStep7Controller.get('stepConfigs')).to.eql(serviceConfigs);
     });
 
     it('addServiceWizard used', function () {
-      var serviceConfigs = Em.A([Em.Object.create({serviceName: 'HDFS', configs: []}), Em.Object.create({serviceName: 's2'})]);
+      serviceConfigs = Em.A([Em.Object.create({serviceName: 'HDFS', configs: []}), Em.Object.create({serviceName: 's2'})]);
       installerStep7Controller.set('wizardController.name', 'addServiceController');
       installerStep7Controller.reopen({selectedServiceNames: ['s2']});
-      sinon.stub(installerStep7Controller, 'renderConfigs', function () {
-        return serviceConfigs;
-      });
       installerStep7Controller.setStepConfigs([], []);
       expect(installerStep7Controller.get('stepConfigs').everyProperty('showConfig', true)).to.equal(true);
       expect(installerStep7Controller.get('stepConfigs').findProperty('serviceName', 's2').get('selected')).to.equal(true);
     });
 
     it('addServiceWizard used, HA enabled', function () {
-      sinon.stub(App, 'get', function (k) {
-        if (k === 'isHaEnabled') {
-          return true;
-        }
-        return Em.get(App, k);
-      });
-      var serviceConfigs = Em.A([
+      this.stub.withArgs('isHaEnabled').returns(true);
+      serviceConfigs = Em.A([
         Em.Object.create({
           serviceName: 'HDFS',
           configs: [
@@ -871,23 +897,18 @@ describe('App.InstallerStep7Controller', function () {
       );
       installerStep7Controller.set('wizardController.name', 'addServiceController');
       installerStep7Controller.reopen({selectedServiceNames: ['HDFS', 's2']});
-      sinon.stub(installerStep7Controller, 'renderConfigs', function () {
-        return serviceConfigs;
-      });
       installerStep7Controller.setStepConfigs([], []);
       expect(installerStep7Controller.get('stepConfigs').everyProperty('showConfig', true)).to.equal(true);
       expect(installerStep7Controller.get('stepConfigs').findProperty('serviceName', 'HDFS').get('selected')).to.equal(true);
       expect(installerStep7Controller.get('stepConfigs').findProperty('serviceName', 'HDFS').get('configs').length).to.equal(5);
-      App.get.restore();
     });
 
     it('not windows stack', function () {
 
-      var s = sinon.stub(App, 'get');
-      s.withArgs('isHadoopWindowsStack').returns(false);
-      s.withArgs('isHaEnabled').returns(false);
+      this.stub.withArgs('isHadoopWindowsStack').returns(false);
+      this.stub.withArgs('isHaEnabled').returns(false);
 
-      var serviceConfigs = Em.A([
+      serviceConfigs = Em.A([
         Em.Object.create({
           serviceName: 'HDFS',
           configs: [
@@ -897,26 +918,17 @@ describe('App.InstallerStep7Controller', function () {
         }),
         Em.Object.create({serviceName: 's2'})]
       );
-
       installerStep7Controller.reopen({selectedServiceNames: ['HDFS', 's2']});
-      sinon.stub(installerStep7Controller, 'renderConfigs', function () {
-        return serviceConfigs;
-      });
       installerStep7Controller.setStepConfigs([], []);
-
       expect(installerStep7Controller.get('stepConfigs').findProperty('serviceName', 'HDFS').get('configs').length).to.equal(2);
-
-      s.restore();
-
     });
 
     it('windows stack', function () {
 
-      var s = sinon.stub(App, 'get');
-      s.withArgs('isHadoopWindowsStack').returns(true);
-      s.withArgs('isHaEnabled').returns(false);
+      this.stub.withArgs('isHadoopWindowsStack').returns(true);
+      this.stub.withArgs('isHaEnabled').returns(false);
 
-      var serviceConfigs = Em.A([
+      serviceConfigs = Em.A([
         Em.Object.create({
           serviceName: 'HDFS',
           configs: [
@@ -929,15 +941,10 @@ describe('App.InstallerStep7Controller', function () {
 
       installerStep7Controller.reopen({selectedServiceNames: ['HDFS', 's2']});
       installerStep7Controller.set('installedServiceNames',['HDFS', 's2', 's3']);
-      sinon.stub(installerStep7Controller, 'renderConfigs', function () {
-        return serviceConfigs;
-      });
       installerStep7Controller.setStepConfigs([], []);
 
       expect(installerStep7Controller.get('stepConfigs').findProperty('serviceName', 'HDFS').get('configs').length).to.equal(2);
 
-      s.restore();
-
     });
 
   });
@@ -946,6 +953,10 @@ describe('App.InstallerStep7Controller', function () {
     beforeEach(function () {
       sinon.stub(installerStep7Controller, 'loadConfigGroups', Em.K);
       sinon.stub(installerStep7Controller, 'loadInstalledServicesConfigGroups', Em.K);
+      sinon.stub(App, 'get', function (k) {
+        if (k === 'supports.hostOverridesInstaller') return false;
+        return Em.get(App, k);
+      });
     });
     afterEach(function () {
       installerStep7Controller.loadConfigGroups.restore();
@@ -980,29 +991,37 @@ describe('App.InstallerStep7Controller', function () {
           }
         }
       ]).forEach(function (test) {
-        it(test.m, function () {
-          sinon.stub(App, 'get', function (k) {
-            if (k === 'supports.hostOverridesInstaller') return test.hostOverridesInstaller;
-            return Em.get(App, k);
-          });
-          installerStep7Controller.reopen({
-            installedServiceNames: test.installedServiceNames,
-            wizardController: {
-              areInstalledConfigGroupsLoaded: test.areInstalledConfigGroupsLoaded
-            }
+        describe(test.m, function () {
+
+          beforeEach(function () {
+            installerStep7Controller.reopen({
+              installedServiceNames: test.installedServiceNames,
+              wizardController: {
+                areInstalledConfigGroupsLoaded: test.areInstalledConfigGroupsLoaded
+              }
+            });
+            installerStep7Controller.checkHostOverrideInstaller();
           });
-          installerStep7Controller.checkHostOverrideInstaller();
+
           if (test.e.loadConfigGroups) {
-            expect(installerStep7Controller.loadConfigGroups.calledOnce).to.equal(true);
+            it('loadConfigGroups is called once', function () {
+              expect(installerStep7Controller.loadConfigGroups.calledOnce).to.equal(true);
+            });
           }
           else {
-            expect(installerStep7Controller.loadConfigGroups.called).to.equal(false);
+            it('loadConfigGroups is not called', function () {
+              expect(installerStep7Controller.loadConfigGroups.called).to.equal(false);
+            });
           }
           if (test.e.loadInstalledServicesConfigGroups) {
-            expect(installerStep7Controller.loadInstalledServicesConfigGroups.calledOnce).to.equal(true);
+            it('loadInstalledServicesConfigGroups is called once', function () {
+              expect(installerStep7Controller.loadInstalledServicesConfigGroups.calledOnce).to.equal(true);
+            });
           }
           else {
-            expect(installerStep7Controller.loadInstalledServicesConfigGroups.called).to.equal(false);
+            it('loadInstalledServicesConfigGroups is not called', function () {
+              expect(installerStep7Controller.loadInstalledServicesConfigGroups.called).to.equal(false);
+            });
           }
         });
       });
@@ -1081,7 +1100,9 @@ describe('App.InstallerStep7Controller', function () {
           }
         }
       });
+      installerStep7Controller.applyServicesConfigs([{name: 'configs'}]);
     });
+
     afterEach(function () {
       App.config.fileConfigsIntoTextarea.restore();
       installerStep7Controller.loadServerSideConfigsRecommendations.restore();
@@ -1091,11 +1112,16 @@ describe('App.InstallerStep7Controller', function () {
       App.StackService.find.restore();
     });
 
-    it('should run some methods' , function () {
-     installerStep7Controller.applyServicesConfigs([{name: 'configs'}]);
+    it('loadServerSideConfigsRecommendations is called once' , function () {
      expect(installerStep7Controller.loadServerSideConfigsRecommendations.calledOnce).to.equal(true);
+    });
+    it('isRecommendedLoaded is true' , function () {
      expect(installerStep7Controller.get('isRecommendedLoaded')).to.equal(true);
+    });
+    it('checkHostOverrideInstalleris called once' , function () {
      expect(installerStep7Controller.checkHostOverrideInstaller.calledOnce).to.equal(true);
+    });
+    it('selectProperServiceis called once' , function () {
      expect(installerStep7Controller.selectProperService.calledOnce).to.equal(true);
     });
 
@@ -1176,44 +1202,77 @@ describe('App.InstallerStep7Controller', function () {
       expect(serviceConfigProperty.get('overrides')).to.eql(Em.A([]));
     });
 
-    it('host overrides not supported', function () {
+    describe('host overrides not supported', function () {
       var serviceConfigProperty = Em.Object.create({
         overrides: [
           {value: 'new value'}
         ]
-      }), component = Em.Object.create({selectedConfigGroup: {isDefault: false}});
-      installerStep7Controller._updateOverridesForConfig(serviceConfigProperty, component);
-      expect(serviceConfigProperty.get('overrides').length).to.equal(1);
-      expect(serviceConfigProperty.get('overrides.firstObject.value')).to.equal('new value');
-      expect(serviceConfigProperty.get('overrides.firstObject.isOriginalSCP')).to.equal(false);
-      expect(serviceConfigProperty.get('overrides.firstObject.parentSCP')).to.eql(serviceConfigProperty);
-    });
+      });
+      var component = Em.Object.create({selectedConfigGroup: {isDefault: false}});
 
-    it('host overrides supported', function () {
-      sinon.stub(App, 'get', function (k) {
-        if (k === 'supports.hostOverrides') return true;
-        return Em.get(App, k);
+      beforeEach(function () {
+        installerStep7Controller._updateOverridesForConfig(serviceConfigProperty, component);
       });
-      var serviceConfigProperty = Em.Object.create({
+      it('there is 1 override', function () {
+        expect(serviceConfigProperty.get('overrides').length).to.equal(1);
+      });
+      it('override value is valid', function () {
+        expect(serviceConfigProperty.get('overrides.firstObject.value')).to.equal('new value');
+      });
+      it('override is not original SCP', function () {
+        expect(serviceConfigProperty.get('overrides.firstObject.isOriginalSCP')).to.equal(false);
+      });
+      it('override is linked to parent', function () {
+        expect(serviceConfigProperty.get('overrides.firstObject.parentSCP')).to.eql(serviceConfigProperty);
+      });
+    });
+
+    describe('host overrides supported', function () {
+      var serviceConfigProperty;
+      var component;
+      beforeEach(function () {
+        sinon.stub(App, 'get', function (k) {
+          if (k === 'supports.hostOverrides') return true;
+          return Em.get(App, k);
+        });
+        serviceConfigProperty = Em.Object.create({
           overrides: [
             {value: 'new value', group: Em.Object.create({name: 'n1'})}
           ]
-        }),
+        });
         component = Em.Object.create({
           selectedConfigGroup: {isDefault: true},
           configGroups: Em.A([
             Em.Object.create({name: 'n1', properties: []})
           ])
         });
-      installerStep7Controller._updateOverridesForConfig(serviceConfigProperty, component);
-      App.get.restore();
-      expect(serviceConfigProperty.get('overrides').length).to.equal(1);
-      expect(serviceConfigProperty.get('overrides.firstObject.value')).to.equal('new value');
-      expect(serviceConfigProperty.get('overrides.firstObject.isOriginalSCP')).to.equal(false);
-      expect(serviceConfigProperty.get('overrides.firstObject.parentSCP')).to.eql(serviceConfigProperty);
-      expect(component.get('configGroups.firstObject.properties').length).to.equal(1);
-      expect(component.get('configGroups.firstObject.properties.firstObject.isEditable')).to.equal(false);
-      expect(component.get('configGroups.firstObject.properties.firstObject.group')).to.be.object;
+        installerStep7Controller._updateOverridesForConfig(serviceConfigProperty, component);
+      });
+
+      afterEach(function () {
+        App.get.restore();
+      });
+      it('there is 1 override', function () {
+        expect(serviceConfigProperty.get('overrides').length).to.equal(1);
+      });
+      it('override.value is valid', function () {
+        expect(serviceConfigProperty.get('overrides.firstObject.value')).to.equal('new value');
+      });
+      it('override is not original SCP', function () {
+        expect(serviceConfigProperty.get('overrides.firstObject.isOriginalSCP')).to.equal(false);
+      });
+      it('override.parentSCP is valid', function () {
+        expect(serviceConfigProperty.get('overrides.firstObject.parentSCP')).to.eql(serviceConfigProperty);
+      });
+      it('there is 1 property in the config group', function () {
+        expect(component.get('configGroups.firstObject.properties').length).to.equal(1);
+      });
+      it('property in the config group is not editable', function () {
+        expect(component.get('configGroups.firstObject.properties.firstObject.isEditable')).to.equal(false);
+      });
+      it('property in the config group is linked to it', function () {
+        expect(component.get('configGroups.firstObject.properties.firstObject.group')).to.be.object;
+      });
     });
 
   });
@@ -1259,14 +1318,27 @@ describe('App.InstallerStep7Controller', function () {
       ],
       installedServiceNames = ['HBASE', 'AMBARI_METRICS'];
 
-    it('should handle properties with the same name', function () {
-      controller.setInstalledServiceConfigs(configs, configsByTags, installedServiceNames);
-      var properties = configs.filterProperty('name', 'hbase.client.scanner.caching');
-      expect(properties).to.have.length(2);
-      expect(properties.findProperty('filename', 'hbase-site.xml').value).to.equal('1500');
-      expect(properties.findProperty('filename', 'hbase-site.xml').savedValue).to.equal('1500');
-      expect(properties.findProperty('filename', 'ams-hbase-site.xml').value).to.equal('2500');
-      expect(properties.findProperty('filename', 'ams-hbase-site.xml').savedValue).to.equal('2500');
+    describe('should handle properties with the same name', function () {
+      var properties;
+      beforeEach(function () {
+        controller.setInstalledServiceConfigs(configs, configsByTags, installedServiceNames);
+        properties = configs.filterProperty('name', 'hbase.client.scanner.caching');
+      });
+      it('there are 2 properties', function () {
+        expect(properties).to.have.length(2);
+      });
+      it('hbase-site/ value is valid', function () {
+        expect(properties.findProperty('filename', 'hbase-site.xml').value).to.equal('1500');
+      });
+      it('hbase-site/ savedValue is valid', function () {
+        expect(properties.findProperty('filename', 'hbase-site.xml').savedValue).to.equal('1500');
+      });
+      it('ams-hbase-site/ value is valid', function () {
+        expect(properties.findProperty('filename', 'ams-hbase-site.xml').value).to.equal('2500');
+      });
+      it('ams-hbase-site/ savedValue is valid', function () {
+        expect(properties.findProperty('filename', 'ams-hbase-site.xml').savedValue).to.equal('2500');
+      });
     });
 
   });
@@ -1370,13 +1442,22 @@ describe('App.InstallerStep7Controller', function () {
     });
 
     cases.forEach(function (item) {
-      it(item.title, function () {
-        var popup = installerStep7Controller.showDatabaseConnectionWarningPopup(serviceNames, dfd);
-        expect(popup.get('body')).to.equal(Em.I18n.t('installer.step7.popup.database.connection.body').format(bodyMessage));
-        popup[item.method]();
-        expect(testObject.isResolved).to.equal(item.isResolved);
-        expect(testObject.isRejected).to.equal(item.isRejected);
-        expect(installerStep7Controller.get('submitButtonClicked')).to.equal(item.submitButtonClicked);
+      describe(item.title, function () {
+        var popup;
+        beforeEach(function () {
+          popup = installerStep7Controller.showDatabaseConnectionWarningPopup(serviceNames, dfd);
+        });
+
+        it('popup body is valid', function () {
+          expect(popup.get('body')).to.equal(Em.I18n.t('installer.step7.popup.database.connection.body').format(bodyMessage));
+        });
+
+        it('after ' + item.method + ' execution', function () {
+          popup[item.method]();
+          expect(testObject.isResolved).to.equal(item.isResolved);
+          expect(testObject.isRejected).to.equal(item.isRejected);
+          expect(installerStep7Controller.get('submitButtonClicked')).to.equal(item.submitButtonClicked);
+        });
       });
     });
 
@@ -1600,10 +1681,12 @@ describe('App.InstallerStep7Controller', function () {
 
   describe('#showOozieDerbyWarning', function() {
     var controller;
+
     beforeEach(function() {
       controller = App.WizardStep7Controller.create({});
       sinon.stub(App.ModalPopup, 'show', Em.K);
     });
+
     afterEach(function() {
       App.ModalPopup.show.restore();
     });
@@ -1628,15 +1711,23 @@ describe('App.InstallerStep7Controller', function () {
         m: 'Oozie selected, mysql database used, warning popup should be sk'
       }
     ]).forEach(function(test) {
-      it(test.m, function() {
-        var callback = sinon.spy();
-        sinon.stub(controller, 'findConfigProperty').returns(Em.Object.create({ value: test.databaseType}));
-        controller.reopen({
-          selectedServiceNames: test.selectedServiceNames
+      describe(test.m, function() {
+
+        beforeEach(function () {
+          sinon.stub(controller, 'findConfigProperty').returns(Em.Object.create({ value: test.databaseType}));
+          controller.reopen({
+            selectedServiceNames: test.selectedServiceNames
+          });
+          controller.showOozieDerbyWarningPopup(Em.K);
+        });
+
+        afterEach(function () {
+          controller.findConfigProperty.restore();
+        });
+
+        it('modal popup is shown needed number of times', function () {
+          expect(App.ModalPopup.show.calledOnce).to.equal(test.e);
         });
-        controller.showOozieDerbyWarningPopup(callback);
-        controller.findConfigProperty.restore();
-        expect(App.ModalPopup.show.calledOnce).to.equal(test.e);
       });
     });
   });

+ 245 - 193
ambari-web/test/controllers/wizard/step8_test.js

@@ -1170,46 +1170,6 @@ describe('App.WizardStep8Controller', function () {
 
   });
 
-  describe('#createSelectedServicesData', function() {
-    it('should reformat provided data', function() {
-      var selectedServices = [
-        Em.Object.create({serviceName: 's1'}),
-        Em.Object.create({serviceName: 's2'}),
-        Em.Object.create({serviceName: 's3'})
-      ];
-      var expected = [
-        {"ServiceInfo": { "service_name": 's1' }},
-        {"ServiceInfo": { "service_name": 's2' }},
-        {"ServiceInfo": { "service_name": 's3' }}
-      ];
-      installerStep8Controller.reopen({selectedServices: selectedServices});
-      var createdData = installerStep8Controller.createSelectedServicesData();
-      expect(createdData).to.eql(expected);
-    });
-  });
-
-  describe('#createRegisterHostData', function() {
-    it('should return empty data if no hosts', function() {
-      sinon.stub(installerStep8Controller, 'getRegisteredHosts', function() {return [];});
-      expect(installerStep8Controller.createRegisterHostData()).to.eql([]);
-      installerStep8Controller.getRegisteredHosts.restore();
-    });
-    it('should return computed data', function() {
-      var data = [
-        {isInstalled: false, hostName: 'h1'},
-        {isInstalled: true, hostName: 'h2'},
-        {isInstalled: false, hostName: 'h3'}
-      ];
-      var expected = [
-        {"Hosts": { "host_name": 'h1'}},
-        {"Hosts": { "host_name": 'h3'}}
-      ];
-      sinon.stub(installerStep8Controller, 'getRegisteredHosts', function() {return data;});
-      expect(installerStep8Controller.createRegisterHostData()).to.eql(expected);
-      installerStep8Controller.getRegisteredHosts.restore();
-    });
-  });
-
   describe('#createStormSiteObj', function() {
     it('should replace quote \'"\' to "\'" for some properties', function() {
       var configs = [
@@ -1247,11 +1207,18 @@ describe('App.WizardStep8Controller', function () {
   });
 
   describe('#ajaxQueueFinished', function() {
-    it('should call App.router.next', function() {
+
+    beforeEach(function () {
       sinon.stub(App.router, 'send', Em.K);
+    });
+
+    afterEach(function () {
+      App.router.send.restore();
+    });
+
+    it('should call App.router.next', function() {
       installerStep8Controller.ajaxQueueFinished();
       expect(App.router.send.calledWith('next')).to.equal(true);
-      App.router.send.restore();
     });
   });
 
@@ -1423,43 +1390,60 @@ describe('App.WizardStep8Controller', function () {
 
     describe('#createSelectedServices', function() {
 
+      var data;
+
+      beforeEach(function () {
+        sinon.stub(installerStep8Controller, 'createSelectedServicesData', function () {
+          return data;
+        });
+      });
+
+      afterEach(function () {
+        installerStep8Controller.createSelectedServicesData.restore();
+      });
+
       it('shouldn\'t do nothing if no data', function() {
-        sinon.stub(installerStep8Controller, 'createSelectedServicesData', function() {return [];});
+        data = [];
         installerStep8Controller.createSelectedServices();
         expect(installerStep8Controller.addRequestToAjaxQueue.called).to.equal(false);
-        installerStep8Controller.createSelectedServicesData.restore();
       });
 
       it('should call addRequestToAjaxQueue with computed data', function() {
-        var data = [
+        data = [
           {"ServiceInfo": { "service_name": 's1' }},
           {"ServiceInfo": { "service_name": 's2' }},
           {"ServiceInfo": { "service_name": 's3' }}
         ];
-        sinon.stub(installerStep8Controller, 'createSelectedServicesData', function() {return data;});
         installerStep8Controller.createSelectedServices();
         expect(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data.data).to.equal(JSON.stringify(data));
-        installerStep8Controller.createSelectedServicesData.restore();
       });
 
     });
 
     describe('#registerHostsToCluster', function() {
+      var data;
+      beforeEach(function () {
+        sinon.stub(installerStep8Controller, 'createRegisterHostData', function () {
+          return data;
+        });
+      });
+
+      afterEach(function () {
+        installerStep8Controller.createRegisterHostData.restore();
+      });
+
       it('shouldn\'t do nothing if no data', function() {
-        sinon.stub(installerStep8Controller, 'createRegisterHostData', function() {return [];});
+        data = [];
         installerStep8Controller.registerHostsToCluster();
         expect(installerStep8Controller.addRequestToAjaxQueue.called).to.equal(false);
-        installerStep8Controller.createRegisterHostData.restore();
       });
       it('should call addRequestToAjaxQueue with computed data', function() {
-        var data = [
+        data = [
           {"Hosts": { "host_name": 'h1'}},
           {"Hosts": { "host_name": 'h3'}}
         ];
-        sinon.stub(installerStep8Controller, 'createRegisterHostData', function() {return data;});
         installerStep8Controller.registerHostsToCluster();
         expect(installerStep8Controller.addRequestToAjaxQueue.args[0][0].data.data).to.equal(JSON.stringify(data));
-        installerStep8Controller.createRegisterHostData.restore();
       });
     });
 
@@ -1646,98 +1630,107 @@ describe('App.WizardStep8Controller', function () {
         installerStep8Controller.registerHostsToComponent.restore();
       });
 
-      it('should add components with isRequiredOnAllHosts == true (1)', function() {
-        installerStep8Controller.reopen({
-          getRegisteredHosts: function() {
-            return [{hostName: 'h1'}, {hostName: 'h2'}];
-          },
-          content: {
-            services: Em.A([
-              Em.Object.create({
-                serviceName: 'ANYSERVICE', isSelected: true, isInstalled: false, serviceComponents: [
-                  // set isRequiredOnAllHosts = true for slave and client
-                  Em.Object.create({
-                    componentName: 'ANYSERVICE_MASTER',
-                    isMaster: true,
-                    isRequiredOnAllHosts: false
-                  }),
-                  Em.Object.create({
-                    componentName: 'ANYSERVICE_SLAVE',
-                    isSlave: true,
-                    isRequiredOnAllHosts: true
-                  }),
-                  Em.Object.create({
-                    componentName: 'ANYSERVICE_SLAVE2',
-                    isSlave: true,
-                    isRequiredOnAllHosts: true
-                  }),
-                  Em.Object.create({
-                    componentName: 'ANYSERVICE_CLIENT',
-                    isClient: true,
-                    isRequiredOnAllHosts: true
-                  })
-                ]
-              })
-            ]),
-            masterComponentHosts: Em.A([
-              Em.Object.create({
-                componentName: 'ANYSERVICE_MASTER',
-                component: 'ANYSERVICE_MASTER',
-                hosts: Em.A([
-                  Em.Object.create({hostName: 'h1', isInstalled: true})
-                ])
-              })
-            ]),
-            slaveComponentHosts: Em.A([
-              Em.Object.create({
-                componentName: 'ANYSERVICE_SLAVE',
-                hosts: Em.A([
-                  Em.Object.create({hostName: 'h1', isInstalled: false}),
-                  Em.Object.create({hostName: 'h2', isInstalled: false})
-                ])
-              }),
-              Em.Object.create({
-                componentName: 'ANYSERVICE_SLAVE2',
-                hosts: Em.A([
-                  Em.Object.create({hostName: 'h1', isInstalled: false}),
-                  Em.Object.create({hostName: 'h2', isInstalled: false})
-                ]),
-              }),
-              Em.Object.create({
-                componentName: 'CLIENT',
-                hosts: Em.A([
-                  Em.Object.create({hostName: 'h1', isInstalled: false}),
-                  Em.Object.create({hostName: 'h2', isInstalled: false})
-                ])
-              })
-            ]),
-            clients: Em.A([
-              Em.Object.create({
-                component_name: 'ANYSERVICE_CLIENT',
-                isInstalled: false,
-                hosts: Em.A([
-                  Em.Object.create({hostName: 'h1', isInstalled: false}),
-                  Em.Object.create({hostName: 'h2', isInstalled: false})
-                ])
-              })
-            ])
-          }
+      describe('should add components with isRequiredOnAllHosts == true (1)', function() {
+
+        beforeEach(function () {
+          installerStep8Controller.reopen({
+            getRegisteredHosts: function() {
+              return [{hostName: 'h1'}, {hostName: 'h2'}];
+            },
+            content: {
+              services: Em.A([
+                Em.Object.create({
+                  serviceName: 'ANYSERVICE', isSelected: true, isInstalled: false, serviceComponents: [
+                    // set isRequiredOnAllHosts = true for slave and client
+                    Em.Object.create({
+                      componentName: 'ANYSERVICE_MASTER',
+                      isMaster: true,
+                      isRequiredOnAllHosts: false
+                    }),
+                    Em.Object.create({
+                      componentName: 'ANYSERVICE_SLAVE',
+                      isSlave: true,
+                      isRequiredOnAllHosts: true
+                    }),
+                    Em.Object.create({
+                      componentName: 'ANYSERVICE_SLAVE2',
+                      isSlave: true,
+                      isRequiredOnAllHosts: true
+                    }),
+                    Em.Object.create({
+                      componentName: 'ANYSERVICE_CLIENT',
+                      isClient: true,
+                      isRequiredOnAllHosts: true
+                    })
+                  ]
+                })
+              ]),
+              masterComponentHosts: Em.A([
+                Em.Object.create({
+                  componentName: 'ANYSERVICE_MASTER',
+                  component: 'ANYSERVICE_MASTER',
+                  hosts: Em.A([
+                    Em.Object.create({hostName: 'h1', isInstalled: true})
+                  ])
+                })
+              ]),
+              slaveComponentHosts: Em.A([
+                Em.Object.create({
+                  componentName: 'ANYSERVICE_SLAVE',
+                  hosts: Em.A([
+                    Em.Object.create({hostName: 'h1', isInstalled: false}),
+                    Em.Object.create({hostName: 'h2', isInstalled: false})
+                  ])
+                }),
+                Em.Object.create({
+                  componentName: 'ANYSERVICE_SLAVE2',
+                  hosts: Em.A([
+                    Em.Object.create({hostName: 'h1', isInstalled: false}),
+                    Em.Object.create({hostName: 'h2', isInstalled: false})
+                  ]),
+                }),
+                Em.Object.create({
+                  componentName: 'CLIENT',
+                  hosts: Em.A([
+                    Em.Object.create({hostName: 'h1', isInstalled: false}),
+                    Em.Object.create({hostName: 'h2', isInstalled: false})
+                  ])
+                })
+              ]),
+              clients: Em.A([
+                Em.Object.create({
+                  component_name: 'ANYSERVICE_CLIENT',
+                  isInstalled: false,
+                  hosts: Em.A([
+                    Em.Object.create({hostName: 'h1', isInstalled: false}),
+                    Em.Object.create({hostName: 'h2', isInstalled: false})
+                  ])
+                })
+              ])
+            }
+          });
+          installerStep8Controller.set('ajaxRequestsQueue', App.ajaxQueue.create());
+          installerStep8Controller.get('ajaxRequestsQueue').clear();
+          installerStep8Controller.createAdditionalHostComponents();
         });
 
-      installerStep8Controller.set('ajaxRequestsQueue', App.ajaxQueue.create());
-      installerStep8Controller.get('ajaxRequestsQueue').clear();
-      installerStep8Controller.createAdditionalHostComponents();
-      // Any component with isRequiredOnAllHosts = true implies that
-      // registerHostsToComponent would be done via
-      // createAdditionalHostComponents() BUT NOT
-      // createMasterHostComponents() or createSlaveAndClientsHostComponents()
-      // or createAdditionalClientComponents()
-      expect(installerStep8Controller.registerHostsToComponent.args[0][0]).to.eql(['h1', 'h2']);
-      expect(installerStep8Controller.registerHostsToComponent.args[0][1]).to.equal('ANYSERVICE_SLAVE');
-      expect(installerStep8Controller.registerHostsToComponent.args[1][0]).to.eql(['h1', 'h2']);
-      expect(installerStep8Controller.registerHostsToComponent.args[1][1]).to.equal('ANYSERVICE_SLAVE2');
-      expect(installerStep8Controller.registerHostsToComponent.args[2][0]).to.eql(['h1', 'h2']);
-      expect(installerStep8Controller.registerHostsToComponent.args[2][1]).to.equal('ANYSERVICE_CLIENT');
+        // Any component with isRequiredOnAllHosts = true implies that
+        // registerHostsToComponent would be done via
+        // createAdditionalHostComponents() BUT NOT
+        // createMasterHostComponents() or createSlaveAndClientsHostComponents()
+        // or createAdditionalClientComponents()
+        it('registerHostsToComponent 1st call', function () {
+          expect(installerStep8Controller.registerHostsToComponent.args[0][0]).to.eql(['h1', 'h2']);
+          expect(installerStep8Controller.registerHostsToComponent.args[0][1]).to.equal('ANYSERVICE_SLAVE');
+        });
+        it('registerHostsToComponent 2nd call', function () {
+          expect(installerStep8Controller.registerHostsToComponent.args[1][0]).to.eql(['h1', 'h2']);
+          expect(installerStep8Controller.registerHostsToComponent.args[1][1]).to.equal('ANYSERVICE_SLAVE2');
+        });
+        it('registerHostsToComponent 3rd call', function () {
+          expect(installerStep8Controller.registerHostsToComponent.args[2][0]).to.eql(['h1', 'h2']);
+          expect(installerStep8Controller.registerHostsToComponent.args[2][1]).to.equal('ANYSERVICE_CLIENT');
+        });
       });
 
       it('should not add components with isRequiredOnAllHosts == false (2)', function() {
@@ -1868,22 +1861,49 @@ describe('App.WizardStep8Controller', function () {
         expect($.ajax.args[0][0].url.contains('overwrite_existing=true')).to.be.true;
       });
 
-      it('sent data should be valid', function () {
+      describe('sent data should be valid', function () {
+        var data;
+        beforeEach(function () {
+          installerStep8Controller.createNotification();
+          data = installerStep8Controller.get('ajaxRequestsQueue.queue')[0].data.data.AlertTarget;
+        });
 
-        installerStep8Controller.createNotification();
-        var data = installerStep8Controller.get('ajaxRequestsQueue.queue')[0].data.data.AlertTarget;
-        expect(data.global).to.be.true;
-        expect(data.notification_type).to.equal('EMAIL');
-        expect(data.alert_states).to.eql(['OK', 'WARNING', 'CRITICAL', 'UNKNOWN']);
-        expect(data.properties['ambari.dispatch.recipients']).to.eql(['to@f.c']);
-        expect(data.properties['mail.smtp.host']).to.equal('h');
-        expect(data.properties['mail.smtp.port']).to.equal('25');
-        expect(data.properties['mail.smtp.from']).to.equal('from@f.c');
-        expect(data.properties['mail.smtp.starttls.enable']).to.equal(true);
-        expect(data.properties['mail.smtp.startssl.enable']).to.equal(false);
-        expect(data.properties['ambari.dispatch.credential.username']).to.equal('usr');
-        expect(data.properties['ambari.dispatch.credential.password']).to.equal('pwd');
-        expect(data.properties['some_p']).to.equal('some_v');
+        it('global is true', function () {
+          expect(data.global).to.be.true;
+        });
+        it('notification_type is EMAIL', function () {
+          expect(data.notification_type).to.equal('EMAIL');
+        });
+        it('alert_states are valid', function () {
+          expect(data.alert_states).to.eql(['OK', 'WARNING', 'CRITICAL', 'UNKNOWN']);
+        });
+        it('ambari.dispatch.recipients is valid', function () {
+          expect(data.properties['ambari.dispatch.recipients']).to.eql(['to@f.c']);
+        });
+        it('mail.smtp.host is valid', function () {
+          expect(data.properties['mail.smtp.host']).to.equal('h');
+        });
+        it('mail.smtp.port is valid', function () {
+          expect(data.properties['mail.smtp.port']).to.equal('25');
+        });
+        it('mail.smtp.from is valid', function () {
+          expect(data.properties['mail.smtp.from']).to.equal('from@f.c');
+        });
+        it('mail.smtp.starttls.enable is true', function () {
+          expect(data.properties['mail.smtp.starttls.enable']).to.equal(true);
+        });
+        it('mail.smtp.startssl.enable is false', function () {
+          expect(data.properties['mail.smtp.startssl.enable']).to.equal(false);
+        });
+        it('ambari.dispatch.credential.username is valid', function () {
+          expect(data.properties['ambari.dispatch.credential.username']).to.equal('usr');
+        });
+        it('ambari.dispatch.credential.password is valid', function () {
+          expect(data.properties['ambari.dispatch.credential.password']).to.equal('pwd');
+        });
+        it('custom property is valid', function () {
+          expect(data.properties['some_p']).to.equal('some_v');
+        });
 
       });
 
@@ -1911,14 +1931,18 @@ describe('App.WizardStep8Controller', function () {
       installerStep8Controller.startDeploy.restore();
     });
 
-    it('no failed requests', function () {
-      expect(installerStep8Controller.get('clusterDeleteRequestsCompleted')).to.equal(1);
-      expect(installerStep8Controller.showDeleteClustersErrorPopup.called).to.be.false;
-      expect(installerStep8Controller.startDeploy.called).to.be.false;
-      installerStep8Controller.deleteClusterSuccessCallback();
-      expect(installerStep8Controller.get('clusterDeleteRequestsCompleted')).to.equal(2);
-      expect(installerStep8Controller.showDeleteClustersErrorPopup.called).to.be.false;
-      expect(installerStep8Controller.startDeploy.calledOnce).to.be.true;
+    describe('no failed requests', function () {
+      it('before Delete Cluster request', function () {
+        expect(installerStep8Controller.get('clusterDeleteRequestsCompleted')).to.equal(1);
+        expect(installerStep8Controller.showDeleteClustersErrorPopup.called).to.be.false;
+        expect(installerStep8Controller.startDeploy.called).to.be.false;
+      });
+      it('after Delete Cluster request', function () {
+        installerStep8Controller.deleteClusterSuccessCallback();
+        expect(installerStep8Controller.get('clusterDeleteRequestsCompleted')).to.equal(2);
+        expect(installerStep8Controller.showDeleteClustersErrorPopup.called).to.be.false;
+        expect(installerStep8Controller.startDeploy.calledOnce).to.be.true;
+      });
     });
 
     it('one request failed', function () {
@@ -1957,20 +1981,34 @@ describe('App.WizardStep8Controller', function () {
       installerStep8Controller.showDeleteClustersErrorPopup.restore();
     });
 
-    it('should show error popup only if all requests are completed', function () {
-      expect(installerStep8Controller.get('clusterDeleteRequestsCompleted')).to.equal(1);
-      expect(installerStep8Controller.showDeleteClustersErrorPopup.called).to.be.false;
-      installerStep8Controller.deleteClusterErrorCallback(request, ajaxOptions, error, opt);
-      expect(installerStep8Controller.get('clusterDeleteRequestsCompleted')).to.equal(2);
-      expect(installerStep8Controller.showDeleteClustersErrorPopup.calledOnce).to.be.true;
+    describe('should show error popup only if all requests are completed', function () {
+      it('Before Delete Cluster request fail', function () {
+        expect(installerStep8Controller.get('clusterDeleteRequestsCompleted')).to.equal(1);
+        expect(installerStep8Controller.showDeleteClustersErrorPopup.called).to.be.false;
+      });
+      it('After Delete Cluster request is failed', function () {
+        installerStep8Controller.deleteClusterErrorCallback(request, ajaxOptions, error, opt);
+        expect(installerStep8Controller.get('clusterDeleteRequestsCompleted')).to.equal(2);
+        expect(installerStep8Controller.showDeleteClustersErrorPopup.calledOnce).to.be.true;
+      });
     });
 
-    it('should create error popup body view', function () {
-      expect(installerStep8Controller.get('clusterDeleteErrorViews')).to.have.length(1);
-      expect(installerStep8Controller.get('clusterDeleteErrorViews.firstObject.url')).to.equal('api/v1/clusters/c0');
-      expect(installerStep8Controller.get('clusterDeleteErrorViews.firstObject.type')).to.equal('DELETE');
-      expect(installerStep8Controller.get('clusterDeleteErrorViews.firstObject.status')).to.equal(500);
-      expect(installerStep8Controller.get('clusterDeleteErrorViews.firstObject.message')).to.equal('Internal Server Error');
+    describe('should create error popup body view', function () {
+      it('One failed request', function () {
+        expect(installerStep8Controller.get('clusterDeleteErrorViews')).to.have.length(1);
+      });
+      it('failed request url is valid', function () {
+        expect(installerStep8Controller.get('clusterDeleteErrorViews.firstObject.url')).to.equal('api/v1/clusters/c0');
+      });
+      it('failed request type is valid', function () {
+        expect(installerStep8Controller.get('clusterDeleteErrorViews.firstObject.type')).to.equal('DELETE');
+      });
+      it('failed request status is valid', function () {
+        expect(installerStep8Controller.get('clusterDeleteErrorViews.firstObject.status')).to.equal(500);
+      });
+      it('failed request message is valid', function () {
+        expect(installerStep8Controller.get('clusterDeleteErrorViews.firstObject.message')).to.equal('Internal Server Error');
+      });
     });
 
   });
@@ -2052,22 +2090,29 @@ describe('App.WizardStep8Controller', function () {
     });
 
     cases.forEach(function (item) {
-      it(item.title, function () {
-        sinon.stub(installerStep8Controller, 'get')
-          .withArgs('ajaxRequestsQueue').returns({
-            start: Em.K
-          })
-          .withArgs('ajaxRequestsQueue.queue.length').returns(1)
-          .withArgs('wizardController').returns({
-            getDBProperty: function () {
-              return item.fileNamesToUpdate;
-            }
-          })
-          .withArgs('content.controllerName').returns(item.controllerName);
-        installerStep8Controller.startDeploy();
+      describe(item.title, function () {
+
+        beforeEach(function () {
+          sinon.stub(installerStep8Controller, 'get')
+            .withArgs('ajaxRequestsQueue').returns({
+              start: Em.K
+            })
+            .withArgs('ajaxRequestsQueue.queue.length').returns(1)
+            .withArgs('wizardController').returns({
+              getDBProperty: function () {
+                return item.fileNamesToUpdate;
+              }
+            })
+            .withArgs('content.controllerName').returns(item.controllerName);
+          installerStep8Controller.startDeploy();
+        });
+
         stubbedNames.forEach(function (name) {
-          expect(installerStep8Controller[name].called).to.equal(!item.notExecuted.contains(name));
+          it(name, function () {
+            expect(installerStep8Controller[name].called).to.equal(!item.notExecuted.contains(name));
+          });
         });
+
       });
     });
 
@@ -2305,12 +2350,19 @@ describe('App.WizardStep8Controller', function () {
   });
 
   describe('#showLoadingIndicator', function() {
+
+    beforeEach(function () {
+      sinon.spy(App.ModalPopup, 'show');
+    });
+
+    afterEach(function () {
+      App.ModalPopup.show.restore();
+    });
+
     it('if popup doesn\'t exist should create another', function() {
       installerStep8Controller.set('isSubmitDisabled', true);
-      sinon.spy(App.ModalPopup, 'show');
       installerStep8Controller.showLoadingIndicator();
       expect(App.ModalPopup.show.calledOnce).to.equal(true);
-      App.ModalPopup.show.restore();
     });
 
   });

+ 53 - 36
ambari-web/test/controllers/wizard/step9_test.js

@@ -397,14 +397,12 @@ describe('App.InstallerStep9Controller', function () {
       var loaded_hosts = c.get('hosts');
       expect(loaded_hosts.length).to.equal(2);
     });
+
     it('All hosts have progress 0', function () {
       var loaded_hosts = c.get('hosts');
       expect(loaded_hosts.everyProperty('progress', 0)).to.equal(true);
     });
-    it('All hosts have progress 0', function () {
-      var loaded_hosts = c.get('hosts');
-      expect(loaded_hosts.everyProperty('progress', 0)).to.equal(true);
-    });
+
     it('All host don\'t have logTasks', function () {
       var loaded_hosts = c.get('hosts');
       expect(loaded_hosts.everyProperty('logTasks.length', 0)).to.equal(true);
@@ -1026,12 +1024,22 @@ describe('App.InstallerStep9Controller', function () {
   });
 
   describe('#clearStep', function () {
-    it('All to default values', function () {
+
+    beforeEach(function () {
       c.reopen({hosts: [{},{},{}]});
       c.clearStep();
+    });
+
+    it('hosts are empty', function () {
       expect(c.get('hosts.length')).to.equal(0);
+    });
+    it('status is `info`', function () {
       expect(c.get('status')).to.equal('info');
+    });
+    it('progress is 0', function () {
       expect(c.get('progress')).to.equal('0');
+    });
+    it('numPolls is 1', function () {
       expect(c.get('numPolls')).to.equal(1);
     });
   });
@@ -1287,11 +1295,18 @@ describe('App.InstallerStep9Controller', function () {
   });
 
   describe('#submit', function () {
-    it('should call App.router.send', function () {
+
+    beforeEach(function () {
       sinon.stub(App.router, 'send', Em.K);
+    });
+
+    afterEach(function () {
+      App.router.send.restore();
+    });
+
+    it('should call App.router.send', function () {
       c.submit();
       expect(App.router.send.calledWith('next')).to.equal(true);
-      App.router.send.restore();
     });
   });
 
@@ -1336,9 +1351,11 @@ describe('App.InstallerStep9Controller', function () {
   describe('#startPolling', function () {
     beforeEach(function () {
       sinon.stub(c, 'reloadErrorCallback', Em.K);
+      sinon.stub(c, 'doPolling', Em.K);
     });
     afterEach(function () {
       c.reloadErrorCallback.restore();
+      c.doPolling.restore();
     });
     it('should set isSubmitDisabled to true', function () {
       c.set('isSubmitDisabled', false);
@@ -1346,10 +1363,8 @@ describe('App.InstallerStep9Controller', function () {
       expect(c.get('isSubmitDisabled')).to.equal(true);
     });
     it('should call doPolling', function () {
-      sinon.stub(c, 'doPolling', Em.K);
       c.startPolling();
       expect(c.doPolling.calledOnce).to.equal(true);
-      c.doPolling.restore();
     });
   });
 
@@ -1375,13 +1390,6 @@ describe('App.InstallerStep9Controller', function () {
       expect(c.getLogsByRequest.calledWith(true, 3)).to.equal(true);
     });
 
-    it('should set POLL_INTERVAL to 1 if testMode enabled', function () {
-      sinon.stub(App, 'get', function(k) { if ('testMode' === k) return true; return Em.get(App, k);});
-      c.loadLogData();
-      expect(c.get('POLL_INTERVAL')).to.equal(1);
-      App.get.restore();
-    });
-
   });
 
   describe('#loadCurrentTaskLog', function () {
@@ -1390,23 +1398,25 @@ describe('App.InstallerStep9Controller', function () {
       c.set('wizardController', Em.Object.create({
         getDBProperty: Em.K
       }));
+      sinon.stub(c, 'togglePreviousSteps', Em.K);
     });
     afterEach(function () {
       c.loadLogData.restore();
+      c.togglePreviousSteps.restore();
     });
+
     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);
     });
+
     it('should call App.ajax.send with provided data', function () {
-      sinon.stub(c, 'togglePreviousSteps', Em.K);
       c.set('currentOpenTaskId', 1);
       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});
-      c.togglePreviousSteps.restore();
     });
   });
 
@@ -1535,12 +1545,15 @@ describe('App.InstallerStep9Controller', function () {
   });
 
   describe('#navigateStep', function () {
+
     beforeEach(function () {
       sinon.stub(c, 'togglePreviousSteps', Em.K);
       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 () {
       c.togglePreviousSteps.restore();
       c.loadStep.restore();
@@ -1548,16 +1561,8 @@ describe('App.InstallerStep9Controller', function () {
       c.startPolling.restore();
       App.get.restore();
     });
-    it('should set custom data in testMode', function () {
-      sinon.stub(App, 'get', function(k) {if('testMode' === k) return true; return Em.get(App, k);});
-      c.reopen({content: {cluster: {status: 'st', isCompleted: true, requestId: 0}}});
-      c.navigateStep();
-      expect(c.get('content.cluster.status')).to.equal('PENDING');
-      expect(c.get('content.cluster.isCompleted')).to.equal(false);
-      expect(c.get('content.cluster.requestId')).to.equal(1);
-    });
+
     it('isCompleted = true, requestId = 1', function () {
-      sinon.stub(App, 'get', function(k) {if('testMode' === k) return false; return Em.get(App, k);});
       c.reopen({content: {cluster: {isCompleted: true, requestId: 1}}});
       c.navigateStep();
       expect(c.loadStep.calledOnce).to.equal(true);
@@ -1565,21 +1570,18 @@ describe('App.InstallerStep9Controller', function () {
       expect(c.get('progress')).to.equal('100');
     });
     it('isCompleted = false, requestId = 1, status = INSTALL FAILED', function () {
-      sinon.stub(App, 'get', function(k) {if('testMode' === k) return false; return Em.get(App, k);});
       c.reopen({content: {cluster: {status: 'INSTALL FAILED', isCompleted: false, requestId: 1}}});
       c.navigateStep();
       expect(c.loadStep.calledOnce).to.equal(true);
       expect(c.loadLogData.calledWith(false)).to.equal(true);
     });
     it('isCompleted = false, requestId = 1, status = START FAILED', function () {
-      sinon.stub(App, 'get', function(k) {if('testMode' === k) return false; return Em.get(App, k);});
       c.reopen({content: {cluster: {status: 'START FAILED', isCompleted: false, requestId: 1}}});
       c.navigateStep();
       expect(c.loadStep.calledOnce).to.equal(true);
       expect(c.loadLogData.calledWith(false)).to.equal(true);
     });
     it('isCompleted = false, requestId = 1, status = OTHER', function () {
-      sinon.stub(App, 'get', function(k) {if('testMode' === k) return false; return Em.get(App, k);});
       c.reopen({content: {cluster: {status: 'STARTED', isCompleted: false, requestId: 1}}});
       c.navigateStep();
       expect(c.loadStep.calledOnce).to.equal(true);
@@ -1633,15 +1635,30 @@ describe('App.InstallerStep9Controller', function () {
           }
         }
       ]).forEach(function (test) {
-        it(test.m, function () {
-          c.launchStartServicesSuccessCallback(test.jsonData);
-          expect(c.hostHasClientsOnly.calledWith(test.e.hostHasClientsOnly)).to.equal(true);
-          expect(c.saveClusterStatus.calledWith(test.e.clusterStatus)).to.equal(true);
+        describe(test.m, function () {
+
+          beforeEach(function () {
+            c.launchStartServicesSuccessCallback(test.jsonData);
+          });
+
+          it('hostHasClientsOnly is called with valid arguments', function () {
+            expect(c.hostHasClientsOnly.calledWith(test.e.hostHasClientsOnly)).to.equal(true);
+          });
+
+          it('saveClusterStatus is called with valid arguments', function () {
+            expect(c.saveClusterStatus.calledWith(test.e.clusterStatus)).to.equal(true);
+          });
+
+
           if (test.e.status) {
-            expect(c.get('status')).to.equal(test.e.status);
+            it('status is valid', function () {
+              expect(c.get('status')).to.equal(test.e.status);
+            });
           }
           if (test.e.progress) {
-            expect(c.get('progress')).to.equal(test.e.progress);
+            it('progress is valid', function () {
+              expect(c.get('progress')).to.equal(test.e.progress);
+            });
           }
         });
       });

+ 91 - 40
ambari-web/test/controllers/wizard_test.js

@@ -56,21 +56,21 @@ describe('App.WizardController', function () {
   // isStep0 ... isStep10 tests
   App.WizardController1 = App.WizardController.extend({currentStep:''});
   var tests = [];
-  for(var i = 0; i < totalSteps; i++) {
+  for (var i = 0; i < totalSteps; i++) {
     var n = ruller.slice(0);
-    n.splice(i,1);
-    tests.push({i:i,n:n});
+    n.splice(i, 1);
+    tests.push({i: i, n: n});
   }
-  tests.forEach(function(test) {
-    describe('isStep'+test.i, function() {
+  tests.forEach(function (test) {
+    describe('isStep' + test.i, function () {
       var w = App.WizardController1.create();
       w.set('currentStep', test.i);
-      it('Current Step is ' + test.i + ', so isStep' + test.i + ' is TRUE', function() {
-        expect(w.get('isStep'+ test.i)).to.equal(true);
+      it('Current Step is ' + test.i + ', so isStep' + test.i + ' is TRUE', function () {
+        expect(w.get('isStep' + test.i)).to.equal(true);
       });
-      test.n.forEach(function(indx) {
-        it('Current Step is ' + test.i + ', so isStep' + indx + ' is FALSE', function() {
-          expect(w.get('isStep'+ indx)).to.equal(false);
+      test.n.forEach(function (indx) {
+        it('Current Step is ' + test.i + ', so isStep' + indx + ' is FALSE', function () {
+          expect(w.get('isStep' + indx)).to.equal(false);
         });
       });
     });
@@ -93,13 +93,19 @@ describe('App.WizardController', function () {
   });
 
   describe('#launchBootstrapSuccessCallback', function() {
+    var params = {popup: {finishLoading: function(){}}};
+    beforeEach(function () {
+      sinon.spy(params.popup, "finishLoading");
+    });
+
+    afterEach(function () {
+      params.popup.finishLoading.restore();
+    });
+
     it('Save bootstrapRequestId', function() {
       var data = {requestId: 123, status: 'SUCCESS', log: 'ok'};
-      var params = {popup: {finishLoading: function(){}}};
-      sinon.spy(params.popup, "finishLoading");
       wizardController.launchBootstrapSuccessCallback(data, {}, params);
       expect(params.popup.finishLoading.calledWith(123, null, 'SUCCESS', 'ok')).to.be.true;
-      params.popup.finishLoading.restore();
     });
   });
 
@@ -125,6 +131,7 @@ describe('App.WizardController', function () {
       sinon.stub(wizardController, 'get')
         .withArgs('installOptionsTemplate').returns({useSsh: true})
         .withArgs('installWindowsOptionsTemplate').returns({useSsh: false});
+      this.stub = sinon.stub(App, 'get');
     });
 
     afterEach(function () {
@@ -134,7 +141,7 @@ describe('App.WizardController', function () {
 
     cases.forEach(function (item) {
       it(title.format(item.expected), function () {
-        sinon.stub(App, 'get').withArgs('isHadoopWindowsStack').returns(item.isHadoopWindowsStack);
+        this.stub.withArgs('isHadoopWindowsStack').returns(item.isHadoopWindowsStack);
         expect(wizardController.getInstallOptions()).to.eql(item.expected);
       });
     });
@@ -156,12 +163,23 @@ describe('App.WizardController', function () {
       App.get.restore();
     });
 
-    it('should clear install options', function () {
-      wizardController.clearInstallOptions();
-      expect(wizardController.get('content.installOptions')).to.eql(wizardController.get('installOptionsTemplate'));
-      expect(wizardController.get('content.hosts')).to.eql({});
-      expect(wizardController.getDBProperty('installOptions')).to.eql(wizardController.get('installOptionsTemplate'));
-      expect(wizardController.getDBProperty('hosts')).to.eql({});
+    describe('should clear install options', function () {
+
+      beforeEach(function () {
+        wizardController.clearInstallOptions();
+      });
+      it('content.installOptions', function () {
+        expect(wizardController.get('content.installOptions')).to.eql(wizardController.get('installOptionsTemplate'));
+      });
+      it('content.hosts', function () {
+        expect(wizardController.get('content.hosts')).to.eql({});
+      });
+      it('installOptions', function () {
+        expect(wizardController.getDBProperty('installOptions')).to.eql(wizardController.get('installOptionsTemplate'));
+      });
+      it('hosts', function () {
+        expect(wizardController.getDBProperty('hosts')).to.eql({});
+      });
     });
   });
 
@@ -250,13 +268,21 @@ describe('App.WizardController', function () {
     afterEach(function(){
       App.ModalPopup.show.restore();
     });
-    it('should set error', function () {
-      sinon.stub(App.ModalPopup,'show', function (data) {
-        data.finishLoading.call(c);
+
+    describe('errors', function () {
+
+      beforeEach(function () {
+        sinon.stub(App.ModalPopup,'show', function (data) {
+          data.finishLoading.call(c);
+        });
+      });
+
+      it('should set error', function () {
+        c.showLaunchBootstrapPopup(Em.K);
+        expect(c.get('isError')).to.be.true;
       });
-      c.showLaunchBootstrapPopup(Em.K);
-      expect(c.get('isError')).to.be.true;
     });
+
     describe('#finishLoading', function () {
       var callback = sinon.spy(),
         stepController = App.get('router.wizardStep3Controller'),
@@ -346,18 +372,36 @@ describe('App.WizardController', function () {
         c.callback.restore();
       });
       cases.forEach(function (item) {
-        it(item.title, function () {
+        describe(item.title, function () {
           var wizardControllerProperties = Em.keys(item.wizardControllerProperties),
             stepControllerProperties = Em.keys(item.stepControllerProperties);
-          sinon.stub(App.ModalPopup,'show', function (data) {
-            data.finishLoading.call(c, item.requestId, item.serverError, item.status, item.log);
+
+          beforeEach(function () {
+            sinon.stub(App.ModalPopup,'show', function (data) {
+              data.finishLoading.call(c, item.requestId, item.serverError, item.status, item.log);
+            });
+            c.showLaunchBootstrapPopup(c.callback);
+          });
+
+          it('wizardControllerProperties are valid', function () {
+            expect(c.getProperties.apply(c, wizardControllerProperties)).to.eql(item.wizardControllerProperties);
+          });
+
+          it('stepControllerProperties are valid', function () {
+            expect(stepController.getProperties.apply(stepController, stepControllerProperties)).to.eql(item.stepControllerProperties);
+          });
+
+          it('bootStatus is valid', function () {
+            expect(stepController.get('hosts').mapProperty('bootStatus').uniq()).to.eql([item.bootStatus]);
+          });
+
+          it('callback is called needed number of times', function () {
+            expect(c.callback.callCount).to.equal(item.callbackCallCount);
+          });
+
+          it('hide is called needed number of times', function () {
+            expect(c.hide.callCount).to.equal(item.hideCallCount);
           });
-          c.showLaunchBootstrapPopup(c.callback);
-          expect(c.getProperties.apply(c, wizardControllerProperties)).to.eql(item.wizardControllerProperties);
-          expect(stepController.getProperties.apply(stepController, stepControllerProperties)).to.eql(item.stepControllerProperties);
-          expect(stepController.get('hosts').mapProperty('bootStatus').uniq()).to.eql([item.bootStatus]);
-          expect(c.callback.callCount).to.equal(item.callbackCallCount);
-          expect(c.hide.callCount).to.equal(item.hideCallCount);
         });
       });
     });
@@ -584,15 +628,21 @@ describe('App.WizardController', function () {
   });
 
   describe('#save', function () {
-    it('should save data', function () {
-      var res;
+    var res;
+    beforeEach(function () {
       sinon.stub(wizardController,'setDBProperty', function(data){
         res = data;
       });
       sinon.stub(wizardController,'toJSInstance').returns('val');
-      wizardController.save('name');
+    });
+
+    afterEach(function () {
       wizardController.setDBProperty.restore();
       wizardController.toJSInstance.restore();
+    });
+
+    it('should save data', function () {
+      wizardController.save('name');
       expect(res).to.be.equal('name');
     });
   });
@@ -1459,6 +1509,7 @@ describe('App.WizardController', function () {
           serviceName: 's1'
         })
       ]));
+      this.stub = sinon.stub(App, 'get');
     });
     afterEach(function () {
       App.get.restore();
@@ -1468,13 +1519,13 @@ describe('App.WizardController', function () {
       wizardController.loadConfigThemeForServices.restore();
     });
     it('Should load config themes', function() { 
-      sinon.stub(App, 'get').returns(true);
+      this.stub.returns(true);
       wizardController.loadConfigThemes().then(function(data) {
         expect().to.be.undefined;
       });
     });
-    it('Should load config themes', function() {
-      sinon.stub(App, 'get').returns(false); 
+    it('Should load config themes (2)', function() {
+      this.stub.returns(false);
       wizardController.loadConfigThemes().then(function(data) {
         expect().to.be.undefined;
       });

+ 13 - 13
ambari-web/test/data/HDP2.2/site_properties_test.js

@@ -43,16 +43,12 @@ describe('hdp2SiteProperties', function () {
      * showLabel
      * unit
      */
-    it('Check attributes of "' + siteProperty.filename + '/' + siteProperty.name  + '"' + '. Stack driven attributes should be undefined ', function () {
-      expect(siteProperty.isVisible).to.equal(undefined);
-      expect(siteProperty.value).to.equal(undefined);
-      expect(siteProperty.recommendedValue).to.equal(undefined);
-      expect(siteProperty.description).to.equal(undefined);
-      expect(siteProperty.isReconfigurable).to.equal(undefined);
-      expect(siteProperty.isRequired).to.equal(undefined);
-      expect(siteProperty.displayName).to.equal(undefined);
-      expect(siteProperty.showLabel).to.equal(undefined);
-      expect(siteProperty.unit).to.equal(undefined);
+    describe('Check attributes of "' + siteProperty.filename + '/' + siteProperty.name  + '"' + '. Stack driven attributes should be undefined ', function () {
+      ['isVisible', 'value', 'recommendedValue', 'description', 'isReconfigurable', 'isRequired', 'displayName', 'showLabel', 'unit'].forEach(function (p) {
+        it(p, function () {
+          expect(siteProperty[p]).to.not.exist;
+        });
+      });
     });
 
     /**
@@ -68,9 +64,13 @@ describe('hdp2SiteProperties', function () {
      * name
      * filename
      */
-    it('Check primary attributes of "' + siteProperty.filename + '/' + siteProperty.name  + '"' + '. Attributes that uniquely represent a property should be defined ', function () {
-      expect(siteProperty.name).to.not.equal(undefined);
-      expect(siteProperty.filename).to.not.equal(undefined);
+    describe('Check primary attributes of "' + siteProperty.filename + '/' + siteProperty.name  + '"' + '. Attributes that uniquely represent a property should be defined ', function () {
+      it('name', function () {
+        expect(siteProperty.name).to.not.equal(undefined);
+      });
+      it('filename', function () {
+        expect(siteProperty.filename).to.not.equal(undefined);
+      });
     });
   });
 

+ 13 - 13
ambari-web/test/data/HDP2.3/site_properties_test.js

@@ -43,16 +43,12 @@ describe('hdp2SiteProperties', function () {
      * showLabel
      * unit
      */
-    it('Check attributes of "' + siteProperty.filename + '/' + siteProperty.name  + '"' + '. Stack driven attributes should be undefined ', function () {
-      expect(siteProperty.isVisible).to.equal(undefined);
-      expect(siteProperty.value).to.equal(undefined);
-      expect(siteProperty.recommendedValue).to.equal(undefined);
-      expect(siteProperty.description).to.equal(undefined);
-      expect(siteProperty.isReconfigurable).to.equal(undefined);
-      expect(siteProperty.isRequired).to.equal(undefined);
-      expect(siteProperty.displayName).to.equal(undefined);
-      expect(siteProperty.showLabel).to.equal(undefined);
-      expect(siteProperty.unit).to.equal(undefined);
+    describe('Check attributes of "' + siteProperty.filename + '/' + siteProperty.name  + '"' + '. Stack driven attributes should be undefined ', function () {
+      ['isVisible', 'value', 'recommendedValue', 'description', 'isReconfigurable', 'isRequired', 'displayName', 'showLabel', 'unit'].forEach(function (p) {
+        it(p, function () {
+          expect(siteProperty[p]).to.not.exist;
+        });
+      });
     });
 
 
@@ -69,9 +65,13 @@ describe('hdp2SiteProperties', function () {
      * name
      * filename
      */
-    it('Check primary attributes of "' + siteProperty.filename + '/' + siteProperty.name  + '"' + '. Attributes that uniquely represent a property should be defined ', function () {
-      expect(siteProperty.name).to.not.equal(undefined);
-      expect(siteProperty.filename).to.not.equal(undefined);
+    describe('Check primary attributes of "' + siteProperty.filename + '/' + siteProperty.name  + '"' + '. Attributes that uniquely represent a property should be defined ', function () {
+      it('name', function () {
+        expect(siteProperty.name).to.not.equal(undefined);
+      });
+      it('filename', function () {
+        expect(siteProperty.filename).to.not.equal(undefined);
+      });
     });
   });
 

+ 13 - 13
ambari-web/test/data/HDP2/site_properties_test.js

@@ -43,16 +43,12 @@ describe('hdp2SiteProperties', function () {
      * showLabel
      * unit
      */
-    it('Check attributes of "' + siteProperty.filename + '/' + siteProperty.name  + '"' + '. Stack driven attributes should be undefined ', function () {
-      expect(siteProperty.isVisible).to.equal(undefined);
-      expect(siteProperty.value).to.equal(undefined);
-      expect(siteProperty.recommendedValue).to.equal(undefined);
-      expect(siteProperty.description).to.equal(undefined);
-      expect(siteProperty.isReconfigurable).to.equal(undefined);
-      expect(siteProperty.isRequired).to.equal(undefined);
-      expect(siteProperty.displayName).to.equal(undefined);
-      expect(siteProperty.showLabel).to.equal(undefined);
-      expect(siteProperty.unit).to.equal(undefined);
+    describe('Check attributes of "' + siteProperty.filename + '/' + siteProperty.name  + '"' + '. Stack driven attributes should be undefined ', function () {
+      ['isVisible', 'value', 'recommendedValue', 'description', 'isReconfigurable', 'isRequired', 'displayName', 'showLabel', 'unit'].forEach(function (p) {
+        it(p, function () {
+          expect(siteProperty[p]).to.not.exist;
+        });
+      });
     });
 
     /**
@@ -68,9 +64,13 @@ describe('hdp2SiteProperties', function () {
      * name
      * filename
      */
-    it('Check primary attributes of "' + siteProperty.filename + '/' + siteProperty.name  + '"' + '. Attributes that uniquely represent a property should be defined ', function () {
-      expect(siteProperty.name).to.not.equal(undefined);
-      expect(siteProperty.filename).to.not.equal(undefined);
+    describe('Check primary attributes of "' + siteProperty.filename + '/' + siteProperty.name  + '"' + '. Attributes that uniquely represent a property should be defined ', function () {
+      it('name', function () {
+        expect(siteProperty.name).to.not.equal(undefined);
+      });
+      it('filename', function () {
+        expect(siteProperty.filename).to.not.equal(undefined);
+      });
     });
   });
 

+ 135 - 30
ambari-web/test/mappers/alert_definition_summary_mapper_test.js

@@ -21,7 +21,7 @@ require('mappers/alert_definition_summary_mapper');
 
 describe('App.alertDefinitionSummaryMapper', function () {
 
-  describe('#map', function() {
+  describe('#map', function () {
 
     var testModels = [
         App.AlertDefinition.createRecord({id: 1, enabled: true, type: 'PORT'}),
@@ -36,8 +36,18 @@ describe('App.alertDefinitionSummaryMapper', function () {
           {
             definition_id: 1,
             summary: {
-              OK: {count: 1, original_timestamp: 1, maintenance_count: 0, latest_text : "Connection failed: [Errno 111] Connection refused to c6407.ambari.apache.org:60000"},
-              WARNING: {count: 1, original_timestamp: 2, maintenance_count: 0, latest_text : "Connection failed: [Errno 111] Connection refused to c6407.ambari.apache.org:60000"},
+              OK: {
+                count: 1,
+                original_timestamp: 1,
+                maintenance_count: 0,
+                latest_text: "Connection failed: [Errno 111] Connection refused to c6407.ambari.apache.org:60000"
+              },
+              WARNING: {
+                count: 1,
+                original_timestamp: 2,
+                maintenance_count: 0,
+                latest_text: "Connection failed: [Errno 111] Connection refused to c6407.ambari.apache.org:60000"
+              },
               CRITICAL: {count: 0, original_timestamp: 0, maintenance_count: 1},
               UNKNOWN: {count: 0, original_timestamp: 0, maintenance_count: 0}
             }
@@ -45,8 +55,18 @@ describe('App.alertDefinitionSummaryMapper', function () {
           {
             definition_id: 2,
             summary: {
-              OK: {count: 1, original_timestamp: 1, maintenance_count: 0, latest_text : "HTTP 200 response in 0.000 seconds"},
-              WARNING: {count: 5, original_timestamp: 2, maintenance_count: 0, latest_text : "Connection failed: [Errno 111] Connection refused to c6407.ambari.apache.org:60000"},
+              OK: {
+                count: 1,
+                original_timestamp: 1,
+                maintenance_count: 0,
+                latest_text: "HTTP 200 response in 0.000 seconds"
+              },
+              WARNING: {
+                count: 5,
+                original_timestamp: 2,
+                maintenance_count: 0,
+                latest_text: "Connection failed: [Errno 111] Connection refused to c6407.ambari.apache.org:60000"
+              },
               CRITICAL: {count: 1, original_timestamp: 1, maintenance_count: 0},
               UNKNOWN: {count: 1, original_timestamp: 3, maintenance_count: 0}
             }
@@ -54,25 +74,50 @@ describe('App.alertDefinitionSummaryMapper', function () {
           {
             definition_id: 3,
             summary: {
-              OK: {count: 1, original_timestamp: 1, maintenance_count: 0, latest_text : "HTTP 200 response in 0.000 seconds"},
+              OK: {
+                count: 1,
+                original_timestamp: 1,
+                maintenance_count: 0,
+                latest_text: "HTTP 200 response in 0.000 seconds"
+              },
               WARNING: {count: 2, original_timestamp: 2, maintenance_count: 2},
-              CRITICAL: {count: 3, original_timestamp: 4, maintenance_count: 0, latest_text : "Connection failed: [Errno 111] Connection refused to c6407.ambari.apache.org:60000"},
+              CRITICAL: {
+                count: 3,
+                original_timestamp: 4,
+                maintenance_count: 0,
+                latest_text: "Connection failed: [Errno 111] Connection refused to c6407.ambari.apache.org:60000"
+              },
               UNKNOWN: {count: 4, original_timestamp: 3, maintenance_count: 0}
             }
           },
           {
             definition_id: 4,
             summary: {
-              OK: {count: 4, original_timestamp: 1, maintenance_count: 0, latest_text : "HTTP 200 response in 0.000 seconds"},
+              OK: {
+                count: 4,
+                original_timestamp: 1,
+                maintenance_count: 0,
+                latest_text: "HTTP 200 response in 0.000 seconds"
+              },
               WARNING: {count: 3, original_timestamp: 2, maintenance_count: 0},
               CRITICAL: {count: 2, original_timestamp: 1, maintenance_count: 0},
-              UNKNOWN: {count: 1, original_timestamp: 2, maintenance_count: 0, latest_text : "Connection failed: [Errno 111] Connection refused to c6407.ambari.apache.org:60000"}
+              UNKNOWN: {
+                count: 1,
+                original_timestamp: 2,
+                maintenance_count: 0,
+                latest_text: "Connection failed: [Errno 111] Connection refused to c6407.ambari.apache.org:60000"
+              }
             }
           },
           {
             definition_id: 5,
             summary: {
-              OK: {count: 1, original_timestamp: 1, maintenance_count: 0, latest_text : "Connection failed: [Errno 111] Connection refused to c6407.ambari.apache.org:60000"},
+              OK: {
+                count: 1,
+                original_timestamp: 1,
+                maintenance_count: 0,
+                latest_text: "Connection failed: [Errno 111] Connection refused to c6407.ambari.apache.org:60000"
+              },
               WARNING: {count: 1, original_timestamp: 2, maintenance_count: 0},
               CRITICAL: {count: 1, original_timestamp: 3, maintenance_count: 0},
               UNKNOWN: {count: 1, original_timestamp: 4, maintenance_count: 0}
@@ -81,45 +126,105 @@ describe('App.alertDefinitionSummaryMapper', function () {
         ]
       };
 
-    beforeEach(function() {
-
-      sinon.stub(App.AlertDefinition, 'find', function() {return testModels;});
-
+    beforeEach(function () {
+      sinon.stub(App.AlertDefinition, 'find').returns(testModels);
+      App.alertDefinitionSummaryMapper.map(dataToMap);
     });
 
-    afterEach(function() {
-
+    afterEach(function () {
       App.AlertDefinition.find.restore();
-
     });
 
-    it('should map summary info for each alert', function() {
-
-      App.alertDefinitionSummaryMapper.map(dataToMap);
+    it('should map summary info for 1st alert', function () {
       expect(App.AlertDefinition.find().findProperty('id', 1).get('lastTriggered')).to.equal(2);
-      expect(App.AlertDefinition.find().findProperty('id', 1).get('summary')).to.eql({OK: {count: 1, maintenanceCount: 0, latestText : "Connection failed: [Errno 111] Connection refused to c6407.ambari.apache.org:60000"}, WARNING: {count: 1, maintenanceCount: 0, latestText : "Connection failed: [Errno 111] Connection refused to c6407.ambari.apache.org:60000"}, CRITICAL: {count: 0, maintenanceCount: 1}, UNKNOWN: {count: 0, maintenanceCount: 0}});
+      expect(App.AlertDefinition.find().findProperty('id', 1).get('summary')).to.eql({
+        OK: {
+          count: 1,
+          maintenanceCount: 0,
+          latestText: "Connection failed: [Errno 111] Connection refused to c6407.ambari.apache.org:60000"
+        },
+        WARNING: {
+          count: 1,
+          maintenanceCount: 0,
+          latestText: "Connection failed: [Errno 111] Connection refused to c6407.ambari.apache.org:60000"
+        },
+        CRITICAL: {count: 0, maintenanceCount: 1},
+        UNKNOWN: {count: 0, maintenanceCount: 0}
+      });
+    });
 
+    it('should map summary info for 2nd alert', function () {
       expect(App.AlertDefinition.find().findProperty('id', 2).get('lastTriggered')).to.equal(3);
-      expect(App.AlertDefinition.find().findProperty('id', 2).get('summary')).to.eql({OK: {count: 1, maintenanceCount: 0, latestText : "HTTP 200 response in 0.000 seconds"}, WARNING: {count: 5, maintenanceCount: 0, latestText : "Connection failed: [Errno 111] Connection refused to c6407.ambari.apache.org:60000"}, CRITICAL: {count: 1, maintenanceCount: 0}, UNKNOWN: {count: 1, maintenanceCount: 0}});
+      expect(App.AlertDefinition.find().findProperty('id', 2).get('summary')).to.eql({
+        OK: {
+          count: 1,
+          maintenanceCount: 0,
+          latestText: "HTTP 200 response in 0.000 seconds"
+        },
+        WARNING: {
+          count: 5,
+          maintenanceCount: 0,
+          latestText: "Connection failed: [Errno 111] Connection refused to c6407.ambari.apache.org:60000"
+        },
+        CRITICAL: {count: 1, maintenanceCount: 0},
+        UNKNOWN: {count: 1, maintenanceCount: 0}
+      });
+    });
 
+    it('should map summary info for 3rd alert', function () {
       expect(App.AlertDefinition.find().findProperty('id', 3).get('lastTriggered')).to.equal(4);
-      expect(App.AlertDefinition.find().findProperty('id', 3).get('summary')).to.eql({OK: {count: 1, maintenanceCount: 0, latestText : "HTTP 200 response in 0.000 seconds"}, WARNING: {count: 2, maintenanceCount: 2}, CRITICAL: {count: 3, maintenanceCount: 0, latestText : "Connection failed: [Errno 111] Connection refused to c6407.ambari.apache.org:60000"}, UNKNOWN: {count: 4, maintenanceCount: 0}});
+      expect(App.AlertDefinition.find().findProperty('id', 3).get('summary')).to.eql({
+        OK: {
+          count: 1,
+          maintenanceCount: 0,
+          latestText: "HTTP 200 response in 0.000 seconds"
+        },
+        WARNING: {count: 2, maintenanceCount: 2},
+        CRITICAL: {
+          count: 3,
+          maintenanceCount: 0,
+          latestText: "Connection failed: [Errno 111] Connection refused to c6407.ambari.apache.org:60000"
+        },
+        UNKNOWN: {count: 4, maintenanceCount: 0}
+      });
+    });
 
+    it('should map summary info for 4th alert', function () {
       expect(App.AlertDefinition.find().findProperty('id', 4).get('lastTriggered')).to.equal(2);
-      expect(App.AlertDefinition.find().findProperty('id', 4).get('summary')).to.eql({OK: {count: 4, maintenanceCount: 0, latestText : "HTTP 200 response in 0.000 seconds"}, WARNING: {count: 3, maintenanceCount: 0}, CRITICAL: {count: 2, maintenanceCount: 0}, UNKNOWN: {count: 1, maintenanceCount: 0, latestText : "Connection failed: [Errno 111] Connection refused to c6407.ambari.apache.org:60000"}});
+      expect(App.AlertDefinition.find().findProperty('id', 4).get('summary')).to.eql({
+        OK: {
+          count: 4,
+          maintenanceCount: 0,
+          latestText: "HTTP 200 response in 0.000 seconds"
+        },
+        WARNING: {count: 3, maintenanceCount: 0},
+        CRITICAL: {count: 2, maintenanceCount: 0},
+        UNKNOWN: {
+          count: 1,
+          maintenanceCount: 0,
+          latestText: "Connection failed: [Errno 111] Connection refused to c6407.ambari.apache.org:60000"
+        }
+      });
+    });
 
+    it('should map summary info for 5th alert', function () {
       expect(App.AlertDefinition.find().findProperty('id', 5).get('lastTriggered')).to.equal(4);
-      expect(App.AlertDefinition.find().findProperty('id', 5).get('summary')).to.eql({OK: {count: 1, maintenanceCount: 0, latestText : "Connection failed: [Errno 111] Connection refused to c6407.ambari.apache.org:60000"}, WARNING: {count: 1, maintenanceCount: 0}, CRITICAL: {count: 1, maintenanceCount: 0}, UNKNOWN: {count: 1, maintenanceCount: 0}});
-
+      expect(App.AlertDefinition.find().findProperty('id', 5).get('summary')).to.eql({
+        OK: {
+          count: 1,
+          maintenanceCount: 0,
+          latestText: "Connection failed: [Errno 111] Connection refused to c6407.ambari.apache.org:60000"
+        },
+        WARNING: {count: 1, maintenanceCount: 0},
+        CRITICAL: {count: 1, maintenanceCount: 0},
+        UNKNOWN: {count: 1, maintenanceCount: 0}
+      });
     });
 
     it('should clear summary for disabled definitions', function () {
-
-      App.alertDefinitionSummaryMapper.map(dataToMap);
       expect(App.AlertDefinition.find().findProperty('id', 6).get('summary')).to.eql({});
-
     });
 
   });
 
-});
+});

+ 61 - 22
ambari-web/test/mappers/configs/service_config_version_mapper_test.js

@@ -88,30 +88,69 @@ describe.skip('App.serviceConfigVersionsMapper', function () {
       expect(App.ServiceConfigVersion.find().get('length')).to.equal(0);
     });
 
-    it('should load data to model', function() {
-      App.serviceConfigVersionsMapper.map(json);
-      expect(App.ServiceConfigVersion.find().get('length')).to.equal(2);
-      expect(App.ServiceConfigVersion.find().mapProperty('id')).to.eql(['SERVICE1_1','SERVICE2_4']);
+    describe('should load data to model', function() {
 
-      //SERVICE1_1
-      expect(App.ServiceConfigVersion.find('SERVICE1_1').get('createTime')).to.eql(1425979244738);
-      expect(App.ServiceConfigVersion.find('SERVICE1_1').get('groupId')).to.eql(-1);
-      expect(App.ServiceConfigVersion.find('SERVICE1_1').get('hosts')).to.eql(defaultAllHosts);
-      expect(App.ServiceConfigVersion.find('SERVICE1_1').get('isCurrent')).to.be.true;
-      expect(App.ServiceConfigVersion.find('SERVICE1_1').get('version')).to.eql(1);
-      expect(App.ServiceConfigVersion.find('SERVICE1_1').get('notes')).to.eql("Initial configurations for SERVICE1");
-      expect(App.ServiceConfigVersion.find('SERVICE1_1').get('serviceName')).to.eql("SERVICE1");
-      expect(App.ServiceConfigVersion.find('SERVICE1_1').get('author')).to.eql("admin");
+      beforeEach(function () {
+        App.serviceConfigVersionsMapper.map(json);
+      });
 
-      //SERVICE1_2
-      expect(App.ServiceConfigVersion.find('SERVICE2_4').get('createTime')).to.eql(1426088137115);
-      expect(App.ServiceConfigVersion.find('SERVICE2_4').get('groupId')).to.eql(2);
-      expect(App.ServiceConfigVersion.find('SERVICE2_4').get('hosts')).to.eql(["host1"]);
-      expect(App.ServiceConfigVersion.find('SERVICE2_4').get('isCurrent')).to.be.false;
-      expect(App.ServiceConfigVersion.find('SERVICE2_4').get('version')).to.eql(4);
-      expect(App.ServiceConfigVersion.find('SERVICE2_4').get('notes')).to.eql("");
-      expect(App.ServiceConfigVersion.find('SERVICE2_4').get('serviceName')).to.eql("SERVICE2");
-      expect(App.ServiceConfigVersion.find('SERVICE2_4').get('author')).to.eql("admin");
+      it('two versions are mapped', function () {
+        expect(App.ServiceConfigVersion.find().get('length')).to.equal(2);
+      });
+
+      it('services have correct ids', function () {
+        expect(App.ServiceConfigVersion.find().mapProperty('id')).to.eql(['SERVICE1_1','SERVICE2_4']);
+      });
+
+      it('SERVICE1_1 createTime', function () {
+        expect(App.ServiceConfigVersion.find('SERVICE1_1').get('createTime')).to.equal(1425979244738);
+      });
+      it('SERVICE1_1 groupId', function () {
+        expect(App.ServiceConfigVersion.find('SERVICE1_1').get('groupId')).to.equal(-1);
+      });
+      it('SERVICE1_1 hosts', function () {
+        expect(App.ServiceConfigVersion.find('SERVICE1_1').get('hosts')).to.eql(defaultAllHosts);
+      });
+      it('SERVICE1_1 isCurrent', function () {
+        expect(App.ServiceConfigVersion.find('SERVICE1_1').get('isCurrent')).to.be.true;
+      });
+      it('SERVICE1_1 version', function () {
+        expect(App.ServiceConfigVersion.find('SERVICE1_1').get('version')).to.equal(1);
+      });
+      it('SERVICE1_1 notes', function () {
+        expect(App.ServiceConfigVersion.find('SERVICE1_1').get('notes')).to.equal("Initial configurations for SERVICE1");
+      });
+      it('SERVICE1_1 serviceName', function () {
+        expect(App.ServiceConfigVersion.find('SERVICE1_1').get('serviceName')).to.equal("SERVICE1");
+      });
+      it('SERVICE1_1 author', function () {
+        expect(App.ServiceConfigVersion.find('SERVICE1_1').get('author')).to.equal("admin");
+      });
+
+      it('SERVICE2_4 createTime', function () {
+        expect(App.ServiceConfigVersion.find('SERVICE2_4').get('createTime')).to.equal(1426088137115);
+      });
+      it('SERVICE2_4 groupId', function () {
+        expect(App.ServiceConfigVersion.find('SERVICE2_4').get('groupId')).to.equal(2);
+      });
+      it('SERVICE2_4 hosts', function () {
+        expect(App.ServiceConfigVersion.find('SERVICE2_4').get('hosts')).to.eql(["host1"]);
+      });
+      it('SERVICE2_4 isCurrent', function () {
+        expect(App.ServiceConfigVersion.find('SERVICE2_4').get('isCurrent')).to.be.false;
+      });
+      it('SERVICE2_4 version', function () {
+        expect(App.ServiceConfigVersion.find('SERVICE2_4').get('version')).to.equal(4);
+      });
+      it('SERVICE2_4 notes', function () {
+        expect(App.ServiceConfigVersion.find('SERVICE2_4').get('notes')).to.equal("");
+      });
+      it('SERVICE2_4 serviceName', function () {
+        expect(App.ServiceConfigVersion.find('SERVICE2_4').get('serviceName')).to.equal("SERVICE2");
+      });
+      it('SERVICE2_4 author', function () {
+        expect(App.ServiceConfigVersion.find('SERVICE2_4').get('author')).to.equal("admin");
+      });
     });
   });
 

+ 218 - 164
ambari-web/test/mappers/configs/stack_config_properties_mapper_test.js

@@ -21,196 +21,250 @@ require('mappers/configs/stack_config_properties_mapper');
 
 describe.skip('App.stackConfigPropertiesMapper', function () {
 
-  describe("#map", function() {
-
-    var json = { items: [
-      {
-        "StackServices" : {
-          "service_name" : "HBASE",
-          "stack_name" : "HDP",
-          "stack_version" : "2.2",
-          "config_types" : {
-            "site1" : {
-              "supports" : {
-                "adding_forbidden" : "false",
-                "do_not_extend" : "false",
-                "final" : "true"
+  describe("#map", function () {
+
+    var json = {
+      items: [
+        {
+          "StackServices": {
+            "service_name": "HBASE",
+            "stack_name": "HDP",
+            "stack_version": "2.2",
+            "config_types": {
+              "site1": {
+                "supports": {
+                  "adding_forbidden": "false",
+                  "do_not_extend": "false",
+                  "final": "true"
+                }
               }
             }
-          }
-        },
-        "configurations" : [
-          {
-            "StackConfigurations" : {
-              "final" : "false",
-              "property_description" : "desc1",
-              "property_name" : "p1",
-              "property_display_name" : "P1",
-              "property_type" : [ ],
-              "property_value" : "v1",
-              "service_name" : "s1",
-              "stack_name" : "HDP",
-              "stack_version" : "2.2",
-              "type" : "site1.xml",
-              "property_depends_on": [
+          },
+          "configurations": [
+            {
+              "StackConfigurations": {
+                "final": "false",
+                "property_description": "desc1",
+                "property_name": "p1",
+                "property_display_name": "P1",
+                "property_type": [],
+                "property_value": "v1",
+                "service_name": "s1",
+                "stack_name": "HDP",
+                "stack_version": "2.2",
+                "type": "site1.xml",
+                "property_depends_on": [
+                  {
+                    "name": "p5",
+                    "type": "site5"
+                  }
+                ],
+                "property_value_attributes": {
+                  "type": "int",
+                  "minimum": "512",
+                  "maximum": "10240",
+                  "unit": "MB"
+                }
+              },
+              "dependencies": [
                 {
-                  "name": "p5",
-                  "type": "site5"
+                  "StackConfigurationDependency": {
+                    "dependency_name": "p4",
+                    "dependency_type": "site4"
+                  }
+                }
+              ]
+            }
+          ]
+        },
+        {
+          "StackServices": {
+            "service_name": "HDFS",
+            "stack_name": "HDP",
+            "stack_version": "2.2",
+            "config_types": {
+              "site2": {
+                "supports": {
+                  "adding_forbidden": "false",
+                  "do_not_extend": "false",
+                  "final": "true"
+                }
+              },
+              "site3": {
+                "supports": {
+                  "adding_forbidden": "false",
+                  "do_not_extend": "false",
+                  "final": "true"
                 }
-              ],
-              "property_value_attributes": {
-                "type": "int",
-                "minimum": "512",
-                "maximum": "10240",
-                "unit": "MB"
+              }
+            }
+          },
+          "configurations": [
+            {
+              "StackConfigurations": {
+                "final": "false",
+                "property_description": "desc3",
+                "property_name": "p2",
+                "property_display_name": "P2",
+                "property_type": [],
+                "property_value": "v2",
+                "service_name": "s2",
+                "stack_name": "HDP",
+                "stack_version": "2.2",
+                "type": "site2.xml"
               }
             },
-            "dependencies": [
-              {
-                "StackConfigurationDependency" : {
-                  "dependency_name" : "p4",
-                  "dependency_type" : "site4"
-                }
+            {
+              "StackConfigurations": {
+                "final": "false",
+                "property_description": "desc3",
+                "property_name": "p3",
+                "property_display_name": "P3",
+                "property_type": [],
+                "property_value": "v3",
+                "service_name": "s2",
+                "stack_name": "HDP",
+                "stack_version": "2.2",
+                "type": "site3.xml"
               }
-            ]
-          }
-        ]
-      },
-      {
-        "StackServices" : {
-          "service_name" : "HDFS",
-          "stack_name" : "HDP",
-          "stack_version" : "2.2",
-          "config_types" : {
-            "site2" : {
-              "supports" : {
-                "adding_forbidden" : "false",
-                "do_not_extend" : "false",
-                "final" : "true"
+            },
+            {
+              "StackConfigurations": {
+                "final": "false",
+                "property_description": "desc4",
+                "property_name": "p4",
+                "property_display_name": "P4",
+                "property_type": ["PASSWORD"],
+                "property_value": "v4",
+                "service_name": "s2",
+                "stack_name": "HDP",
+                "stack_version": "2.2",
+                "type": "site3.xml"
               }
             },
-            "site3" : {
-              "supports" : {
-                "adding_forbidden" : "false",
-                "do_not_extend" : "false",
-                "final" : "true"
+            {
+              "StackConfigurations": {
+                "final": "false",
+                "property_description": "desc5",
+                "property_name": "p5",
+                "property_display_name": "P5",
+                "property_type": ["USER"],
+                "property_value": "v4",
+                "service_name": "s2",
+                "stack_name": "HDP",
+                "stack_version": "2.2",
+                "type": "site3.xml"
               }
             }
-          }
-        },
-        "configurations" : [
-          {
-            "StackConfigurations" : {
-              "final" : "false",
-              "property_description" : "desc3",
-              "property_name" : "p2",
-              "property_display_name" : "P2",
-              "property_type" : [ ],
-              "property_value" : "v2",
-              "service_name" : "s2",
-              "stack_name" : "HDP",
-              "stack_version" : "2.2",
-              "type" : "site2.xml"
-            }
-          },
-          {
-            "StackConfigurations" : {
-              "final" : "false",
-              "property_description" : "desc3",
-              "property_name" : "p3",
-              "property_display_name" : "P3",
-              "property_type" : [ ],
-              "property_value" : "v3",
-              "service_name" : "s2",
-              "stack_name" : "HDP",
-              "stack_version" : "2.2",
-              "type" : "site3.xml"
-            }
-          },
-          {
-            "StackConfigurations" : {
-              "final" : "false",
-              "property_description" : "desc4",
-              "property_name" : "p4",
-              "property_display_name" : "P4",
-              "property_type" : [ "PASSWORD" ],
-              "property_value" : "v4",
-              "service_name" : "s2",
-              "stack_name" : "HDP",
-              "stack_version" : "2.2",
-              "type" : "site3.xml"
-            }
-          },
-          {
-            "StackConfigurations" : {
-              "final" : "false",
-              "property_description" : "desc5",
-              "property_name" : "p5",
-              "property_display_name" : "P5",
-              "property_type" : [ "USER" ],
-              "property_value" : "v4",
-              "service_name" : "s2",
-              "stack_name" : "HDP",
-              "stack_version" : "2.2",
-              "type" : "site3.xml"
-            }
-          }
-        ]
-      }
-    ]};
+          ]
+        }
+      ]
+    };
 
     beforeEach(function () {
       App.resetDsStoreTypeMap(App.StackConfigProperty);
       sinon.stub(App.store, 'commit', Em.K);
-      sinon.stub(App.StackService, 'find', function() { return Em.A()});
+      sinon.stub(App.StackService, 'find', function () {
+        return Em.A()
+      });
     });
-    afterEach(function(){
+    afterEach(function () {
       App.store.commit.restore();
       App.StackService.find.restore();
     });
 
-    it('should not do anything as there is no json', function() {
+    it('should not do anything as there is no json', function () {
       App.stackConfigPropertiesMapper.map(null);
       expect(App.StackConfigProperty.find().get('length')).to.equal(0);
     });
 
-    it('should load data to model', function() {
-      App.stackConfigPropertiesMapper.map(json);
-      expect(App.StackConfigProperty.find().get('length')).to.equal(5);
-      expect(App.StackConfigProperty.find().mapProperty('id')).to.eql(['p1__site1','p2__site2','p3__site3', 'p4__site3', 'p5__site3']);
-
-      expect(App.StackConfigProperty.find('p1__site1').get('name')).to.eql('p1');
-      expect(App.StackConfigProperty.find('p1__site1').get('displayName')).to.eql('P1');
-      expect(App.StackConfigProperty.find('p1__site1').get('description')).to.eql('desc1');
-      expect(App.StackConfigProperty.find('p1__site1').get('recommendedValue')).to.eql('v1');
-      expect(App.StackConfigProperty.find('p1__site1').get('recommendedIsFinal')).to.be.false;
-      expect(App.StackConfigProperty.find('p1__site1').get('serviceName')).to.eql('s1');
-      expect(App.StackConfigProperty.find('p1__site1').get('stackName')).to.eql('HDP');
-      expect(App.StackConfigProperty.find('p1__site1').get('stackVersion')).to.eql('2.2');
-      expect(App.StackConfigProperty.find('p1__site1').get('type').toArray()).to.eql([]);
-      expect(App.StackConfigProperty.find('p1__site1').get('fileName')).to.eql('site1.xml');
-      expect(App.StackConfigProperty.find('p1__site1').get('propertyDependedBy')).to.eql([
-        {
-          "type": "site4",
-          "name": "p4"
-        }
-      ]);
-      expect(App.StackConfigProperty.find('p1__site1').get('propertyDependsOn')).to.eql([
-        {
-          "type": "site5",
-          "name": "p5"
-        }
-      ]);
-      expect(App.StackConfigProperty.find('p1__site1').get('valueAttributes')).to.eql({
-        "type": "int",
-        "minimum": "512",
-        "maximum": "10240",
-        "unit": "MB"
-      });
-      expect(App.StackConfigProperty.find('p1__site1').get('supportsFinal')).to.be.true;
+    describe('should load data to model', function () {
+
+      beforeEach(function () {
+        App.stackConfigPropertiesMapper.map(json);
+      });
+
+      it('5 properties are mapped', function () {
+        expect(App.StackConfigProperty.find().get('length')).to.equal(5);
+      });
+
+      it('ids are valid', function () {
+        expect(App.StackConfigProperty.find().mapProperty('id')).to.eql(['p1__site1', 'p2__site2', 'p3__site3', 'p4__site3', 'p5__site3']);
+      });
+
+      it('name is valid', function () {
+        expect(App.StackConfigProperty.find('p1__site1').get('name')).to.eql('p1');
+      });
+
+      it('displayName is valid', function () {
+        expect(App.StackConfigProperty.find('p1__site1').get('displayName')).to.eql('P1');
+      });
+
+      it('description is valid', function () {
+        expect(App.StackConfigProperty.find('p1__site1').get('description')).to.eql('desc1');
+      });
+
+      it('recommendedValue is valid', function () {
+        expect(App.StackConfigProperty.find('p1__site1').get('recommendedValue')).to.eql('v1');
+      });
+
+      it('recommendedIsFinal is valid', function () {
+        expect(App.StackConfigProperty.find('p1__site1').get('recommendedIsFinal')).to.be.false;
+      });
+
+      it('serviceName is valid', function () {
+        expect(App.StackConfigProperty.find('p1__site1').get('serviceName')).to.eql('s1');
+      });
+
+      it('stackName is valid', function () {
+        expect(App.StackConfigProperty.find('p1__site1').get('stackName')).to.eql('HDP');
+      });
+
+      it('stackVersion is valid', function () {
+        expect(App.StackConfigProperty.find('p1__site1').get('stackVersion')).to.eql('2.2');
+      });
+
+      it('type is valid', function () {
+        expect(App.StackConfigProperty.find('p1__site1').get('type').toArray()).to.eql([]);
+      });
+
+      it('fileName is valid', function () {
+        expect(App.StackConfigProperty.find('p1__site1').get('fileName')).to.eql('site1.xml');
+      });
+
+      it('propertyDependedBy is valid', function () {
+        expect(App.StackConfigProperty.find('p1__site1').get('propertyDependedBy')).to.eql([
+          {
+            "type": "site4",
+            "name": "p4"
+          }
+        ]);
+      });
+
+      it('propertyDependsOn is valid', function () {
+        expect(App.StackConfigProperty.find('p1__site1').get('propertyDependsOn')).to.eql([
+          {
+            "type": "site5",
+            "name": "p5"
+          }
+        ]);
+      });
+
+      it('valueAttributes is valid', function () {
+        expect(App.StackConfigProperty.find('p1__site1').get('valueAttributes')).to.eql({
+          "type": "int",
+          "minimum": "512",
+          "maximum": "10240",
+          "unit": "MB"
+        });
+      });
+
+      it('supportsFinal is valid', function () {
+        expect(App.StackConfigProperty.find('p1__site1').get('supportsFinal')).to.be.true;
+      });
     });
 
-    it('should set "displayType" by "property_type" attribute', function() {
+    it('should set "displayType" by "property_type" attribute', function () {
       App.stackConfigPropertiesMapper.map(json);
       var prop = App.StackConfigProperty.find().findProperty('name', 'p4');
       var prop2 = App.StackConfigProperty.find().findProperty('name', 'p5');

+ 98 - 82
ambari-web/test/mappers/configs/themes_mapper_test.js

@@ -92,45 +92,45 @@ describe('App.themeMapper', function () {
                     }
                   ],
                   "widgets": [
-                              {
-                                "config": "c1/p1",
-                                "widget": {
-                                  "type": "slider",
-                                  "units": [
-                                            {
-                                              "unit-name": "MB"
-                                            },
-                                            {
-                                              "unit-name": "GB"
-                                            }
-                                            ]
-                                }
-                              },
-                              {
-                                "config": "c1/p2",
-                                "widget": {
-                                  "type": "slider",
-                                  "units": [
-                                            {
-                                              "unit-name": "percent"
-                                            }
-                                            ]
-                                }
-                              }
-                              ],
-                              "placement": {
-                                "configuration-layout": "default",
-                                "configs": [
-                                            {
-                                              "config": "c1/p1",
-                                              "subsection-name": "subsection1"
-                                            },
-                                            {
-                                              "config": "c1/p2",
-                                              "subsection-name": "subsection1"
-                                            }
-                                            ]
-                              }
+                    {
+                      "config": "c1/p1",
+                      "widget": {
+                        "type": "slider",
+                        "units": [
+                          {
+                            "unit-name": "MB"
+                          },
+                          {
+                            "unit-name": "GB"
+                          }
+                        ]
+                      }
+                    },
+                    {
+                      "config": "c1/p2",
+                      "widget": {
+                        "type": "slider",
+                        "units": [
+                          {
+                            "unit-name": "percent"
+                          }
+                        ]
+                      }
+                    }
+                  ],
+                  "placement": {
+                    "configuration-layout": "default",
+                    "configs": [
+                      {
+                        "config": "c1/p1",
+                        "subsection-name": "subsection1"
+                      },
+                      {
+                        "config": "c1/p2",
+                        "subsection-name": "subsection1"
+                      }
+                    ]
+                  }
                 }
               }
             }
@@ -139,56 +139,72 @@ describe('App.themeMapper', function () {
       ]
     };
 
-    it('should map theme data', function () {
+    describe('should map theme data', function () {
 
-      App.themesMapper.map(json);
+      beforeEach(function () {
+        App.themesMapper.map(json);
+      });
 
-      expect(App.Tab.find().get('length')).to.equal(1);
-      expect(App.Section.find().get('length')).to.equal(2);
-      expect(App.SubSection.find().get('length')).to.equal(1);
+      it('1 Tab is mapped', function () {
+        expect(App.Tab.find().get('length')).to.equal(1);
+      });
 
-      //checking tab
-      expect(App.Tab.find('HDFS_settings').toJSON()).to.eql({
-        id: 'HDFS_settings',
-        name: 'settings',
-        display_name: 'Settings',
-        columns: "2",
-        rows: "1",
-        is_advanced: false,
-        service_name: 'HDFS',
-        is_advanced_hidden: false,
-        is_rendered: false,
-        is_configs_prepared: false
+      it('2 Sections are mapped', function () {
+        expect(App.Section.find().get('length')).to.equal(2);
+      });
+
+      it('1 SubSection is mapped', function () {
+        expect(App.SubSection.find().get('length')).to.equal(1);
+      });
+
+      it('HDFS_settings tab is mapped correctly', function () {
+        //checking tab
+        expect(App.Tab.find('HDFS_settings').toJSON()).to.eql({
+          id: 'HDFS_settings',
+          name: 'settings',
+          display_name: 'Settings',
+          columns: "2",
+          rows: "1",
+          is_advanced: false,
+          service_name: 'HDFS',
+          is_advanced_hidden: false,
+          is_rendered: false,
+          is_configs_prepared: false
+        });
       });
 
-      //checking section
-      expect(App.Tab.find('HDFS_settings').get('sections').objectAt(0).toJSON()).to.eql({
-        "id": "Section-1",
-        "name": "Section-1",
-        "display_name": "Section One",
-        "row_index": "0",
-        "row_span": "1",
-        "column_index": "0",
-        "column_span": "1",
-        "section_columns": "2",
-        "section_rows": "3",
-        "tab_id": "HDFS_settings"
+      it('HDFS_settings section is mapped correctly', function () {
+        //checking section
+        expect(App.Tab.find('HDFS_settings').get('sections').objectAt(0).toJSON()).to.eql({
+          "id": "Section-1",
+          "name": "Section-1",
+          "display_name": "Section One",
+          "row_index": "0",
+          "row_span": "1",
+          "column_index": "0",
+          "column_span": "1",
+          "section_columns": "2",
+          "section_rows": "3",
+          "tab_id": "HDFS_settings"
+        });
       });
 
-      //checking subsection
-      expect(App.Tab.find('HDFS_settings').get('sections').objectAt(0).get('subSections').objectAt(0).toJSON()).to.eql({
-        "id": "subsection1",
-        "name": "subsection1",
-        "display_name": "Storage",
-        "border": "false",
-        "row_index": "0",
-        "row_span": "1",
-        "column_index": "0",
-        "depends_on": [],
-        "config_properties": [],
-        "left_vertical_splitter": true,
-        "column_span": "1",
-        "section_id": "Section-1"
+      it('HDFS_settings section subsection is mapped correctly', function () {
+        //checking subsection
+        expect(App.Tab.find('HDFS_settings').get('sections').objectAt(0).get('subSections').objectAt(0).toJSON()).to.eql({
+          "id": "subsection1",
+          "name": "subsection1",
+          "display_name": "Storage",
+          "border": "false",
+          "row_index": "0",
+          "row_span": "1",
+          "column_index": "0",
+          "depends_on": [],
+          "config_properties": [],
+          "left_vertical_splitter": true,
+          "column_span": "1",
+          "section_id": "Section-1"
+        });
       });
     });
   });

+ 9 - 6
ambari-web/test/mappers/service_mapper_test.js

@@ -255,16 +255,19 @@ describe('App.serviceMetricsMapper', function () {
       }
     ];
 
+    beforeEach(function () {
+      this.stub = sinon.stub(App, 'get');
+    });
+
+    afterEach(function () {
+      App.get.restore();
+    });
+
     tests.forEach(function(test) {
       it(test.message, function() {
-        sinon.stub(App, 'get', function(key) {
-          if (key == 'currentStackVersionNumber') {
-            return test.stackVersionNumber;
-          }
-        });
+        this.stub.withArgs('currentStackVersionNumber').returns(test.stackVersionNumber);
         var result = App.serviceMetricsMapper.stormMapper(test);
         expect(result).to.include(test.expectedValues);
-        App.get.restore();
       });
     });
 

+ 18 - 6
ambari-web/test/mappers/stack_mapper_test.js

@@ -261,29 +261,41 @@ describe('App.stackMapper', function () {
       App.resetDsStoreTypeMap(App.OperatingSystem);
       App.resetDsStoreTypeMap(App.Stack);
       sinon.stub(App.store, 'commit', Em.K);
+      App.stackMapper.map(test_data);
     });
     afterEach(function(){
       App.store.commit.restore();
     });
 
-		
     it ('should map active Stack data', function() {
-      App.stackMapper.map(test_data);
       expect(App.Stack.find().get('length')).to.equal(2);
+    });
+
+    it ('all stacks are active', function() {
       expect(App.Stack.find().everyProperty('active')).to.equal(true);
+    });
+
+    it ('no one stack is selected', function() {
       expect(App.Stack.find().everyProperty('isSelected')).to.equal(false);
+    });
+
+    it ('stack ids are valid', function() {
       expect(App.Stack.find().mapProperty('id')).to.eql(['HDP-2.1','HDP-1.3']);
     });
 
-    it ('should map Operating System data', function() {
-      App.stackMapper.map(test_data);
+    it ('4 OSes are mapped', function() {
       expect(App.OperatingSystem.find().get('length')).to.equal(4);
+    });
+
+    it ('OSes have valid ids', function() {
       expect(App.OperatingSystem.find().mapProperty('id')).to.eql(['HDP-2.1-redhat5', 'HDP-2.1-redhat6', 'HDP-1.3-redhat5', 'HDP-1.3-redhat6']);
     });
     
-    it ('should map Repository data', function() {
-      App.stackMapper.map(test_data);
+    it ('8 repositories are mapped', function() {
       expect(App.Repository.find().get('length')).to.equal(8);
+    });
+
+    it ('Repositories ids are valid', function() {
       expect(App.Repository.find().mapProperty('id')).to.eql(["HDP-2.1-redhat5-HDP-2.1", "HDP-2.1-redhat5-HDP-UTILS-1.1.0.17", "HDP-2.1-redhat6-HDP-2.1", "HDP-2.1-redhat6-HDP-UTILS-1.1.0.17", "HDP-1.3-redhat5-HDP-1.3", "HDP-1.3-redhat5-HDP-UTILS-1.1.0.16", "HDP-1.3-redhat6-HDP-1.3", "HDP-1.3-redhat6-HDP-UTILS-1.1.0.16"]);
     });
   });

+ 4 - 6
ambari-web/test/utils/blueprint_test.js

@@ -441,12 +441,10 @@ describe('utils/blueprint', function() {
       expect(blueprintUtils._generateHostMap({}, [],'c1')).to.eql({});
     });
 
-    it('skip throws error when data is wrong', function() {
-      it('should assert error if no data returned from server', function () {
-        expect(function () {
-          blueprintUtils._generateHostMap();
-        }).to.throw(Error);
-      });
+    it('skip throws error when data is wrong (should assert error if no data returned from server)', function() {
+      expect(function () {
+        blueprintUtils._generateHostMap();
+      }).to.throw(Error);
     });
   });
 });

+ 1 - 4
ambari-web/test/utils/helper_test.js

@@ -239,10 +239,7 @@ describe('utils/helper', function() {
         expect(App.isEmptyObject({ a: 1 })).to.eql(false);
       });
     });
-    describe('#parseJSON()', function(){
-      var testable = '{"hello": "world"}';
-      expect(App.parseJSON(testable).hello).to.eql('world');
-    });
+
     describe('#tooltip()', function() {
       beforeEach(appendDiv);
       afterEach(removeDiv);

+ 0 - 59
ambari-web/test/views/main/alerts/manage_alert_groups_view_test.js

@@ -32,65 +32,6 @@ describe('App.MainAlertsManageAlertGroupView', function () {
     view = getView();
   });
 
-  it('#buttonObserver', function () {
-
-    Em.A([
-      {
-        p: {
-          isRemoveButtonDisabled: false,
-          isRenameButtonDisabled: false,
-          isDuplicateButtonDisabled: true
-        },
-        selectedAlertGroup: {default: true},
-        m: 'selected alert group is default',
-        e: {
-          isRemoveButtonDisabled: true,
-          isRenameButtonDisabled: true,
-          isDuplicateButtonDisabled: false
-        }
-      },
-      {
-        p: {
-          isRemoveButtonDisabled: true,
-          isRenameButtonDisabled: true,
-          isDuplicateButtonDisabled: true
-        },
-        selectedAlertGroup: {default: false},
-        m: 'selected alert group is not default',
-        e: {
-          isRemoveButtonDisabled: false,
-          isRenameButtonDisabled: false,
-          isDuplicateButtonDisabled: false
-        }
-      },
-      {
-        p: {
-          isRemoveButtonDisabled: true,
-          isRenameButtonDisabled: true,
-          isDuplicateButtonDisabled: true
-        },
-        selectedAlertGroup: null,
-        m: 'not one alert group is selected',
-        e: {
-          isRemoveButtonDisabled: false,
-          isRenameButtonDisabled: false,
-          isDuplicateButtonDisabled: false
-        }
-      }
-    ]).forEach(function (test) {
-        it(test.m, function () {
-          Em.keys(test.p).forEach(function (k) {
-            view.set(k, test.p[k]);
-          });
-          view.set('controller.selectedAlertGroup', test.selectedAlertGroup);
-          Em.keys(test.e).forEach(function (k) {
-            expect(view.get(k)).to.equal(test.e[k]);
-          });
-        });
-      });
-
-  });
-
   App.TestAliases.testAsComputedIfThenElse(getView(), 'removeButtonTooltip', 'controller.isRemoveButtonDisabled', Em.I18n.t('alerts.actions.manage_alert_groups_popup.removeButtonDisabled'), Em.I18n.t('alerts.actions.manage_alert_groups_popup.removeButton'))
 
 });

+ 8 - 7
ambari-web/test/views/main/service/info/summary_test.js

@@ -185,14 +185,15 @@ describe('App.MainServiceInfoSummaryView', function() {
         serviceName: 'HDFS'
       }));
       expect(view.get('hasAlertDefinitions')).to.be.true;
+    });
+
+    it('should return false if there is no alert definition for this service', function () {
+      view.set('controller.content', Em.Object.create({
+        serviceName: 'ZOOKEEPER'
+      }));
+      expect(view.get('hasAlertDefinitions')).to.be.false;
+    });
 
-      it('should return false if there is no alert definition for this service', function () {
-        view.set('controller.content', Em.Object.create({
-          serviceName: 'ZOOKEEPER'
-        }));
-        expect(view.get('hasAlertDefinitions')).to.be.false;
-      });
-    })
   });
 
   describe('#didInsertElement', function () {