Преглед изворни кода

AMBARI-14531. Improve Ambari UI UT (p.4) (onechiporenko)

Oleg Nechiporenko пре 9 година
родитељ
комит
b8aede2a8e
43 измењених фајлова са 1773 додато и 1165 уклоњено
  1. 18 10
      ambari-web/test/controllers/global/update_controller_test.js
  2. 129 119
      ambari-web/test/controllers/installer_test.js
  3. 20 8
      ambari-web/test/controllers/main/admin/highAvailability/nameNode/step3_controller_test.js
  4. 16 7
      ambari-web/test/controllers/main/admin/highAvailability/nameNode/step4_controller_test.js
  5. 35 29
      ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js
  6. 48 38
      ambari-web/test/controllers/main/alerts/definitions_configs_controller_test.js
  7. 39 17
      ambari-web/test/controllers/main/charts/heatmap_metrics/heatmap_metric_test.js
  8. 26 14
      ambari-web/test/controllers/main/charts/heatmap_test.js
  9. 150 96
      ambari-web/test/controllers/main/host/add_controller_test.js
  10. 100 55
      ambari-web/test/controllers/main/host/details_test.js
  11. 16 6
      ambari-web/test/controllers/main/service/add_controller_test.js
  12. 27 8
      ambari-web/test/controllers/main/service/info/summary_test.js
  13. 66 45
      ambari-web/test/controllers/main/service/item_test.js
  14. 53 56
      ambari-web/test/controllers/main/service/manage_config_groups_controller_test.js
  15. 6 12
      ambari-web/test/controllers/main/service/reassign/step4_controller_test.js
  16. 17 10
      ambari-web/test/controllers/main/service_test.js
  17. 24 10
      ambari-web/test/controllers/wizard/step10_test.js
  18. 50 21
      ambari-web/test/controllers/wizard/step3_test.js
  19. 61 45
      ambari-web/test/controllers/wizard/step4_test.js
  20. 18 11
      ambari-web/test/controllers/wizard/step5_test.js
  21. 111 83
      ambari-web/test/controllers/wizard/step6_test.js
  22. 83 58
      ambari-web/test/controllers/wizard/step7_test.js
  23. 229 168
      ambari-web/test/controllers/wizard/step8_test.js
  24. 84 61
      ambari-web/test/controllers/wizard/step9_test.js
  25. 5 2
      ambari-web/test/controllers/wizard_test.js
  26. 2 0
      ambari-web/test/helpers.js
  27. 2 0
      ambari-web/test/mappers/stack_service_mapper_test.js
  28. 19 10
      ambari-web/test/mixins/common/serverValidator_test.js
  29. 2 1
      ambari-web/test/models/form_test.js
  30. 28 17
      ambari-web/test/utils/config_test.js
  31. 42 21
      ambari-web/test/utils/configs/config_initializer_test.js
  32. 53 30
      ambari-web/test/views/common/configs/widgets/config_widget_view_test.js
  33. 9 7
      ambari-web/test/views/common/configs/widgets/list_config_widget_view_test.js
  34. 26 19
      ambari-web/test/views/common/configs/widgets/slider_config_widget_view_test.js
  35. 2 2
      ambari-web/test/views/common/configs/widgets/toggle_config_widget_view_test.js
  36. 23 12
      ambari-web/test/views/common/controls_view_test.js
  37. 18 9
      ambari-web/test/views/common/rolling_restart_view_test.js
  38. 20 8
      ambari-web/test/views/main/admin/stack_upgrade/upgrade_wizard_view_test.js
  39. 18 8
      ambari-web/test/views/main/alerts/manage_alert_groups/select_definitions_popup_body_view_test.js
  40. 41 16
      ambari-web/test/views/main/dashboard/widget_test.js
  41. 18 8
      ambari-web/test/views/main/dashboard/widgets_test.js
  42. 7 1
      ambari-web/test/views/main/host/details_test.js
  43. 12 7
      ambari-web/test/views/wizard/step5_view_test.js

+ 18 - 10
ambari-web/test/controllers/global/update_controller_test.js

@@ -427,16 +427,24 @@ describe('App.UpdateController', function () {
     });
 
     cases.forEach(function (item) {
-      it(item.title, function () {
-        appGetMock.withArgs('router.mainAdminStackAndUpgradeController').returns(Em.Object.create({
-          loadUpgradeData: mock.loadUpgradeData,
-          isLoadUpgradeDataPending: item.isLoadUpgradeDataPending
-        })).withArgs('wizardIsNotFinished').returns(item.wizardIsNotFinished)
-          .withArgs('router.currentState.name').returns(item.currentStateName)
-          .withArgs('router.currentState.parentState.name').returns(item.parentStateName);;
-        controller.updateUpgradeState(mock.callback);
-        expect(mock.loadUpgradeData.callCount).to.equal(item.loadUpgradeDataCallCount);
-        expect(mock.callback.callCount).to.equal(item.callbackCallCount);
+      describe(item.title, function () {
+
+        beforeEach(function () {
+          appGetMock.withArgs('router.mainAdminStackAndUpgradeController').returns(Em.Object.create({
+            loadUpgradeData: mock.loadUpgradeData,
+            isLoadUpgradeDataPending: item.isLoadUpgradeDataPending
+          })).withArgs('wizardIsNotFinished').returns(item.wizardIsNotFinished)
+            .withArgs('router.currentState.name').returns(item.currentStateName)
+            .withArgs('router.currentState.parentState.name').returns(item.parentStateName);
+          controller.updateUpgradeState(mock.callback);
+        });
+        it('loadUpgradeData is called ' + item.loadUpgradeDataCallCount + ' times', function () {
+          expect(mock.loadUpgradeData.callCount).to.equal(item.loadUpgradeDataCallCount);
+        });
+        it('callback is called ' + item.callbackCallCount + ' times', function () {
+          expect(mock.callback.callCount).to.equal(item.callbackCallCount);
+        });
+
       });
     });
 

+ 129 - 119
ambari-web/test/controllers/installer_test.js

@@ -94,38 +94,38 @@ describe('App.InstallerController', function () {
   });
 
   describe('#checkRepoURL', function() {
-
+    var stacks = Em.A([
+      Em.Object.create({
+        isSelected: false
+      }),
+      Em.Object.create({
+        isSelected: true,
+        reload: false,
+        id: 'nn-cc',
+        repositories: Em.A([
+          Em.Object.create({
+            isSelected: true
+          })
+        ]),
+        operatingSystems: Em.A([
+          Em.Object.create({
+            isSelected: true,
+            repositories: Em.A([
+              Em.Object.create({
+                errorTitle: '1',
+                errorContent: '1',
+                validation: ''
+              })
+            ])
+          })
+        ])
+      })
+    ]);
+    var wizard = Em.Object.create({
+      skipValidationChecked: true
+    });
     it ('Should reload installed stacks', function() {
-      var stacks = Em.A([
-        Em.Object.create({
-          isSelected: false
-        }),
-        Em.Object.create({
-          isSelected: true,
-          reload: false,
-          id: 'nn-cc',
-          repositories: Em.A([
-            Em.Object.create({
-              isSelected: true
-            })
-          ]),
-          operatingSystems: Em.A([
-            Em.Object.create({
-              isSelected: true,
-              repositories: Em.A([
-                Em.Object.create({
-                  errorTitle: '1',
-                  errorContent: '1',
-                  validation: ''
-                })
-              ])
-            })
-          ])
-        })
-      ]);
-      var wizard = Em.Object.create({
-        skipValidationChecked: true
-      });
+
       installerController.set('content.stacks', stacks);
       installerController.checkRepoURL(wizard);
 
@@ -164,47 +164,48 @@ describe('App.InstallerController', function () {
   });
 
   describe('#checkRepoURLSuccessCallback', function() {
-    it ('Should check stacks for sucess', function() {
-      var stacks = Em.A([
-        Em.Object.create({
-          isSelected: false
-        }),
-        Em.Object.create({
-          isSelected: true,
-          reload: false,
-          id: 'nn-cc',
-          repositories: Em.A([
-            Em.Object.create({
-              repoId: 11,
-              isSelected: true
-            })
-          ]),
-          operatingSystems: Em.A([
-            Em.Object.create({
-              isSelected: true,
-              id: 1,
-              repositories: Em.A([
-                Em.Object.create({
-                  repoId: 11,
-                  errorTitle: '1',
-                  errorContent: '1',
-                  validation: ''
-                })
-              ])
-            })
-          ])
-        })
-      ]);
-      var resolve = false;
-      var data = {
-        osId: 1,
-        repoId: 11,
-        dfd: {
-          resolve: function() {
-            resolve = true;
-          }
+    var stacks = Em.A([
+      Em.Object.create({
+        isSelected: false
+      }),
+      Em.Object.create({
+        isSelected: true,
+        reload: false,
+        id: 'nn-cc',
+        repositories: Em.A([
+          Em.Object.create({
+            repoId: 11,
+            isSelected: true
+          })
+        ]),
+        operatingSystems: Em.A([
+          Em.Object.create({
+            isSelected: true,
+            id: 1,
+            repositories: Em.A([
+              Em.Object.create({
+                repoId: 11,
+                errorTitle: '1',
+                errorContent: '1',
+                validation: ''
+              })
+            ])
+          })
+        ])
+      })
+    ]);
+    var data = {
+      osId: 1,
+      repoId: 11,
+      dfd: {
+        resolve: function() {
+          resolve = true;
         }
-      };
+      }
+    };
+    var resolve = false;
+    it ('Should check stacks for sucess', function() {
+
       installerController.set('content.stacks', stacks);
       installerController.checkRepoURLSuccessCallback(null,null,data);
 
@@ -246,47 +247,48 @@ describe('App.InstallerController', function () {
   });
 
   describe('#checkRepoURLErrorCallback', function() {
-    it ('Should check stacks for error', function() {
-      var stacks = Em.A([
-        Em.Object.create({
-          isSelected: false
-        }),
-        Em.Object.create({
-          isSelected: true,
-          reload: false,
-          id: 'nn-cc',
-          repositories: Em.A([
-            Em.Object.create({
-              repoId: 11,
-              isSelected: true
-            })
-          ]),
-          operatingSystems: Em.A([
-            Em.Object.create({
-              isSelected: true,
-              id: 1,
-              repositories: Em.A([
-                Em.Object.create({
-                  repoId: 11,
-                  errorTitle: '1',
-                  errorContent: '1',
-                  validation: ''
-                })
-              ])
-            })
-          ])
-        })
-      ]);
-      var resolve = false;
-      var data = {
-        osId: 1,
-        repoId: 11,
-        dfd: {
-          reject: function() {
-            resolve = true;
-          }
+    var stacks = Em.A([
+      Em.Object.create({
+        isSelected: false
+      }),
+      Em.Object.create({
+        isSelected: true,
+        reload: false,
+        id: 'nn-cc',
+        repositories: Em.A([
+          Em.Object.create({
+            repoId: 11,
+            isSelected: true
+          })
+        ]),
+        operatingSystems: Em.A([
+          Em.Object.create({
+            isSelected: true,
+            id: 1,
+            repositories: Em.A([
+              Em.Object.create({
+                repoId: 11,
+                errorTitle: '1',
+                errorContent: '1',
+                validation: ''
+              })
+            ])
+          })
+        ])
+      })
+    ]);
+    var data = {
+      osId: 1,
+      repoId: 11,
+      dfd: {
+        reject: function() {
+          resolve = true;
         }
-      };
+      }
+    };
+    var resolve = false;
+    it ('Should check stacks for error', function() {
+
       var req = {
         status: 500,
         statusText: 'error'
@@ -351,7 +353,8 @@ describe('App.InstallerController', function () {
   });
 
   describe('#setLowerStepsDisable', function() {
-    it ('Should disable lower steps', function() {
+
+    beforeEach(function () {
       var steps = Em.A([
         Em.Object.create({
           step: 0,
@@ -376,6 +379,9 @@ describe('App.InstallerController', function () {
       ]);
       installerController.set('isStepDisabled', steps);
       installerController.setLowerStepsDisable(3);
+    });
+
+    it ('Should disable lower steps', function() {
       var expected = [
         {
           "step": 0,
@@ -398,15 +404,14 @@ describe('App.InstallerController', function () {
           "value": false
         }
       ];
-
       var res = JSON.parse(JSON.stringify(installerController.get('isStepDisabled')));
-
       expect(res).to.eql(expected);
     });
   });
 
   describe('#setStepsEnable', function() {
-    it ('Should enable next steps', function() {
+
+    beforeEach(function () {
       var steps = Em.A([
         Em.Object.create({
           step: 0,
@@ -432,6 +437,9 @@ describe('App.InstallerController', function () {
       installerController.set('isStepDisabled', steps);
       installerController.totalSteps = steps.length - 1;
       installerController.set('currentStep',2);
+    });
+
+    it ('Should enable next steps', function() {
       var expected = [
         {
           "step": 0,
@@ -454,9 +462,7 @@ describe('App.InstallerController', function () {
           "value": true
         }
       ];
-
       var res = JSON.parse(JSON.stringify(installerController.get('isStepDisabled')));
-
       expect(res).to.eql(expected);
     });
   });
@@ -827,8 +833,10 @@ describe('App.InstallerController', function () {
   });
 
   describe('#saveClients', function() {
-    it ('Should return correct clients names', function() {
-      var stepController = Em.Object.create({
+    var stepController;
+
+    beforeEach(function () {
+      stepController = Em.Object.create({
         content: Em.A([
           Em.Object.create({
             isInstalled: true,
@@ -864,6 +872,8 @@ describe('App.InstallerController', function () {
           })
         ])
       });
+    });
+    it ('Should return correct clients names', function() {
       installerController.saveClients(stepController);
       var res = JSON.parse(JSON.stringify(installerController.get('content.clients')));
       expect(res).to.eql([

+ 20 - 8
ambari-web/test/controllers/main/admin/highAvailability/nameNode/step3_controller_test.js

@@ -329,15 +329,27 @@ describe('App.HighAvailabilityWizardStep3Controller', function() {
         value: nameServiceId + '/hawq_default'
       }
     ]).forEach(function (test) {
-      it(test.config.name, function () {
-        test.config.displayName = test.config.name;
-        var configs = [test.config];
-        configs = controller.tweakServiceConfigs(configs);
-        expect(configs[0].value).to.equal(test.value);
-        expect(configs[0].recommendedValue).to.equal(test.value);
+      describe(test.config.name, function () {
+        var configs;
+        beforeEach(function () {
+          test.config.displayName = test.config.name;
+          configs = controller.tweakServiceConfigs([test.config]);
+        });
+
+        it('value is ' + test.value, function () {
+          expect(configs[0].value).to.equal(test.value);
+        });
+        it('recommendedValue is ' + test.value, function () {
+          expect(configs[0].recommendedValue).to.equal(test.value);
+        });
+
         if(test.name) {
-          expect(configs[0].name).to.equal(test.name);
-          expect(configs[0].displayName).to.equal(test.name);
+          it('name is ' + test.name, function () {
+            expect(configs[0].name).to.equal(test.name);
+          });
+          it('displayNamr is' + test.name, function () {
+            expect(configs[0].displayName).to.equal(test.name);
+          });
         }
       });
     });

+ 16 - 7
ambari-web/test/controllers/main/admin/highAvailability/nameNode/step4_controller_test.js

@@ -92,13 +92,22 @@ describe('App.HighAvailabilityWizardStep4Controller', function() {
     ];
 
     tests.forEach(function(test) {
-      it(test.m, function() {
-        this.controller.set('isNameNodeStarted', !test.e.isNameNodeStarted);
-        this.controller.checkNnCheckPointStatus(test.responseData);
-        this.clock.tick(this.controller.get('POLL_INTERVAL'));
-        expect(this.controller.get('isNameNodeStarted')).to.be.eql(test.e.isNameNodeStarted);
-        expect(this.controller.get('isNextEnabled')).to.be.eql(test.e.isNextEnabled);
-        expect(this.controller.pullCheckPointStatus.called).to.be.eql(test.e.isPollingCalled);
+      describe(test.m, function() {
+
+        beforeEach(function () {
+          this.controller.set('isNameNodeStarted', !test.e.isNameNodeStarted);
+          this.controller.checkNnCheckPointStatus(test.responseData);
+          this.clock.tick(this.controller.get('POLL_INTERVAL'));
+        });
+        it('isNameNodeStarted is ' + test.e.isNameNodeStarted, function () {
+          expect(this.controller.get('isNameNodeStarted')).to.be.equal(test.e.isNameNodeStarted);
+        });
+        it('isNextEnabled is ' + test.e.isNextEnabled, function () {
+          expect(this.controller.get('isNextEnabled')).to.be.equal(test.e.isNextEnabled);
+        });
+        it('pullCheckPointStatus is ' + (test.e.isPollingCalled ? '' : 'not') + ' called', function () {
+          expect(this.controller.pullCheckPointStatus.called).to.be.equal(test.e.isPollingCalled);
+        });
       });
     });
   });

+ 35 - 29
ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js

@@ -2088,20 +2088,12 @@ describe('App.MainAdminStackAndUpgradeController', function() {
       focus: function () {}
     };
 
-    before(function(){
+    beforeEach(function(){
       sinon.stub(window, 'open', function () {
         return mock;
       });
       sinon.spy(mock.document, 'write');
       sinon.spy(mock, 'focus');
-    });
-
-    after(function(){
-      window.open.restore();
-    });
-
-    it("should open window and write table to it", function () {
-
       controller.openConfigsInNewWindow({
         context: [
           {
@@ -2120,29 +2112,43 @@ describe('App.MainAdminStackAndUpgradeController', function() {
           }
         ]
       });
+    });
+
+    afterEach(function(){
+      window.open.restore();
+      mock.document.write.restore();
+      mock.focus.restore();
+    });
 
+    it('new window is open', function () {
       expect(window.open.calledOnce).to.be.true;
+    });
+
+    it('new window content is valid', function () {
       expect(mock.document.write.calledWith('<table style="text-align: left;"><thead><tr>' +
-          '<th>' + Em.I18n.t('popup.clusterCheck.Upgrade.configsMerge.configType') + '</th>' +
-          '<th>' + Em.I18n.t('popup.clusterCheck.Upgrade.configsMerge.propertyName') + '</th>' +
-          '<th>' + Em.I18n.t('popup.clusterCheck.Upgrade.configsMerge.currentValue') + '</th>' +
-          '<th>' + Em.I18n.t('popup.clusterCheck.Upgrade.configsMerge.recommendedValue') + '</th>' +
-          '<th>' + Em.I18n.t('popup.clusterCheck.Upgrade.configsMerge.resultingValue') + '</th>' +
-          '</tr></thead><tbody>' +
-          '<tr>' +
-          '<td>' + 'type1' + '</td>' +
-          '<td>' + 'name1' + '</td>' +
-          '<td>' + 'currentValue1' + '</td>' +
-          '<td>' + 'recommendedValue1' + '</td>' +
-          '<td>' + 'resultingValue1' + '</td>' +
-          '</tr>' +
-          '<tr>' +
-          '<td>' + 'type2' + '</td>' +
-          '<td>' + 'name2' + '</td>' +
-          '<td>' + 'currentValue2' + '</td>' +
-          '<td>' + 'recommendedValue2' + '</td>' +
-          '<td>' + 'resultingValue2' + '</td>' +
-          '</tr></tbody></table>')).to.be.true;
+        '<th>' + Em.I18n.t('popup.clusterCheck.Upgrade.configsMerge.configType') + '</th>' +
+        '<th>' + Em.I18n.t('popup.clusterCheck.Upgrade.configsMerge.propertyName') + '</th>' +
+        '<th>' + Em.I18n.t('popup.clusterCheck.Upgrade.configsMerge.currentValue') + '</th>' +
+        '<th>' + Em.I18n.t('popup.clusterCheck.Upgrade.configsMerge.recommendedValue') + '</th>' +
+        '<th>' + Em.I18n.t('popup.clusterCheck.Upgrade.configsMerge.resultingValue') + '</th>' +
+        '</tr></thead><tbody>' +
+        '<tr>' +
+        '<td>' + 'type1' + '</td>' +
+        '<td>' + 'name1' + '</td>' +
+        '<td>' + 'currentValue1' + '</td>' +
+        '<td>' + 'recommendedValue1' + '</td>' +
+        '<td>' + 'resultingValue1' + '</td>' +
+        '</tr>' +
+        '<tr>' +
+        '<td>' + 'type2' + '</td>' +
+        '<td>' + 'name2' + '</td>' +
+        '<td>' + 'currentValue2' + '</td>' +
+        '<td>' + 'recommendedValue2' + '</td>' +
+        '<td>' + 'resultingValue2' + '</td>' +
+        '</tr></tbody></table>')).to.be.true;
+    });
+
+    it('document.focus is called once', function () {
       expect(mock.focus.calledOnce).to.be.true;
     });
   });

+ 48 - 38
ambari-web/test/controllers/main/alerts/definitions_configs_controller_test.js

@@ -93,8 +93,7 @@ describe('App.MainAlertDefinitionConfigsController', function () {
 
   describe('#renderPortConfigs()', function () {
 
-    it('should render array of configs with correct values', function () {
-
+    beforeEach(function () {
       controller.set('content', Em.Object.create({
         name: 'alertDefinitionName',
         service: {displayName: 'alertDefinitionService'},
@@ -119,15 +118,17 @@ describe('App.MainAlertDefinitionConfigsController', function () {
         uri: 'alertDefinitionUri',
         defaultPort: '777'
       }));
+    });
 
+    it('isWizard = true', function () {
       controller.set('isWizard', true);
       var result = controller.renderPortConfigs();
-
       expect(result.length).to.equal(11);
+    });
 
+    it('isWizard = false', function () {
       controller.set('isWizard', false);
-      result = controller.renderPortConfigs();
-
+      var result = controller.renderPortConfigs();
       expect(result.length).to.equal(5);
     });
 
@@ -135,8 +136,7 @@ describe('App.MainAlertDefinitionConfigsController', function () {
 
   describe('#renderMetricConfigs()', function () {
 
-    it('should render array of configs with correct values', function () {
-
+    beforeEach(function () {
       controller.set('content', Em.Object.create({
         name: 'alertDefinitionName',
         service: {displayName: 'alertDefinitionService'},
@@ -174,15 +174,17 @@ describe('App.MainAlertDefinitionConfigsController', function () {
           value: null
         }
       }));
+    });
 
+    it('isWizard = true', function () {
       controller.set('isWizard', true);
       var result = controller.renderMetricConfigs();
-
       expect(result.length).to.equal(11);
+    });
 
+    it('isWizard = false', function () {
       controller.set('isWizard', false);
-      result = controller.renderMetricConfigs();
-
+      var result = controller.renderMetricConfigs();
       expect(result.length).to.equal(5);
     });
 
@@ -190,8 +192,7 @@ describe('App.MainAlertDefinitionConfigsController', function () {
 
   describe('#renderWebConfigs()', function () {
 
-    it('should render array of configs with correct values', function () {
-
+    beforeEach(function () {
       controller.set('content', Em.Object.create({
         name: 'alertDefinitionName',
         service: {displayName: 'alertDefinitionService'},
@@ -221,15 +222,17 @@ describe('App.MainAlertDefinitionConfigsController', function () {
           "default_port": 0.0
         }
       }));
+    });
 
+    it('isWizard = true', function () {
       controller.set('isWizard', true);
       var result = controller.renderWebConfigs();
-
       expect(result.length).to.equal(11);
+    });
 
+    it('isWizard = false', function () {
       controller.set('isWizard', false);
-      result = controller.renderWebConfigs();
-
+      var result = controller.renderWebConfigs();
       expect(result.length).to.equal(5);
     });
 
@@ -237,8 +240,7 @@ describe('App.MainAlertDefinitionConfigsController', function () {
 
   describe('#renderScriptConfigs()', function () {
 
-    it('should render array of configs with correct values', function () {
-
+    beforeEach(function () {
       controller.set('content', Em.Object.create({
         name: 'alertDefinitionName',
         service: {displayName: 'alertDefinitionService'},
@@ -262,15 +264,17 @@ describe('App.MainAlertDefinitionConfigsController', function () {
         ],
         location: 'path to script'
       }));
+    });
 
+    it('isWizard = true', function () {
       controller.set('isWizard', true);
       var result = controller.renderScriptConfigs();
-
       expect(result.length).to.equal(8);
+    });
 
+    it('isWizard = false', function () {
       controller.set('isWizard', false);
-      result = controller.renderScriptConfigs();
-
+      var result = controller.renderScriptConfigs();
       expect(result.length).to.equal(2);
     });
 
@@ -309,20 +313,23 @@ describe('App.MainAlertDefinitionConfigsController', function () {
 
   describe('#editConfigs()', function () {
 
-    it('should set previousValue, isDisabled for each config and change canEdit flag', function () {
-
+    beforeEach(function () {
       controller.set('configs', [
         Em.Object.create({value: 'value1', previousValue: '', isDisabled: true}),
         Em.Object.create({value: 'value2', previousValue: '', isDisabled: true}),
         Em.Object.create({value: 'value3', previousValue: '', isDisabled: true})
       ]);
-
       controller.set('canEdit', false);
-
       controller.editConfigs();
+    });
 
+    it('should set previousValue', function () {
       expect(controller.get('configs').mapProperty('previousValue')).to.eql(['value1', 'value2', 'value3']);
+    });
+    it('should set isDisabled for each config', function () {
       expect(controller.get('configs').someProperty('isDisabled', true)).to.be.false;
+    });
+    it('should change canEdit flag', function () {
       expect(controller.get('canEdit')).to.be.true;
     });
 
@@ -330,20 +337,23 @@ describe('App.MainAlertDefinitionConfigsController', function () {
 
   describe('#cancelEditConfigs()', function () {
 
-    it('should set previousValue, isDisabled for each config and change canEdit flag', function () {
-
+    beforeEach(function () {
       controller.set('configs', [
         Em.Object.create({value: '', previousValue: 'value1', isDisabled: false}),
         Em.Object.create({value: '', previousValue: 'value2', isDisabled: false}),
         Em.Object.create({value: '', previousValue: 'value3', isDisabled: false})
       ]);
-
       controller.set('canEdit', true);
-
       controller.cancelEditConfigs();
+    });
 
+    it('should set previousValue', function () {
       expect(controller.get('configs').mapProperty('value')).to.eql(['value1', 'value2', 'value3']);
+    });
+    it('should set isDisabled for each config', function () {
       expect(controller.get('configs').someProperty('isDisabled', false)).to.be.false;
+    });
+    it('should change canEdit flag', function () {
       expect(controller.get('canEdit')).to.be.false;
     });
 
@@ -353,26 +363,26 @@ describe('App.MainAlertDefinitionConfigsController', function () {
 
     beforeEach(function () {
       sinon.spy(App.ajax, 'send');
-    });
-
-    afterEach(function () {
-      App.ajax.send.restore();
-    });
-
-    it('should set previousValue, isDisabled for each config and change canEdit flag', function () {
-
       controller.set('configs', [
         Em.Object.create({isDisabled: true}),
         Em.Object.create({isDisabled: true}),
         Em.Object.create({isDisabled: true})
       ]);
-
       controller.set('canEdit', true);
-
       controller.saveConfigs();
+    });
 
+    afterEach(function () {
+      App.ajax.send.restore();
+    });
+
+    it('should set isDisabled for each config', function () {
       expect(controller.get('configs').someProperty('isDisabled', false)).to.be.false;
+    });
+    it('should change canEdit flag', function () {
       expect(controller.get('canEdit')).to.be.false;
+    });
+    it('should sent 1 request', function () {
       expect(App.ajax.send.calledOnce).to.be.true;
     });
 

+ 39 - 17
ambari-web/test/controllers/main/charts/heatmap_metrics/heatmap_metric_test.js

@@ -47,32 +47,54 @@ describe('MainChartHeatmapMetric', function () {
   describe('#slotDefinitions', function () {
     beforeEach(function () {
       sinon.stub(mainChartHeatmapMetric, 'generateSlot', Em.K);
+      mainChartHeatmapMetric.set('maximumValue', 100);
+      mainChartHeatmapMetric.set('minimumValue', 0);
     });
     afterEach(function () {
       mainChartHeatmapMetric.generateSlot.restore();
     });
-    it('one slot', function () {
-      mainChartHeatmapMetric.set('numberOfSlots', 1);
-      mainChartHeatmapMetric.set('maximumValue', 100);
-      mainChartHeatmapMetric.set('minimumValue', 0);
 
-      mainChartHeatmapMetric.propertyDidChange('slotDefinitions');
+    describe('one slot', function () {
+
+      beforeEach(function () {
+        mainChartHeatmapMetric.set('numberOfSlots', 1);
+        mainChartHeatmapMetric.propertyDidChange('slotDefinitions');
+        this.slotDefinitions = mainChartHeatmapMetric.get('slotDefinitions');
+      });
+
+      it('3 slotDefinitions', function () {
+        expect(this.slotDefinitions.length).to.equal(3);
+      });
+      it('generateSlot is called 1 time', function () {
+        expect(mainChartHeatmapMetric.generateSlot.callCount).to.be.equal(1);
+      });
+      it('generateSlot is called with correct arguments', function () {
+        expect(mainChartHeatmapMetric.generateSlot.getCall(0).args).to.eql([0, 100, '', {r: 0, g: 204, b: 0}]);
+      });
 
-      expect(mainChartHeatmapMetric.get('slotDefinitions').length).to.equal(3);
-      expect(mainChartHeatmapMetric.generateSlot.getCall(0).args).to.eql([0, 100, '', {r: 0, g: 204, b: 0}]);
-      expect(mainChartHeatmapMetric.generateSlot.callCount).to.be.equal(1);
     });
-    it('two slots', function () {
-      mainChartHeatmapMetric.set('numberOfSlots', 2);
-      mainChartHeatmapMetric.set('maximumValue', 100);
-      mainChartHeatmapMetric.set('minimumValue', 0);
 
-      mainChartHeatmapMetric.propertyDidChange('slotDefinitions');
+    describe('two slots', function () {
+
+      beforeEach(function () {
+        mainChartHeatmapMetric.set('numberOfSlots', 2);
+        mainChartHeatmapMetric.propertyDidChange('slotDefinitions');
+        this.slotDefinitions = mainChartHeatmapMetric.get('slotDefinitions');
+      });
+
+      it('4 slotDefinitions', function () {
+        expect(this.slotDefinitions.length).to.equal(4);
+      });
+      it('generateSlot is called 2 times', function () {
+        expect(mainChartHeatmapMetric.generateSlot.callCount).to.be.equal(2);
+      });
+      it('generateSlot 1st call has valid arguments', function () {
+        expect(mainChartHeatmapMetric.generateSlot.getCall(0).args).to.eql([0, 50, '', {r: 0, g: 204, b: 0}]);
+      });
+      it('generateSlot 2nd call has valid arguments', function () {
+        expect(mainChartHeatmapMetric.generateSlot.getCall(1).args).to.eql([50, 100, '', {r: 159, g: 238, b: 0}]);
+      });
 
-      expect(mainChartHeatmapMetric.get('slotDefinitions').length).to.equal(4);
-      expect(mainChartHeatmapMetric.generateSlot.getCall(0).args).to.eql([0, 50, '', {r: 0, g: 204, b: 0}]);
-      expect(mainChartHeatmapMetric.generateSlot.getCall(1).args).to.eql([50, 100, '', {r: 159, g: 238, b: 0}]);
-      expect(mainChartHeatmapMetric.generateSlot.callCount).to.be.equal(2);
     });
   });
 

+ 26 - 14
ambari-web/test/controllers/main/charts/heatmap_test.js

@@ -206,20 +206,32 @@ describe('MainChartsHeatmapController', function () {
       expect(categories[0].get('heatmaps')).to.eql(allHeatmaps);
     });
 
-    it("two categories", function() {
-      var allHeatmaps = [
-        {
-          metrics: JSON.stringify([{service_name: 'S1'}])
-        },
-        {
-          metrics: JSON.stringify([{service_name: 'S1'}])
-        }
-      ];
-      var categories = controller.categorizeByServiceName(allHeatmaps);
-      expect(categories[0].get('serviceName')).to.equal('S1');
-      expect(categories[0].get('displayName')).to.equal('S1');
-      expect(categories[0].get('heatmaps')[0]).to.eql(allHeatmaps[0]);
-      expect(categories[0].get('heatmaps')[1]).to.eql(allHeatmaps[1]);
+    describe("two categories", function() {
+      var allHeatmaps;
+      beforeEach(function () {
+        allHeatmaps = [
+          {
+            metrics: JSON.stringify([{service_name: 'S1'}])
+          },
+          {
+            metrics: JSON.stringify([{service_name: 'S1'}])
+          }
+        ];
+        this.categories = controller.categorizeByServiceName(allHeatmaps);
+      });
+
+      it('serviceName is S1', function () {
+        expect(this.categories[0].get('serviceName')).to.equal('S1');
+      });
+      it('displayName is S1', function () {
+        expect(this.categories[0].get('displayName')).to.equal('S1');
+      });
+      it('heatmaps.0 is valid', function () {
+        expect(this.categories[0].get('heatmaps')[0]).to.eql(allHeatmaps[0]);
+      });
+      it('heatmaps.1 is valid', function () {
+        expect(this.categories[0].get('heatmaps')[1]).to.eql(allHeatmaps[1]);
+      });
     });
   });
 

+ 150 - 96
ambari-web/test/controllers/main/host/add_controller_test.js

@@ -418,6 +418,7 @@ describe('App.AddHostController', function () {
       stack: [],
       model: []
     };
+
     beforeEach(function () {
       sinon.stub(controller, 'getDBProperty', function () {
         return services.db;
@@ -430,111 +431,164 @@ describe('App.AddHostController', function () {
       });
       sinon.stub(controller, 'setDBProperty', Em.K);
     });
+
     afterEach(function () {
       controller.getDBProperty.restore();
       App.StackService.find.restore();
       App.Service.find.restore();
       controller.setDBProperty.restore();
     });
-    it("No services in db, no installed services", function () {
-      services.stack = [Em.Object.create({
-        serviceName: 'S1'
-      })];
-      controller.loadServices();
-      expect(controller.setDBProperty.getCall(0).args).to.eql(['services',
-        {
-          selectedServices: [],
-          installedServices: []
+
+    Em.A([
+      {
+        m: 'No services in db, no installed services',
+        service: {
+          db: null,
+          stack: [Em.Object.create({
+            serviceName: 'S1'
+          })],
+          model: []
+        },
+        e: {
+
+          db: ['services',
+            {
+              selectedServices: [],
+              installedServices: []
+            }
+          ],
+          services: [
+            Em.Object.create({
+              serviceName: 'S1',
+              isInstalled: false,
+              isSelected: false
+            })
+          ]
         }
-      ]);
-      expect(controller.get('content.services')).to.eql([
-        Em.Object.create({
-          serviceName: 'S1',
-          isInstalled: false,
-          isSelected: false
-        })
-      ])
-    });
-    it("No services in db, installed service present", function () {
-      services.stack = [
-        Em.Object.create({
-          serviceName: 'S1'
-        }),
-        Em.Object.create({
-          serviceName: 'S2'
-        })
-      ];
-      services.model = [
-        Em.Object.create({
-          serviceName: 'S1'
-        })
-      ];
-      controller.loadServices();
-      expect(controller.setDBProperty.getCall(0).args).to.eql(['services',
-        {
-          selectedServices: ['S1'],
-          installedServices: ['S1']
+      },
+      {
+        m: 'No services in db, installed service present',
+        service: {
+          db: null,
+          stack: [
+            Em.Object.create({
+              serviceName: 'S1'
+            }),
+            Em.Object.create({
+              serviceName: 'S2'
+            })
+          ],
+          model: [
+            Em.Object.create({
+              serviceName: 'S1'
+            })
+          ]
+        },
+        e: {
+          db: ['services',
+            {
+              selectedServices: ['S1'],
+              installedServices: ['S1']
+            }
+          ],
+          services: [
+            Em.Object.create({
+              serviceName: 'S1',
+              isInstalled: true,
+              isSelected: true
+            }),
+            Em.Object.create({
+              serviceName: 'S2',
+              isInstalled: false,
+              isSelected: false
+            })
+          ]
         }
-      ]);
-      expect(controller.get('content.services')).to.eql([
-        Em.Object.create({
-          serviceName: 'S1',
-          isInstalled: true,
-          isSelected: true
-        }),
-        Em.Object.create({
-          serviceName: 'S2',
-          isInstalled: false,
-          isSelected: false
-        })
-      ]);
-    });
-    it("DB is empty", function () {
-      services.stack = [Em.Object.create({
-        serviceName: 'S1'
-      })];
-      services.db = {
-        selectedServices: [],
-        installedServices: []
-      };
-      controller.loadServices();
-      expect(controller.setDBProperty.called).to.be.false;
-      expect(controller.get('content.services')).to.eql([
-        Em.Object.create({
-          serviceName: 'S1',
-          isSelected: false,
-          isInstalled: false
-        })
-      ]);
-    });
-    it("DB has selected and installed services", function () {
-      services.stack = [
-        Em.Object.create({
-          serviceName: 'S1'
-        }),
-        Em.Object.create({
-          serviceName: 'S2'
-        })
-      ];
-      services.db = {
-        selectedServices: ['S1'],
-        installedServices: ['S2']
-      };
-      controller.loadServices();
-      expect(controller.setDBProperty.called).to.be.false;
-      expect(controller.get('content.services')).to.eql([
-        Em.Object.create({
-          serviceName: 'S1',
-          isInstalled: false,
-          isSelected: true
-        }),
-        Em.Object.create({
-          serviceName: 'S2',
-          isInstalled: true,
-          isSelected: false
-        })
-      ]);
+      },
+      {
+        m: 'DB is empty',
+        service: {
+          db: {
+            selectedServices: [],
+            installedServices: []
+          },
+          stack: [Em.Object.create({
+            serviceName: 'S1'
+          })],
+          model: []
+        },
+        e: {
+          db: false,
+          services: [
+            Em.Object.create({
+              serviceName: 'S1',
+              isSelected: false,
+              isInstalled: false
+            })
+          ]
+        }
+      },
+      {
+        m: 'DB has selected and installed services',
+        service: {
+          db: {
+            selectedServices: ['S1'],
+            installedServices: ['S2']
+          },
+          stack: [
+            Em.Object.create({
+              serviceName: 'S1'
+            }),
+            Em.Object.create({
+              serviceName: 'S2'
+            })
+          ],
+          model: []
+        },
+        e: {
+          db: false,
+          services: [
+            Em.Object.create({
+              serviceName: 'S1',
+              isInstalled: false,
+              isSelected: true
+            }),
+            Em.Object.create({
+              serviceName: 'S2',
+              isInstalled: true,
+              isSelected: false
+            })
+          ]
+        }
+      }
+    ]).forEach(function (test) {
+
+      describe(test.m, function () {
+
+        beforeEach(function () {
+          services = test.service;
+          controller.loadServices();
+        });
+
+        it('services are valid', function () {
+          expect(controller.get('content.services')).to.be.eql(test.e.services);
+        });
+
+        if (test.e.db) {
+          it('setDBProperty is called with valid arguments', function () {
+            expect(controller.setDBProperty.getCall(0).args).to.eql(test.e.db);
+          });
+        }
+        else {
+          it('setDBProperty is not called', function () {
+            expect(controller.setDBProperty.called).to.be.false;
+          });
+        }
+
+      });
+
     });
+
   });
 
   describe("#loadSlaveComponentHosts()", function () {

+ 100 - 55
ambari-web/test/controllers/main/host/details_test.js

@@ -152,51 +152,71 @@ describe('App.MainHostDetailsController', function () {
   });
 
   describe('#sendComponentCommand()', function () {
-    it('single component', function () {
-      controller.set('content.hostName', 'host1');
-      var component = Em.Object.create({
-        service: {serviceName: 'S1'},
-        componentName: 'COMP1'
+
+    describe('single component', function () {
+      var component;
+      beforeEach(function () {
+        controller.set('content.hostName', 'host1');
+        component = Em.Object.create({
+          service: {serviceName: 'S1'},
+          componentName: 'COMP1'
+        });
+
+        controller.sendComponentCommand(component, {}, 'state');
       });
 
-      controller.sendComponentCommand(component, {}, 'state');
-      expect(App.ajax.send.getCall(0).args[0].name).to.be.equal('common.host.host_component.update');
-      expect(App.ajax.send.getCall(0).args[0].data).to.be.eql({
-        "hostName": "host1",
-        "context": {},
-        "component": component,
-        "HostRoles": {
-          "state": "state"
-        },
-        "componentName": "COMP1",
-        "serviceName": "S1"
+      it('1st call endpoint is valid', function () {
+        expect(App.ajax.send.getCall(0).args[0].name).to.be.equal('common.host.host_component.update');
+      });
+
+      it('1st call data is valid', function () {
+        expect(App.ajax.send.getCall(0).args[0].data).to.be.eql({
+          "hostName": "host1",
+          "context": {},
+          "component": component,
+          "HostRoles": {
+            "state": "state"
+          },
+          "componentName": "COMP1",
+          "serviceName": "S1"
+        });
       });
     });
-    it('multiple component', function () {
-      controller.set('content.hostName', 'host1');
-      var component = [
-        Em.Object.create({
-          service: {serviceName: 'S1'},
-          componentName: 'COMP1'
-        }),
-        Em.Object.create({
-          service: {serviceName: 'S1'},
-          componentName: 'COMP2'
-        })
-      ];
 
-      controller.sendComponentCommand(component, {}, 'state');
-      expect(App.ajax.send.getCall(0).args[0].name).to.be.equal('common.host.host_components.update');
-      expect(App.ajax.send.getCall(0).args[0].data).to.be.eql({
-        "hostName": "host1",
-        "context": {},
-        "component": component,
-        "HostRoles": {
-          "state": "state"
-        },
-        "query": "HostRoles/component_name.in(COMP1,COMP2)"
+    describe('multiple component', function () {
+      var component;
+      beforeEach(function () {
+        controller.set('content.hostName', 'host1');
+        component = [
+          Em.Object.create({
+            service: {serviceName: 'S1'},
+            componentName: 'COMP1'
+          }),
+          Em.Object.create({
+            service: {serviceName: 'S1'},
+            componentName: 'COMP2'
+          })
+        ];
+        controller.sendComponentCommand(component, {}, 'state');
+      });
+
+      it('1st call endpoint is valid', function () {
+        expect(App.ajax.send.getCall(0).args[0].name).to.be.equal('common.host.host_components.update');
+      });
+
+      it('1st call data is valid', function () {
+        expect(App.ajax.send.getCall(0).args[0].data).to.be.eql({
+          "hostName": "host1",
+          "context": {},
+          "component": component,
+          "HostRoles": {
+            "state": "state"
+          },
+          "query": "HostRoles/component_name.in(COMP1,COMP2)"
+        });
       });
     });
+
   });
 
   describe('#sendComponentCommandSuccessCallback()', function () {
@@ -3013,24 +3033,49 @@ describe('App.MainHostDetailsController', function () {
     afterEach(function () {
       controller._doDeleteHostComponent.restore();
     });
-    it("Host has no components", function () {
-      controller.set('content.hostComponents', Em.A([]));
-      controller.doDeleteHost(Em.K);
-      expect(controller.get('fromDeleteHost')).to.be.true;
-      expect(App.ajax.send.getCall(0).args[0].data.hostName).to.be.equal('host1');
-      expect(App.ajax.send.getCall(0).args[0].name).to.be.equal('common.delete.host');
+
+    describe("Host has no components", function () {
+
+      beforeEach(function () {
+        controller.set('content.hostComponents', Em.A([]));
+        controller.doDeleteHost(Em.K);
+      });
+
+      it('fromDeleteHost is true', function () {
+        expect(controller.get('fromDeleteHost')).to.be.true;
+      });
+      it('1st request is to delete host', function () {
+        expect(App.ajax.send.getCall(0).args[0].name).to.be.equal('common.delete.host');
+      });
+      it('1st request is done with valid hostName', function () {
+        expect(App.ajax.send.getCall(0).args[0].data.hostName).to.be.equal('host1');
+      });
     });
-    it("Host has components", function () {
-      controller.set('content.hostComponents', Em.A([Em.Object.create({
-        componentName: 'COMP1'
-      })]));
-      controller.doDeleteHost(Em.K);
-      expect(controller._doDeleteHostComponent.calledWith(Em.Object.create({
-        componentName: 'COMP1'
-      }))).to.be.true;
-      expect(controller.get('fromDeleteHost')).to.be.true;
-      expect(App.ajax.send.getCall(0).args[0].data.hostName).to.be.equal('host1');
-      expect(App.ajax.send.getCall(0).args[0].name).to.be.equal('common.delete.host');
+
+    describe("Host has components", function () {
+
+      beforeEach(function () {
+        controller.set('content.hostComponents', Em.A([Em.Object.create({
+          componentName: 'COMP1'
+        })]));
+        controller.doDeleteHost(Em.K);
+      });
+
+      it('_doDeleteHostComponent is called with correct arguments', function () {
+        expect(controller._doDeleteHostComponent.calledWith(Em.Object.create({
+          componentName: 'COMP1'
+        }))).to.be.true;
+      });
+      it('fromDeleteHost is true', function () {
+        expect(controller.get('fromDeleteHost')).to.be.true;
+      });
+      it('1st request is to delete host', function () {
+        expect(App.ajax.send.getCall(0).args[0].name).to.be.equal('common.delete.host');
+      });
+      it('1st request is done with valid hostName', function () {
+        expect(App.ajax.send.getCall(0).args[0].data.hostName).to.be.equal('host1');
+      });
+
     });
   });
 

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

@@ -63,13 +63,23 @@ describe('App.AddServiceController', function() {
       App.get.restore();
     });
 
-    it('send request to install client', function () {
-      addServiceController.set("content.additionalClients", [t.additionalClients]);
-      addServiceController.installAdditionalClients();
-      expect($.ajax.calledOnce).to.equal(true);
+    describe('send request to install client', function () {
+
+      beforeEach(function () {
+        addServiceController.set("content.additionalClients", [t.additionalClients]);
+        addServiceController.installAdditionalClients();
+      });
+
+      it('1 request is sent', function () {
+        expect($.ajax.calledOnce).to.equal(true);
+      });
+      it('data.Body is valid', function () {
+        expect(JSON.parse($.ajax.args[0][0].data).Body).to.deep.eql(t.Body);
+      });
+      it('data.RequestInfo is valid', function () {
+        expect(JSON.parse($.ajax.args[0][0].data).RequestInfo).to.eql(t.RequestInfo);
+      });
 
-      expect(JSON.parse($.ajax.args[0][0].data).Body).to.deep.eql(t.Body);
-      expect(JSON.parse($.ajax.args[0][0].data).RequestInfo).to.eql(t.RequestInfo);
     });
 
     it('should not send request to install client', function () {

+ 27 - 8
ambari-web/test/controllers/main/service/info/summary_test.js

@@ -207,14 +207,23 @@ App.TestAliases.testAsComputedOr(getController(), 'showTimeRangeControl', ['!isS
     });
 
     cases.forEach(function (item) {
-      it(item.title, function () {
-        controller.set('isPreviousRangerConfigsCallFailed', item.isPreviousRangerConfigsCallFailed);
-        controller.get('rangerPlugins').findProperty('serviceName', 'HDFS').tag = item.hdfsTag;
-        controller.get('rangerPlugins').findProperty('serviceName', 'HBASE').tag = item.hbaseTag;
-        controller.getRangerPluginsStatus(data);
-        expect(App.ajax.send.calledOnce).to.equal(item.ajaxRequestSent);
+      describe(item.title, function () {
+
+        beforeEach(function () {
+          controller.set('isPreviousRangerConfigsCallFailed', item.isPreviousRangerConfigsCallFailed);
+          controller.get('rangerPlugins').findProperty('serviceName', 'HDFS').tag = item.hdfsTag;
+          controller.get('rangerPlugins').findProperty('serviceName', 'HBASE').tag = item.hbaseTag;
+          controller.getRangerPluginsStatus(data);
+        });
+
+        it('1 request is ' + item.ajaxRequestSent + ' sent', function () {
+          expect(App.ajax.send.calledOnce).to.equal(item.ajaxRequestSent);
+        });
+
         if (item.ajaxRequestSent) {
-          expect(App.ajax.send.getCall(0).args[0].data.urlParams.contains('ranger-yarn-plugin-properties')).to.be.false;
+          it('request does not contains `ranger-yarn-plugin-properties`', function () {
+            expect(App.ajax.send.getCall(0).args[0].data.urlParams.contains('ranger-yarn-plugin-properties')).to.be.false;
+          });
         }
       });
     });
@@ -222,7 +231,8 @@ App.TestAliases.testAsComputedOr(getController(), 'showTimeRangeControl', ['!isS
   });
 
   describe('#getRangerPluginsStatusSuccess', function () {
-    it('relevant plugin statuses are set', function () {
+
+    beforeEach(function () {
       controller.getRangerPluginsStatusSuccess({
         'items': [
           {
@@ -245,9 +255,18 @@ App.TestAliases.testAsComputedOr(getController(), 'showTimeRangeControl', ['!isS
           }
         ]
       });
+    });
+
+    it('isPreviousRangerConfigsCallFailed is false', function () {
       expect(controller.get('isPreviousRangerConfigsCallFailed')).to.be.false;
+    });
+    it('rangerPlugins.HDFS status is valid', function () {
       expect(controller.get('rangerPlugins').findProperty('serviceName', 'HDFS').status).to.equal(Em.I18n.t('alerts.table.state.enabled'));
+    });
+    it('rangerPlugins.HIVE status is valid', function () {
       expect(controller.get('rangerPlugins').findProperty('serviceName', 'HIVE').status).to.equal(Em.I18n.t('alerts.table.state.enabled'));
+    });
+    it('rangerPlugins.HBASE status is valid', function () {
       expect(controller.get('rangerPlugins').findProperty('serviceName', 'HBASE').status).to.equal(Em.I18n.t('common.unknown'));
     });
   });

+ 66 - 45
ambari-web/test/controllers/main/service/item_test.js

@@ -304,25 +304,30 @@ describe('App.MainServiceItemController', function () {
 
     tests.forEach(function (test, index) {
 
-      function setupWithTestData() {
-        mainServiceItemController = App.MainServiceItemController.create({content: {serviceName: test.data.serviceName}});
-        mainServiceItemController.startStopPopupPrimary(test.data.state, test.data.query);
-      }
+      describe('case #' + (index + 1), function () {
+
+        beforeEach(function () {
+          mainServiceItemController = App.MainServiceItemController.create({content: {serviceName: test.data.serviceName}});
+          mainServiceItemController.startStopPopupPrimary(test.data.state, test.data.query);
+          this.data = JSON.parse($.ajax.args[0][0].data);
+        });
+
+        it('request is sent with valid data ' + (index + 1), function () {
+          expect($.ajax.calledOnce).to.equal(true);
+          expect(this.data.Body.ServiceInfo.state).to.equal(test.request.Body.ServiceInfo.state);
+          expect(this.data.RequestInfo.context).to.equal(test.request.RequestInfo.context);
+        });
+
+        it('isStopDisabled is true ' + (index + 1), function () {
+          expect(mainServiceItemController.get('isStopDisabled')).to.equal(true);
+        });
+
+        it('isStartDisabled is true ' + (index + 1), function () {
+          expect(mainServiceItemController.get('isStartDisabled')).to.equal(true);
+        });
 
-      it('request is sent with valid data ' + (index + 1), function () {
-        setupWithTestData();
-        expect($.ajax.calledOnce).to.equal(true);
-        expect(JSON.parse($.ajax.args[0][0].data).Body.ServiceInfo.state).to.equal(test.request.Body.ServiceInfo.state);
-        expect(JSON.parse($.ajax.args[0][0].data).RequestInfo.context).to.equal(test.request.RequestInfo.context);
-      });
-      it('isStopDisabled is true ' + (index + 1), function () {
-        setupWithTestData();
-        expect(mainServiceItemController.get('isStopDisabled')).to.equal(true);
-      });
-      it('isStartDisabled is true ' + (index + 1), function () {
-        setupWithTestData();
-        expect(mainServiceItemController.get('isStartDisabled')).to.equal(true);
       });
+
     });
 
 
@@ -517,37 +522,53 @@ describe('App.MainServiceItemController', function () {
         expect(Em.I18n.t.calledWith('services.service.stop.warningMsg.dependent.services')).to.not.be.ok;
       });
       
-      it ("should display dependent list if other services depend on the one to be stopped", function() {
-        var mainServiceItemController = App.MainServiceItemController.create(
-          {content: {
-            serviceName: "HDFS",
-            passiveState:'OFF',
-            hostComponents: [{
-              componentName: 'NAMENODE',
-              workStatus: 'INSTALLED'
-            }]
-          }}
-        );
-        mainServiceItemController.startStopPopup(event, "INSTALLED");
-        expect(Em.I18n.t.calledWith('services.service.stop.warningMsg.turnOnMM')).to.be.ok;
-        expect(Em.I18n.t.calledWith('services.service.stop.warningMsg.dependent.services')).to.be.ok;
-        
-        var dependencies = Em.I18n.t('services.service.stop.warningMsg.dependent.services').format("HDFS", "HBase,YARN")
-        var msg = Em.I18n.t('services.service.stop.warningMsg.turnOnMM').format("HDFS");
-        var fullMsg = mainServiceItemController.addAdditionalWarningMessage("INSTALLED", msg, "HDFS");
-        expect(fullMsg).to.be.equal(msg + " " + dependencies);
+      describe ("should display dependent list if other services depend on the one to be stopped", function() {
+        var mainServiceItemController;
+        beforeEach(function () {
+          mainServiceItemController = App.MainServiceItemController.create(
+            {content: {
+              serviceName: "HDFS",
+              passiveState:'OFF',
+              hostComponents: [{
+                componentName: 'NAMENODE',
+                workStatus: 'INSTALLED'
+              }]
+            }}
+          );
+          mainServiceItemController.startStopPopup(event, "INSTALLED");
+          this.dependencies = Em.I18n.t('services.service.stop.warningMsg.dependent.services').format("HDFS", "HBase,YARN");
+          this.msg = Em.I18n.t('services.service.stop.warningMsg.turnOnMM').format("HDFS");
+          this.fullMsg = mainServiceItemController.addAdditionalWarningMessage("INSTALLED", this.msg, "HDFS");
+        });
+
+        it('turnOnMM message is shown', function () {
+          expect(Em.I18n.t.calledWith('services.service.stop.warningMsg.turnOnMM')).to.be.ok;
+        });
+        it('message about dependent services is shown', function () {
+          expect(Em.I18n.t.calledWith('services.service.stop.warningMsg.dependent.services')).to.be.ok;
+        });
+        it('full message is valid', function () {
+          expect(this.fullMsg).to.be.equal(this.msg + " " + this.dependencies);
+        });
       });
 
-      it ("should display the dependent service if another service depends on the one to be stopped", function() {
-        var mainServiceItemController = App.MainServiceItemController.create(
+      describe("should display the dependent service if another service depends on the one to be stopped", function() {
+
+        beforeEach(function () {
+          var mainServiceItemController = App.MainServiceItemController.create(
             {content: {serviceName: "HIVE", passiveState:'OFF'}});
-        mainServiceItemController.startStopPopup(event, "INSTALLED");
-        expect(Em.I18n.t.calledWith('services.service.stop.warningMsg.dependent.services')).to.be.ok;
-        
-        var dependencies = Em.I18n.t('services.service.stop.warningMsg.dependent.services').format("HIVE", "Spark")
-        var msg = Em.I18n.t('services.service.stop.warningMsg.turnOnMM').format("HIVE");
-        var fullMsg = mainServiceItemController.addAdditionalWarningMessage("INSTALLED", msg, "HIVE");
-        expect(fullMsg).to.be.equal(msg + " " + dependencies);
+          mainServiceItemController.startStopPopup(event, "INSTALLED");
+          this.dependencies = Em.I18n.t('services.service.stop.warningMsg.dependent.services').format("HIVE", "Spark");
+          this.msg = Em.I18n.t('services.service.stop.warningMsg.turnOnMM').format("HIVE");
+          this.fullMsg = mainServiceItemController.addAdditionalWarningMessage("INSTALLED", this.msg, "HIVE");
+        });
+
+        it('message about dependent services is shown', function () {
+          expect(Em.I18n.t.calledWith('services.service.stop.warningMsg.dependent.services')).to.be.ok;
+        });
+        it('full message is valid', function () {
+          expect(this.fullMsg).to.be.equal(this.msg + " " + this.dependencies);
+        });
       });
       
       afterEach(function () {

+ 53 - 56
ambari-web/test/controllers/main/service/manage_config_groups_controller_test.js

@@ -442,6 +442,58 @@ describe('App.ManageConfigGroupsController', function() {
 
   describe('#_onLoadPropertiesSuccess', function () {
 
+    var data = {
+      items: [
+        {
+          type: 'type1',
+          tag: 'tag1',
+          properties: {
+            prop1: 'val1',
+            prop2: 'val2'
+          }
+        },
+        {
+          type: 'type1',
+          tag: 'tag2',
+          properties: {
+            prop3: 'val3'
+          }
+        },
+        {
+          type: 'type2',
+          tag: 'tag1',
+          properties: {
+            prop4: 'val4'
+          }
+        }
+      ]
+    };
+    var params = {
+      typeTagToGroupMap: {
+        'type1///tag1': 'group1',
+        'type1///tag2': 'group2',
+        'type2///tag1': 'group3'
+      }
+    };
+    var configGroups = [
+      Em.Object.create({
+        name: 'group1',
+        properties: []
+      }),
+      Em.Object.create({
+        name: 'group2',
+        properties: []
+      }),
+      Em.Object.create({
+        name: 'group3',
+        properties: []
+      }),
+      Em.Object.create({
+        name: 'group4',
+        properties: []
+      })
+    ];
+
     beforeEach(function () {
       sinon.stub(c, 'resortConfigGroup', Em.K);
     });
@@ -451,63 +503,8 @@ describe('App.ManageConfigGroupsController', function() {
     });
 
     it('should set properties to config groups', function () {
-
-      c.set('configGroups', [
-        Em.Object.create({
-          name: 'group1',
-          properties: []
-        }),
-        Em.Object.create({
-          name: 'group2',
-          properties: []
-        }),
-        Em.Object.create({
-          name: 'group3',
-          properties: []
-        }),
-        Em.Object.create({
-          name: 'group4',
-          properties: []
-        })
-      ]);
-
-      var data = {
-        items: [
-          {
-            type: 'type1',
-            tag: 'tag1',
-            properties: {
-              prop1: 'val1',
-              prop2: 'val2'
-            }
-          },
-          {
-            type: 'type1',
-            tag: 'tag2',
-            properties: {
-              prop3: 'val3'
-            }
-          },
-          {
-            type: 'type2',
-            tag: 'tag1',
-            properties: {
-              prop4: 'val4'
-            }
-          }
-        ]
-      };
-
-      var params = {
-        typeTagToGroupMap: {
-          'type1///tag1': 'group1',
-          'type1///tag2': 'group2',
-          'type2///tag1': 'group3'
-        }
-      };
-
+      c.set('configGroups', configGroups);
       c._onLoadPropertiesSuccess(data, null, params);
-
       expect(JSON.stringify(c.get('configGroups'))).to.equal(JSON.stringify([
         Em.Object.create({
           properties: [

+ 6 - 12
ambari-web/test/controllers/main/service/reassign/step4_controller_test.js

@@ -934,28 +934,22 @@ describe('App.ReassignMasterWizardStep4Controller', function () {
   describe('#startNameNode()', function () {
     beforeEach(function () {
       sinon.stub(controller, 'updateComponent', Em.K);
+      controller.set('content.masterComponentHosts', [{
+        component: 'NAMENODE',
+        hostName: 'host1'
+      }]);
     });
     afterEach(function () {
       controller.updateComponent.restore();
     });
 
     it('reassign host does not match current', function () {
-      controller.set('content.masterComponentHosts', [{
-        component: 'NAMENODE',
-        hostName: 'host1'
-      }]);
       controller.set('content.reassignHosts.source', 'host2');
       controller.startNameNode();
-      expect(controller.updateComponent.getCall(0).args[1][0]).to.equal('host1');
-      expect(controller.updateComponent.getCall(0).args[0]).to.equal('NAMENODE');
-      expect(controller.updateComponent.getCall(0).args[2]).to.equal('HDFS');
-      expect(controller.updateComponent.getCall(0).args[3]).to.equal('Start');
+      expect(controller.updateComponent.calledWith('NAMENODE', ['host1'], 'HDFS', 'Start')).to.be.true;
     });
+
     it('reassign host matches current', function () {
-      controller.set('content.masterComponentHosts', [{
-        component: 'NAMENODE',
-        hostName: 'host1'
-      }]);
       controller.set('content.reassignHosts.source', 'host1');
       controller.startNameNode();
       expect(controller.updateComponent.calledWith('NAMENODE', [], 'HDFS', 'Start')).to.be.true;

+ 17 - 10
ambari-web/test/controllers/main/service_test.js

@@ -273,6 +273,9 @@ describe('App.MainServiceController', function () {
 
   describe('#allServicesCall', function() {
 
+    var state = 'STARTED',
+      query = 'some query';
+
     beforeEach(function() {
       sinon.stub($, 'ajax', Em.K);
       sinon.stub(App, 'get', function(k) {
@@ -280,6 +283,9 @@ describe('App.MainServiceController', function () {
         if ('clusterName' === k) return 'tdk';
         return Em.get(App, k);
       });
+      mainServiceController.allServicesCall(state, query);
+      this.params = $.ajax.args[0][0];
+      this.data = JSON.parse(this.params.data);
     });
 
     afterEach(function() {
@@ -287,16 +293,17 @@ describe('App.MainServiceController', function () {
       App.get.restore();
     });
 
-    it('should do ajax-request', function() {
-      var state = 'STARTED',
-        query = 'some query';
-      mainServiceController.allServicesCall(state, query);
-      var params = $.ajax.args[0][0];
-      expect(params.type).to.equal('PUT');
-      expect(params.url.contains('/clusters/tdk/services?')).to.be.true;
-      var data = JSON.parse(params.data);
-      expect(data.Body.ServiceInfo.state).to.equal(state);
-      expect(data.RequestInfo.context).to.equal(App.BackgroundOperationsController.CommandContexts.START_ALL_SERVICES);
+    it('PUT request is sent', function() {
+      expect(this.params.type).to.equal('PUT');
+    });
+    it('request is sent to `/services`', function() {
+      expect(this.params.url.contains('/clusters/tdk/services?')).to.be.true;
+    });
+    it('Body.ServiceInfo.state is ' + state, function() {
+      expect(this.data.Body.ServiceInfo.state).to.equal(state);
+    });
+    it('RequestInfo.context is ' + query, function() {
+      expect(this.data.RequestInfo.context).to.equal(App.BackgroundOperationsController.CommandContexts.START_ALL_SERVICES);
     });
 
   });

+ 24 - 10
ambari-web/test/controllers/wizard/step10_test.js

@@ -158,12 +158,19 @@ describe('App.WizardStep10Controller', function () {
       }
     ]);
     tests.forEach(function(test) {
-      it(test.m, function() {
-        controller.set('content.hosts', test.hosts);
-        controller.set('clusterInfo', Em.A([Em.Object.create({id: 1, status: []})]));
-        controller.loadInstalledHosts();
+      describe(test.m, function() {
+
+        beforeEach(function () {
+          controller.set('content.hosts', test.hosts);
+          controller.set('clusterInfo', Em.A([Em.Object.create({id: 1, status: []})]));
+          controller.loadInstalledHosts();
+        });
+
         test.e.forEach(function(ex) {
-          expect(controller.get('clusterInfo').findProperty('id', 1).get('status').findProperty('id', ex.id).get('displayStatement').contains(ex.l)).to.equal(true);
+          it(JSON.stringify(test.e), function () {
+            var displayStatement = controller.get('clusterInfo').findProperty('id', 1).get('status').findProperty('id', ex.id).get('displayStatement');
+            expect(displayStatement.contains(ex.l)).to.equal(true);
+          });
         });
       })
     });
@@ -314,12 +321,19 @@ describe('App.WizardStep10Controller', function () {
       }
     ]);
     testsForFailedTasks.forEach(function(test) {
-      it(test.m, function() {
-        controller.set('content.hosts', test.hosts);
-        controller.set('clusterInfo', Em.A([Em.Object.create({id: 1, status: []})]));
-        controller.loadInstalledHosts();
+      describe(test.m, function() {
+
+        beforeEach(function () {
+          controller.set('content.hosts', test.hosts);
+          controller.set('clusterInfo', Em.A([Em.Object.create({id: 1, status: []})]));
+          controller.loadInstalledHosts();
+        });
+
         test.e.forEach(function(ex) {
-          expect(controller.get('clusterInfo').findProperty('id', 1).get('status').findProperty('id', 2).get('statements').mapProperty('status', ex.st).length).to.equal(ex.l);
+          it(JSON.stringify(test.e), function () {
+            var tasksWithNeededStatements = controller.get('clusterInfo').findProperty('id', 1).get('status').findProperty('id', 2).get('statements').filterProperty('status', ex.st);
+            expect(tasksWithNeededStatements.length).to.equal(ex.l);
+          });
         });
       })
     });

+ 50 - 21
ambari-web/test/controllers/wizard/step3_test.js

@@ -355,17 +355,28 @@ describe('App.WizardStep3Controller', function () {
     ]);
 
     tests.forEach(function (test) {
-      it(test.m, function () {
-        c.set('bootHosts', test.bootHosts);
-        var r = c.parseHostInfo(test.hostsStatusFromServer);
-        expect(r).to.equal(test.e.r);
+      describe(test.m, function () {
+        var r;
+        beforeEach(function () {
+          c.set('bootHosts', test.bootHosts);
+          r = c.parseHostInfo(test.hostsStatusFromServer);
+        });
+
+        it('parsed hosts info is valid', function () {
+          expect(r).to.equal(test.e.r);
+        });
+
         if (test.e.c) {
           test.hostsStatusFromServer.forEach(function (h) {
-            var r = c.get('bootHosts').findProperty('name', h.hostName);
-            if (!['REGISTERED', 'REGISTERING'].contains(r.get('bootStatus'))) {
-              expect(r.get('bootStatus')).to.equal(h.status);
-              expect(r.get('bootLog')).to.equal(h.log);
-            }
+
+            it('bootStatus and bootLog are valid', function () {
+              var bootHosts = c.get('bootHosts').findProperty('name', h.hostName);
+              if (!['REGISTERED', 'REGISTERING'].contains(bootHosts.get('bootStatus'))) {
+                expect(bootHosts.get('bootStatus')).to.equal(h.status);
+                expect(bootHosts.get('bootLog')).to.equal(h.log);
+              }
+            });
+
           });
         }
       });
@@ -1617,15 +1628,24 @@ describe('App.WizardStep3Controller', function () {
           ])
         }
       ]).forEach(function (category) {
-        describe(category.m, function () {
-          category.tests.forEach(function (test) {
-            it(test.m, function () {
+      describe(category.m, function () {
+        category.tests.forEach(function (test) {
+
+          describe(test.m, function () {
+
+            beforeEach(function () {
               c.parseHostCheckWarnings({tasks: test.tasks});
+            });
+
+            it('warnings', function () {
               c.get('warnings').forEach(function (w, i) {
                 Em.keys(test.e.warnings[i]).forEach(function (k) {
                   expect(w[k]).to.eql(test.e.warnings[i][k]);
                 });
               });
+            });
+
+            it('warningsByHost', function () {
               for (var i in test.e.warningsByHost) {
                 if (test.e.warningsByHost.hasOwnProperty(i)) {
                   expect(c.get('warningsByHost')[i].warnings.length).to.equal(test.e.warningsByHost[i]);
@@ -1635,6 +1655,7 @@ describe('App.WizardStep3Controller', function () {
           });
         });
       });
+      });
 
     it('should parse umask warnings', function () {
 
@@ -2081,18 +2102,26 @@ describe('App.WizardStep3Controller', function () {
       ]).forEach(function (category) {
         describe(category.m, function () {
           category.tests.forEach(function (test) {
-            it(test.m, function () {
-              c.parseWarnings({items: test.items});
-              c.get('warnings').forEach(function (w, i) {
-                Em.keys(test.e.warnings[i]).forEach(function (k) {
-                  expect(w[k]).to.eql(test.e.warnings[i][k]);
+            describe(test.m, function () {
+
+              beforeEach(function () {
+                c.parseWarnings({items: test.items});
+              });
+              it('warnings', function () {
+                c.get('warnings').forEach(function (w, i) {
+                  Em.keys(test.e.warnings[i]).forEach(function (k) {
+                    expect(w[k]).to.eql(test.e.warnings[i][k]);
+                  });
                 });
               });
-              for (var i in test.e.warningsByHost) {
-                if (test.e.warningsByHost.hasOwnProperty(i)) {
-                  expect(c.get('warningsByHost')[i].warnings.length).to.equal(test.e.warningsByHost[i]);
+
+              it('warningsByHost', function () {
+                for (var i in test.e.warningsByHost) {
+                  if (test.e.warningsByHost.hasOwnProperty(i)) {
+                    expect(c.get('warningsByHost')[i].warnings.length).to.equal(test.e.warningsByHost[i]);
+                  }
                 }
-              }
+              });
             });
           });
         });

+ 61 - 45
ambari-web/test/controllers/wizard/step4_test.js

@@ -160,19 +160,25 @@ describe('App.WizardStep4Controller', function () {
     ];
 
     testCases.forEach(function(testCase){
-      it(testCase.title, function () {
-        controller.clear();
-        for(var id in testCase.condition) {
-          controller.pushObject(Ember.Object.create({
-            'serviceName':id, 'isSelected': testCase.condition[id], 'canBeSelected': true, 'isInstalled': false,
-            coSelectedServices: function() {
-              return App.StackService.coSelected[this.get('serviceName')] || [];
-            }.property('serviceName')
-          }));
-        }
-        controller.setGroupedServices();
+      describe(testCase.title, function () {
+
+        beforeEach(function () {
+          controller.clear();
+          for(var id in testCase.condition) {
+            controller.pushObject(Ember.Object.create({
+              'serviceName':id, 'isSelected': testCase.condition[id], 'canBeSelected': true, 'isInstalled': false,
+              coSelectedServices: function() {
+                return App.StackService.coSelected[this.get('serviceName')] || [];
+              }.property('serviceName')
+            }));
+          }
+          controller.setGroupedServices();
+        });
+
         for(var service in testCase.result) {
-          expect(controller.findProperty('serviceName', service).get('isSelected')).to.equal(testCase.result[service]);
+          it(service, function () {
+            expect(controller.findProperty('serviceName', service).get('isSelected')).to.equal(testCase.result[service]);
+          });
         }
       });
     }, this);
@@ -431,26 +437,31 @@ describe('App.WizardStep4Controller', function () {
         });
 
         if (test.errorsExpected) {
-          it('if errors detected than it should be shown', function () {
+          describe('if errors detected than it should be shown', function () {
+            var currentErrorObject;
+            beforeEach(function () {
+              currentErrorObject = c.get('errorStack').findProperty('isShown', false);
+            });
             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(error, function () {
+                // validate current error
+                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();
-              }
+              });
             });
           });
         }
@@ -795,21 +806,26 @@ describe('App.WizardStep4Controller', function () {
     });
 
     cases.forEach(function (item) {
-      it(item.title, function () {
-        this.stub.withArgs('currentStackName').returns(item.currentStackName).
-          withArgs('currentStackVersionNumber').returns(item.currentStackVersionNumber);
-        controller.set('content', generateSelectedServicesContent(item.services));
-        var spark = controller.findProperty('serviceName', 'SPARK');
-        if (item.services.contains('SPARK')) {
-          spark.setProperties({
-            isSelected: item.isSparkSelected,
-            isInstalled: item.isSparkInstalled
-          });
-        } else {
-          controller.removeObject(spark);
-        }
-        controller.sparkValidation();
-        expect(controller.get('errorStack').mapProperty('id').contains('sparkWarning')).to.equal(item.isSparkWarning);
+      describe(item.title, function () {
+        beforeEach(function () {
+          this.stub.withArgs('currentStackName').returns(item.currentStackName).
+            withArgs('currentStackVersionNumber').returns(item.currentStackVersionNumber);
+          controller.set('content', generateSelectedServicesContent(item.services));
+          var spark = controller.findProperty('serviceName', 'SPARK');
+          if (item.services.contains('SPARK')) {
+            spark.setProperties({
+              isSelected: item.isSparkSelected,
+              isInstalled: item.isSparkInstalled
+            });
+          } else {
+            controller.removeObject(spark);
+          }
+          controller.sparkValidation();
+        });
+
+        it('sparkWarning is ' + item.sparkWarning, function () {
+          expect(controller.get('errorStack').mapProperty('id').contains('sparkWarning')).to.equal(item.isSparkWarning);
+        });
       });
     });
 

+ 18 - 11
ambari-web/test/controllers/wizard/step5_test.js

@@ -1104,17 +1104,24 @@ describe('App.WizardStep5Controller', function () {
       expect(r.mapProperty('selectedHost')).to.eql(['h1', 'h1', 'h2', 'h2', 'h3']);
     });
 
-    it('some saved components exist', function() {
-      c.set('content.controllerName', 'addServiceController');
-      c.get('multipleComponents').push('c4');
-      c.set('content.masterComponentHosts', [
-        {hostName: 'h3', component: 'c4'}
-      ]);
-      c.get('content.recommendations.blueprint.host_groups')[2].components.push({name: 'c4'});
-      var r = c.createComponentInstallationObjects();
-      expect(r.mapProperty('component_name')).to.eql(['c1', 'c2', 'c1', 'c2', 'c1', 'c4']);
-      expect(r.mapProperty('serviceId')).to.eql(['s1', 's2', 's1', 's2', 's1', 's2']);
-      expect(r.mapProperty('selectedHost')).to.eql(['h1', 'h1', 'h2', 'h2', 'h3', 'h3']);
+    describe('some saved components exist', function() {
+
+      beforeEach(function () {
+        c.set('content.controllerName', 'addServiceController');
+        c.get('multipleComponents').push('c4');
+        c.set('content.masterComponentHosts', [
+          {hostName: 'h3', component: 'c4'}
+        ]);
+        c.get('content.recommendations.blueprint.host_groups')[2].components.push({name: 'c4'});
+      });
+
+      it('data contains save components', function () {
+        var r = c.createComponentInstallationObjects();
+        expect(r.mapProperty('component_name')).to.eql(['c1', 'c2', 'c1', 'c2', 'c1', 'c4']);
+        expect(r.mapProperty('serviceId')).to.eql(['s1', 's2', 's1', 's2', 's1', 's2']);
+        expect(r.mapProperty('selectedHost')).to.eql(['h1', 'h1', 'h2', 'h2', 'h3', 'h3']);
+      });
+
     });
 
   });

+ 111 - 83
ambari-web/test/controllers/wizard/step6_test.js

@@ -116,25 +116,27 @@ describe('App.WizardStep6Controller', function () {
   });
 
   describe('#selectAllNodes', function () {
+
+    var hostsObj = Em.A([Em.Object.create({
+      hasMaster: false,
+      isInstalled: false,
+      checkboxes: Em.A([
+        Em.Object.create({
+          title: 'l1',
+          component: 'name',
+          isInstalled: false,
+          checked: false
+        })
+      ])
+    })]);
+    var obj = Em.Object.create({
+      context: {
+        name: "name"
+      }
+    });
+    var clientComponents = Em.A([{component_name: "name1"}]);
+
     it('should make checkbox checked', function () {
-      var hostsObj = Em.A([Em.Object.create({
-        hasMaster: false,
-        isInstalled: false,
-        checkboxes: Em.A([
-          Em.Object.create({
-            title: 'l1',
-            component: 'name',
-            isInstalled: false,
-            checked: false
-          })
-        ])
-      })]);
-      var obj = Em.Object.create({
-        context: {
-          name: "name"
-        }
-      });
-      var clientComponents = Em.A([{component_name: "name1"}]);
       controller.set('hosts', hostsObj);
       controller.set('content.clients', clientComponents);
       controller.selectAllNodes(obj);
@@ -154,25 +156,27 @@ describe('App.WizardStep6Controller', function () {
   });
 
   describe('#deselectAllNodes', function () {
+
+    var hostsObj = Em.A([Em.Object.create({
+      hasMaster: false,
+      isInstalled: false,
+      checkboxes: Em.A([
+        Em.Object.create({
+          title: 'l1',
+          component: 'name',
+          isInstalled: false,
+          checked: true
+        })
+      ])
+    })]);
+    var obj = Em.Object.create({
+      context: {
+        name: "name"
+      }
+    });
+    var clientComponents = Em.A([{component_name: "name1"}]);
+
     it('should uncheck checkbox', function () {
-      var hostsObj = Em.A([Em.Object.create({
-        hasMaster: false,
-        isInstalled: false,
-        checkboxes: Em.A([
-          Em.Object.create({
-            title: 'l1',
-            component: 'name',
-            isInstalled: false,
-            checked: true
-          })
-        ])
-      })]);
-      var obj = Em.Object.create({
-        context: {
-          name: "name"
-        }
-      });
-      var clientComponents = Em.A([{component_name: "name1"}]);
       controller.set('hosts', hostsObj);
       controller.set('content.clients', clientComponents);
       controller.deselectAllNodes(obj);
@@ -558,6 +562,31 @@ describe('App.WizardStep6Controller', function () {
   });
 
   describe('#updateValidationsSuccessCallback', function () {
+
+    var hosts = Em.A([Em.Object.create({
+      warnMessages: "warn",
+      errorMessages: "error",
+      anyMessage: true,
+      checkboxes: Em.A([Em.Object.create({
+        hasWarnMessage: true,
+        hasErrorMessage: true
+      })])
+    })]);
+
+    var validationData = Em.Object.create({
+      resources: Em.A([
+        Em.Object.create({
+          items: Em.A([
+            Em.Object.create({
+              "component-name": 'HDFS_CLIENT',
+              host: "1",
+              isMaster: true
+            })
+          ])
+        })
+      ])
+    });
+
     beforeEach(function () {
       sinon.stub(validationUtils, 'filterNotInstalledComponents', function () {
         return  Em.A([Em.Object.create({
@@ -626,51 +655,49 @@ describe('App.WizardStep6Controller', function () {
             })
           ];
         });
+      controller.set('hosts', hosts);
+      controller.updateValidationsSuccessCallback(validationData);
     });
+
     afterEach(function () {
       App.StackServiceComponent.find.restore();
       validationUtils.filterNotInstalledComponents.restore();
     });
-    it('should return modified hosts', function () {
-      var hosts = Em.A([Em.Object.create({
-        warnMessages: "warn",
-        errorMessages: "error",
-        anyMessage: true,
-        checkboxes: Em.A([Em.Object.create({
-          hasWarnMessage: true,
-          hasErrorMessage: true
-        })])
-      })]);
-      controller.set('hosts', hosts);
-      var validationData = Em.Object.create({
-          resources: Em.A([
-            Em.Object.create({
-              items: Em.A([
-                Em.Object.create({
-                  "component-name": 'HDFS_CLIENT',
-                  host: "1",
-                  isMaster: true
-                })
-              ])
-            })
-          ])
-      });
-      controller.updateValidationsSuccessCallback(validationData);
+
+    it('no generalErrorMessages', function () {
       expect(controller.get('generalErrorMessages').length).to.equal(0);
+    });
+
+    it('no generalWarningMessages', function () {
       expect(controller.get('generalWarningMessages').length).to.equal(0);
-      expect(JSON.parse(JSON.stringify(controller.get('hosts')))).to.eql(JSON.parse(JSON.stringify(Em.A([Em.Object.create({
+    });
+
+    it('hosts info is valid', function () {
+      var cHosts = JSON.parse(JSON.stringify(controller.get('hosts')));
+      var expected = [{
         warnMessages: [null],
         errorMessages: [null],
         anyMessage: true,
-        checkboxes: Em.A([Em.Object.create({
+        checkboxes: [{
           hasWarnMessage: true,
           hasErrorMessage: true
-        })])
-      })]))));
+        }]
+      }];
+      expect(cHosts).to.eql(expected);
     });
   });
 
   describe('#clearError', function () {
+
+    var headers = Em.A([
+      Em.Object.create({name: "c1", label: 't1'}),
+      Em.Object.create({name: "c2", label: 't2'})]);
+
+    beforeEach(function () {
+      controller.set('errorMessage', 'error');
+      controller.set('headers', headers);
+    });
+
     it('both checkboxes are checked', function () {
       var hosts = Em.A([
         Em.Object.create({
@@ -687,12 +714,8 @@ describe('App.WizardStep6Controller', function () {
             })])
         })
       ]);
-      var headers = Em.A([
-        Em.Object.create({name: "c1"}),
-        Em.Object.create({name: "c2"})]);
-      controller.set('errorMessage', 'error');
+
       controller.set('hosts', hosts);
-      controller.set('headers', headers);
       controller.clearError();
       expect(controller.get('errorMessage')).to.equal('');
     });
@@ -715,12 +738,8 @@ describe('App.WizardStep6Controller', function () {
             })])
         })
       ]);
-      var headers = Em.A([
-        Em.Object.create({name: "c1", label: 't1'}),
-        Em.Object.create({name: "c2", label: 't2'})]);
-      controller.set('errorMessage', 'error');
+
       controller.set('hosts', hosts);
-      controller.set('headers', headers);
       controller.set('isAddHostWizard', true);
       controller.clearError();
       expect(controller.get('errorMessage')).to.equal('error');
@@ -921,14 +940,23 @@ describe('App.WizardStep6Controller', function () {
           }
         }
       ]).forEach(function (test) {
-        it(test.m, function () {
-          controller.clearStep();
-          controller.set('headers', test.headers);
-          controller.set('hosts', test.hosts);
-          controller.checkCallback(test.component);
-          var header = controller.get('headers').findProperty('name', test.component);
-          expect(header.get('allChecked')).to.equal(test.e.allChecked);
-          expect(header.get('noChecked')).to.equal(test.e.noChecked);
+        describe(test.m, function () {
+
+          beforeEach(function () {
+            controller.clearStep();
+            controller.set('headers', test.headers);
+            controller.set('hosts', test.hosts);
+            controller.checkCallback(test.component);
+            this.header = controller.get('headers').findProperty('name', test.component);
+          });
+
+          it('allChecked is ' + test.e.allChecked, function () {
+            expect(this.header.get('allChecked')).to.equal(test.e.allChecked);
+          });
+
+          it('noChecked is ' + test.e.noChecked, function () {
+            expect(this.header.get('noChecked')).to.equal(test.e.noChecked);
+          });
         });
       });
   });

+ 83 - 58
ambari-web/test/controllers/wizard/step7_test.js

@@ -287,7 +287,8 @@ describe('App.InstallerStep7Controller', function () {
   });
 
   describe('#checkDatabaseConnectionTest', function () {
-    it('should return promise in process', function () {
+
+    beforeEach(function () {
       installerStep7Controller.set('content', {
         services: Em.A([
           Em.Object.create({isSelected: true, isInstalled: false, serviceName: 'OOZIE', ignored: []}),
@@ -302,10 +303,13 @@ describe('App.InstallerStep7Controller', function () {
       });
       var obj = Em.Object.create({name:'oozie_database',value:"aa"});
       installerStep7Controller.set('stepConfigs',Em.A([Em.Object.create({serviceName: 'OOZIE', configs: Em.A([obj]) })]));
-      var deffer = installerStep7Controller.checkDatabaseConnectionTest();
-      expect(deffer.isResolved()).to.equal(false);
-      deffer.resolve(true);
-      deffer.done(function(data) {
+      this.deffer = installerStep7Controller.checkDatabaseConnectionTest();
+    });
+
+    it('should return promise in process', function () {
+      expect(this.deffer.isResolved()).to.equal(false);
+      this.deffer.resolve(true);
+      this.deffer.done(function(data) {
         expect(data).to.equal(true);
       });
     });
@@ -684,48 +688,67 @@ describe('App.InstallerStep7Controller', function () {
       expect(updatedConfig.get('overrides')).to.be.null;
     });
 
-    it('no overrideToAdd', function () {
-      var isDefault = true,
-        name = 'n1',
-        config = Em.Object.create({overrides: null, name: name, flag: 'flag'}),
-        overrides = Em.A([
-          Em.Object.create({name: name, value: 'v1'}),
-          Em.Object.create({name: name, value: 'v2'}),
-          Em.Object.create({name: 'n2', value: 'v3'})
-        ]);
-      installerStep7Controller.reopen({
-        overrideToAdd: null,
-        selectedConfigGroup: Em.Object.create({
-          isDefault: isDefault
-        })
+    describe('no overrideToAdd', function () {
+      var isDefault;
+      beforeEach(function () {
+        isDefault = true;
+        var name = 'n1',
+          config = Em.Object.create({overrides: null, name: name, flag: 'flag'}),
+          overrides = Em.A([
+            Em.Object.create({name: name, value: 'v1'}),
+            Em.Object.create({name: name, value: 'v2'}),
+            Em.Object.create({name: 'n2', value: 'v3'})
+          ]);
+        installerStep7Controller.reopen({
+          overrideToAdd: null,
+          selectedConfigGroup: Em.Object.create({
+            isDefault: isDefault
+          })
+        });
+        this.updatedConfig = installerStep7Controller._setOverrides(config, overrides);
+      });
+
+      it('2 overrides', function () {
+        expect(this.updatedConfig.get('overrides.length')).to.equal(2);
+      });
+      it('each isEditable is ' + !isDefault, function () {
+        expect(this.updatedConfig.get('overrides').everyProperty('isEditable', !isDefault)).to.equal(true);
+      });
+      it('each parentSCP.flag is `flag`', function () {
+        expect(this.updatedConfig.get('overrides').everyProperty('parentSCP.flag', 'flag')).to.equal(true);
       });
-      var updatedConfig = installerStep7Controller._setOverrides(config, overrides);
-      expect(updatedConfig.get('overrides.length')).to.equal(2);
-      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',
-        config = Em.Object.create({overrides: null, name: name, flag: 'flag'}),
-        overrides = Em.A([
-          Em.Object.create({name: name, value: 'v1'}),
-          Em.Object.create({name: name, value: 'v2'}),
-          Em.Object.create({name: 'n2', value: 'v3'})
-        ]);
-      installerStep7Controller.reopen({
-        overrideToAdd: Em.Object.create({name: name}),
-        selectedService: {configGroups: [Em.Object.create({name: 'n', properties: []})]},
-        selectedConfigGroup: Em.Object.create({
-          isDefault: isDefault,
-          name: 'n'
-        })
+    describe('overrideToAdd exists', function () {
+      var isDefault = true;
+      beforeEach(function () {
+        var name = 'n1',
+          config = Em.Object.create({overrides: null, name: name, flag: 'flag'}),
+          overrides = Em.A([
+            Em.Object.create({name: name, value: 'v1'}),
+            Em.Object.create({name: name, value: 'v2'}),
+            Em.Object.create({name: 'n2', value: 'v3'})
+          ]);
+        installerStep7Controller.reopen({
+          overrideToAdd: Em.Object.create({name: name}),
+          selectedService: {configGroups: [Em.Object.create({name: 'n', properties: []})]},
+          selectedConfigGroup: Em.Object.create({
+            isDefault: isDefault,
+            name: 'n'
+          })
+        });
+        this.updatedConfig = installerStep7Controller._setOverrides(config, overrides);
+      });
+
+      it('3 overrides', function () {
+        expect(this.updatedConfig.get('overrides.length')).to.equal(3);
+      });
+      it('each isEditable is ' + !isDefault, function () {
+        expect(this.updatedConfig.get('overrides').everyProperty('isEditable', !isDefault)).to.equal(true);
+      });
+      it('each parentSCP.flag is `flag`', function () {
+        expect(this.updatedConfig.get('overrides').everyProperty('parentSCP.flag', 'flag')).to.equal(true);
       });
-      var updatedConfig = installerStep7Controller._setOverrides(config, overrides);
-      expect(updatedConfig.get('overrides.length')).to.equal(3);
-      expect(updatedConfig.get('overrides').everyProperty('isEditable', !isDefault)).to.equal(true);
-      expect(updatedConfig.get('overrides').everyProperty('parentSCP.flag', 'flag')).to.equal(true);
     });
   });
 
@@ -1721,25 +1744,27 @@ describe('App.InstallerStep7Controller', function () {
         expectedNewValue: dfsNameservices + '/hawq_data'
       }
     ]).forEach(function (test) {
-      it(test.serviceName + ' ' + test.configToUpdate, function () {
-        var serviceConfigs = [App.ServiceConfig.create({
-          serviceName: test.serviceName,
+
+      var serviceConfigs = [App.ServiceConfig.create({
+        serviceName: test.serviceName,
+        configs: [
+          Em.Object.create({
+            name: test.configToUpdate,
+            value: test.oldValue
+          })
+        ]
+      }),
+        App.ServiceConfig.create({
+          serviceName: 'HDFS',
           configs: [
             Em.Object.create({
-              name: test.configToUpdate,
-              value: test.oldValue
+              name: 'dfs.nameservices',
+              value: dfsNameservices
             })
           ]
-        }),
-          App.ServiceConfig.create({
-            serviceName: 'HDFS',
-            configs: [
-              Em.Object.create({
-                name: 'dfs.nameservices',
-                value: dfsNameservices
-              })
-            ]
-          })];
+        })];
+
+      it(test.serviceName + ' ' + test.configToUpdate, function () {
         installerStep7Controller.reopen({
           selectedServiceNames: [test.serviceName, 'HDFS']
         });

+ 229 - 168
ambari-web/test/controllers/wizard/step8_test.js

@@ -240,7 +240,8 @@ describe('App.WizardStep8Controller', function () {
   });
 
   describe('#createCoreSiteObj', function () {
-    it('should return config', function () {
+
+    beforeEach(function () {
       var content = Em.Object.create({
         services: Em.A([
           Em.Object.create({
@@ -306,6 +307,9 @@ describe('App.WizardStep8Controller', function () {
           ])
         })
       ]));
+    });
+
+    it('should return config', function () {
       var expected = {
         "type": "core-site",
         "tag": "version1",
@@ -321,6 +325,7 @@ describe('App.WizardStep8Controller', function () {
   });
 
   describe('#createConfigurationGroups', function () {
+    var content;
     beforeEach(function() {
       sinon.stub(App.router,'get').returns(Em.Object.create({
         getDBProperty: function() {
@@ -335,12 +340,7 @@ describe('App.WizardStep8Controller', function () {
         },
         createSiteObj: App.MainServiceInfoConfigsController.create({}).createSiteObj.bind(App.MainServiceInfoConfigsController.create({}))
       }));
-    });
-    afterEach(function() {
-      App.router.get.restore();
-    });
-    it('should push group in properties', function () {
-      var content = Em.Object.create({
+      content = Em.Object.create({
         configGroups: Em.A([
           Em.Object.create({
             is_default: true,
@@ -398,6 +398,12 @@ describe('App.WizardStep8Controller', function () {
       installerStep8Controller.set('ajaxRequestsQueue', App.ajaxQueue.create());
       installerStep8Controller.get('ajaxRequestsQueue').clear();
       installerStep8Controller.createConfigurationGroups();
+    });
+    afterEach(function() {
+      App.router.get.restore();
+    });
+
+    it('should push group in properties', function () {
       var expected = [
         {
           "value": "p3",
@@ -434,7 +440,8 @@ describe('App.WizardStep8Controller', function () {
   });
 
   describe('#loadServices', function () {
-    it('should load services', function () {
+
+    beforeEach(function () {
       var services = Em.A([
         Em.Object.create({
           serviceName: 's1',
@@ -503,6 +510,9 @@ describe('App.WizardStep8Controller', function () {
       installerStep8Controller.set('services', Em.A([]));
       installerStep8Controller.reopen({selectedServices: selectedServices});
       installerStep8Controller.loadServices();
+    });
+
+    it('should load services', function () {
       var expected = [
         {
           "service_name": "s1",
@@ -537,7 +547,8 @@ describe('App.WizardStep8Controller', function () {
   });
 
   describe('#removeClientsFromList', function () {
-    it('should remove h1', function () {
+
+    beforeEach(function () {
       installerStep8Controller.set('content', Em.Object.create({
         hosts: Em.Object.create({
           h1: Em.Object.create({
@@ -552,6 +563,9 @@ describe('App.WizardStep8Controller', function () {
           })
         })
       }));
+    });
+
+    it('should remove h1', function () {
       var hostList = Em.A(['h1','h2']);
       installerStep8Controller.removeClientsFromList('h1', hostList);
       expect(JSON.parse(JSON.stringify(hostList))).to.eql(["h2"]);
@@ -559,7 +573,8 @@ describe('App.WizardStep8Controller', function () {
   });
 
   describe('#createSlaveAndClientsHostComponents', function () {
-    it('should return non install object', function () {
+
+    beforeEach(function () {
       installerStep8Controller.set('content', Em.Object.create({
         masterComponentHosts: Em.A([
           Em.Object.create({
@@ -615,13 +630,17 @@ describe('App.WizardStep8Controller', function () {
       }));
       installerStep8Controller.set('ajaxRequestsQueue', App.ajaxQueue.create());
       installerStep8Controller.get('ajaxRequestsQueue').clear();
+    });
+
+    it('should return non install object', function () {
       installerStep8Controller.createSlaveAndClientsHostComponents();
       expect(installerStep8Controller.get('content.clients')[0].isInstalled).to.be.false;
     });
   });
 
   describe('#createAdditionalClientComponents', function () {
-    it('should bes equal to content.cluster.name', function () {
+
+    beforeEach(function () {
       installerStep8Controller.set('content', Em.Object.create({
         masterComponentHosts: Em.A([
           Em.Object.create({
@@ -669,6 +688,10 @@ describe('App.WizardStep8Controller', function () {
       installerStep8Controller.set('ajaxRequestsQueue', App.ajaxQueue.create());
       installerStep8Controller.get('ajaxRequestsQueue').clear();
       installerStep8Controller.createAdditionalClientComponents();
+    });
+
+    it('should bes equal to content.cluster.name', function () {
+
       var result = [
         {
           "hostNames": "name",
@@ -1526,60 +1549,82 @@ 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.Object.create({
-                serviceName: 'GANGLIA', isSelected: true, isInstalled: false, serviceComponents: [
-                  Em.Object.create({
-                    componentName: 'GANGLIA_MONITOR',
-                    isRequiredOnAllHosts: true
-                  }),
-                  Em.Object.create({
-                    componentName: 'GANGLIA_SERVER',
-                    isRequiredOnAllHosts: false
-                  })
-                ]
-              })
-            ]
-          }
+      describe('should add components with isRequiredOnAllHosts == true (1)', function() {
+
+        beforeEach(function () {
+          installerStep8Controller.reopen({
+            getRegisteredHosts: function() {
+              return [{hostName: 'h1'}, {hostName: 'h2'}];
+            },
+            content: {
+              services: [
+                Em.Object.create({
+                  serviceName: 'GANGLIA', isSelected: true, isInstalled: false, serviceComponents: [
+                    Em.Object.create({
+                      componentName: 'GANGLIA_MONITOR',
+                      isRequiredOnAllHosts: true
+                    }),
+                    Em.Object.create({
+                      componentName: 'GANGLIA_SERVER',
+                      isRequiredOnAllHosts: false
+                    })
+                  ]
+                })
+              ]
+            }
+          });
+          installerStep8Controller.createAdditionalHostComponents();
+        });
+
+        it('registerHostsToComponent is called once', function () {
+          expect(installerStep8Controller.registerHostsToComponent.calledOnce).to.equal(true);
+        });
+        it('hosts are ["h1", "h2"]', function () {
+          expect(installerStep8Controller.registerHostsToComponent.args[0][0]).to.eql(['h1', 'h2']);
+        });
+        it('component is GANGLIA_MONITOR', function () {
+          expect(installerStep8Controller.registerHostsToComponent.args[0][1]).to.equal('GANGLIA_MONITOR');
         });
-        installerStep8Controller.createAdditionalHostComponents();
-        expect(installerStep8Controller.registerHostsToComponent.calledOnce).to.equal(true);
-        expect(installerStep8Controller.registerHostsToComponent.args[0][0]).to.eql(['h1', 'h2']);
-        expect(installerStep8Controller.registerHostsToComponent.args[0][1]).to.equal('GANGLIA_MONITOR');
+
       });
 
-      it('should add components with isRequiredOnAllHosts == true (2)', function() {
-        installerStep8Controller.reopen({
-          getRegisteredHosts: function() {
-            return [{hostName: 'h1', isInstalled: true}, {hostName: 'h2', isInstalled: false}];
-          },
-          content: {
-            services: [
-              Em.Object.create({
-                serviceName: 'GANGLIA', isSelected: true, isInstalled: true, serviceComponents: [
-                  Em.Object.create({
-                    componentName: 'GANGLIA_MONITOR',
-                    isRequiredOnAllHosts: true
-                  }),
-                  Em.Object.create({
-                    componentName: 'GANGLIA_SERVER',
-                    isRequiredOnAllHosts: false
-                  })
-                ]
-              })
-            ]
-          }
+      describe('should add components with isRequiredOnAllHosts == true (2)', function() {
+
+        beforeEach(function () {
+          installerStep8Controller.reopen({
+            getRegisteredHosts: function() {
+              return [{hostName: 'h1', isInstalled: true}, {hostName: 'h2', isInstalled: false}];
+            },
+            content: {
+              services: [
+                Em.Object.create({
+                  serviceName: 'GANGLIA', isSelected: true, isInstalled: true, serviceComponents: [
+                    Em.Object.create({
+                      componentName: 'GANGLIA_MONITOR',
+                      isRequiredOnAllHosts: true
+                    }),
+                    Em.Object.create({
+                      componentName: 'GANGLIA_SERVER',
+                      isRequiredOnAllHosts: false
+                    })
+                  ]
+                })
+              ]
+            }
+          });
+          installerStep8Controller.createAdditionalHostComponents();
+        });
+
+        it('registerHostsToComponent is called once', function () {
+          expect(installerStep8Controller.registerHostsToComponent.calledOnce).to.equal(true);
+        });
+        it('hosts are ["h2"]', function () {
+          expect(installerStep8Controller.registerHostsToComponent.args[0][0]).to.eql(['h2']);
+        });
+        it('component is GANGLIA_MONITOR', function () {
+          expect(installerStep8Controller.registerHostsToComponent.args[0][1]).to.equal('GANGLIA_MONITOR');
         });
-        installerStep8Controller.createAdditionalHostComponents();
-        expect(installerStep8Controller.registerHostsToComponent.calledOnce).to.equal(true);
-        expect(installerStep8Controller.registerHostsToComponent.args[0][0]).to.eql(['h2']);
-        expect(installerStep8Controller.registerHostsToComponent.args[0][1]).to.equal('GANGLIA_MONITOR');
+
       });
 
       var newDatabases = [
@@ -1592,28 +1637,38 @@ describe('App.WizardStep8Controller', function () {
       ];
 
       newDatabases.forEach(function (db) {
-        it('should add {0}'.format(db.component), function() {
-          installerStep8Controller.reopen({
-            getRegisteredHosts: function() {
-              return [{hostName: 'h1'}, {hostName: 'h2'}];
-            },
-            content: {
-              masterComponentHosts: [
-                {component: 'HIVE_SERVER', hostName: 'h1'},
-                {component: 'HIVE_SERVER', hostName: 'h2'}
-              ],
-              services: [
-                Em.Object.create({serviceName: 'HIVE', isSelected: true, isInstalled: false, serviceComponents: []})
-              ],
-              serviceConfigProperties: [
-                {name: 'hive_database', value: db.name}
-              ]
-            }
+        describe('should add {0}'.format(db.component), function() {
+
+          beforeEach(function () {
+            installerStep8Controller.reopen({
+              getRegisteredHosts: function() {
+                return [{hostName: 'h1'}, {hostName: 'h2'}];
+              },
+              content: {
+                masterComponentHosts: [
+                  {component: 'HIVE_SERVER', hostName: 'h1'},
+                  {component: 'HIVE_SERVER', hostName: 'h2'}
+                ],
+                services: [
+                  Em.Object.create({serviceName: 'HIVE', isSelected: true, isInstalled: false, serviceComponents: []})
+                ],
+                serviceConfigProperties: [
+                  {name: 'hive_database', value: db.name}
+                ]
+              }
+            });
+            installerStep8Controller.createAdditionalHostComponents();
+          });
+
+          it('registerHostsToComponent is called once', function () {
+            expect(installerStep8Controller.registerHostsToComponent.calledOnce).to.equal(true);
+          });
+          it('hosts are ["h1", "h2"]', function () {
+            expect(installerStep8Controller.registerHostsToComponent.args[0][0]).to.eql(['h1', 'h2']);
+          });
+          it('component is ' + db.component, function () {
+            expect(installerStep8Controller.registerHostsToComponent.args[0][1]).to.equal(db.component);
           });
-          installerStep8Controller.createAdditionalHostComponents();
-          expect(installerStep8Controller.registerHostsToComponent.calledOnce).to.equal(true);
-          expect(installerStep8Controller.registerHostsToComponent.args[0][0]).to.eql(['h1', 'h2']);
-          expect(installerStep8Controller.registerHostsToComponent.args[0][1]).to.equal(db.component);
         });
 
       });
@@ -1687,7 +1742,7 @@ describe('App.WizardStep8Controller', function () {
                   hosts: Em.A([
                     Em.Object.create({hostName: 'h1', isInstalled: false}),
                     Em.Object.create({hostName: 'h2', isInstalled: false})
-                  ]),
+                  ])
                 }),
                 Em.Object.create({
                   componentName: 'CLIENT',
@@ -1733,93 +1788,99 @@ describe('App.WizardStep8Controller', function () {
         });
       });
 
-      it('should not add components with isRequiredOnAllHosts == false (2)', 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 = false for all components
-                  Em.Object.create({
-                    componentName: 'ANYSERVICE_MASTER',
-                    isMaster: true,
-                    isRequiredOnAllHosts: false
-                  }),
-                  Em.Object.create({
-                    componentName: 'ANYSERVICE_SLAVE',
-                    isSlave: true,
-                    isRequiredOnAllHosts: false
-                  }),
-                  Em.Object.create({
-                    componentName: 'ANYSERVICE_SLAVE2',
-                    isSlave: true,
-                    isRequiredOnAllHosts: false
-                  }),
-                  Em.Object.create({
-                    componentName: 'ANYSERVICE_CLIENT',
-                    isClient: true,
-                    isRequiredOnAllHosts: false
-                  })
-                ]
-              })
-            ]),
-            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 not add components with isRequiredOnAllHosts == false (2)', 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 = false for all components
+                    Em.Object.create({
+                      componentName: 'ANYSERVICE_MASTER',
+                      isMaster: true,
+                      isRequiredOnAllHosts: false
+                    }),
+                    Em.Object.create({
+                      componentName: 'ANYSERVICE_SLAVE',
+                      isSlave: true,
+                      isRequiredOnAllHosts: false
+                    }),
+                    Em.Object.create({
+                      componentName: 'ANYSERVICE_SLAVE2',
+                      isSlave: true,
+                      isRequiredOnAllHosts: false
+                    }),
+                    Em.Object.create({
+                      componentName: 'ANYSERVICE_CLIENT',
+                      isClient: true,
+                      isRequiredOnAllHosts: false
+                    })
+                  ]
+                })
+              ]),
+              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();
+        });
+
+        it('registerHostsToComponent is not called', function () {
+          // isRequiredOnAllHosts = false for all components, implies that
+          // registerHostsToComponent would be done via
+          // createMasterHostComponents() or createSlaveAndClientsHostComponents()
+          // or createAdditionalClientComponents()
+          // BUT NOT createAdditionalHostComponents()
+          expect(installerStep8Controller.registerHostsToComponent.callCount).to.equal(0);
         });
 
-      installerStep8Controller.set('ajaxRequestsQueue', App.ajaxQueue.create());
-      installerStep8Controller.get('ajaxRequestsQueue').clear();
-      installerStep8Controller.createAdditionalHostComponents();
-      // isRequiredOnAllHosts = false for all components, implies that
-      // registerHostsToComponent would be done via
-      // createMasterHostComponents() or createSlaveAndClientsHostComponents()
-      // or createAdditionalClientComponents()
-      // BUT NOT createAdditionalHostComponents()
-      expect(installerStep8Controller.registerHostsToComponent.callCount).to.equal(0);
       });
 
   });

+ 84 - 61
ambari-web/test/controllers/wizard/step9_test.js

@@ -458,61 +458,74 @@ describe('App.InstallerStep9Controller', function () {
   });
 
   describe('#setIsServicesInstalled', function () {
-    it('Should return 100% completed', function () {
-      var polledData = Em.A([
-        Em.Object.create({
-          Tasks: Em.Object.create({
-            status: 'NONE'
-          })
-        }),
-        Em.Object.create({
-          Tasks: Em.Object.create({
-            status: 'NONE'
-          })
-        })
-      ]);
-      c.setProperties({
-        status: 'failed',
-        isPolling: true,
-        hosts: Em.A([
+
+    Em.A([
+      {
+        m: 'Should return 100% completed',
+        c: {
+          status: 'failed',
+          isPolling: true,
+          hosts: Em.A([
+            Em.Object.create({
+              progress: 0
+            })
+          ])
+        },
+        polledData: Em.A([
           Em.Object.create({
-            progress: 0
-          })
-        ])
-      });
-      c.setIsServicesInstalled(polledData);
-      expect(c.get('progress')).to.equal('100');
-      expect(c.get('isPolling')).to.be.false;
-    });
-    it('Should return 34% completed', function () {
-      var polledData = Em.A([
-        Em.Object.create({
-          Tasks: Em.Object.create({
-            status: 'NONE'
+            Tasks: Em.Object.create({
+              status: 'NONE'
+            })
+          }),
+          Em.Object.create({
+            Tasks: Em.Object.create({
+              status: 'NONE'
+            })
           })
-        }),
-        Em.Object.create({
-          Tasks: Em.Object.create({
-            status: 'NONE'
+        ]),
+        e: {
+          progress: '100',
+          isPolling: false
+        }
+      },
+      {
+        m: 'Should return 34% completed',
+        c: {
+          status: '',
+          isPolling: true,
+          hosts: Em.A([
+            Em.Object.create({
+              progress: 0
+            })
+          ]),
+          content: Em.Object.create({
+            controllerName: 'installerController'
           })
-        })
-      ]);
-      c.setProperties({
-        status: '',
-        isPolling: true,
-        hosts: Em.A([
+        },
+        polledData: Em.A([
+          Em.Object.create({
+            Tasks: Em.Object.create({
+              status: 'NONE'
+            })
+          }),
           Em.Object.create({
-            progress: 0
+            Tasks: Em.Object.create({
+              status: 'NONE'
+            })
           })
         ]),
-        content: Em.Object.create({
-          controllerName: 'installerController'
-        })
+        e: {
+          progress: '34',
+          isPolling: true
+        }
+      }
+    ]).forEach(function (test) {
+      it(test.m, function () {
+        c.setProperties(test.c);
+        c.setIsServicesInstalled(test.polledData);
       });
-      c.setIsServicesInstalled(polledData);
-      expect(c.get('progress')).to.equal('34');
-      expect(c.get('isPolling')).to.be.true;
     });
+
   });
 
   describe('#launchStartServices', function () {
@@ -1005,20 +1018,29 @@ describe('App.InstallerStep9Controller', function () {
       }
     ]);
     tests.forEach(function (test) {
-      it(test.m, function () {
-        var actions = [];
-        for (var prop in test.actions) {
-          if (test.actions.hasOwnProperty(prop) && test.actions[prop]) {
-            for (var i = 0; i < test.actions[prop]; i++) {
-              actions.push({Tasks: {status: prop}});
+      describe(test.m, function () {
+
+        beforeEach(function () {
+          var actions = [];
+          for (var prop in test.actions) {
+            if (test.actions.hasOwnProperty(prop) && test.actions[prop]) {
+              for (var i = 0; i < test.actions[prop]; i++) {
+                actions.push({Tasks: {status: prop}});
+              }
             }
           }
-        }
-        c.reopen({content: {cluster: {status: test.cluster.status}}});
-        App.set('supports.skipComponentStartAfterInstall', test.s);
-        var progress = c.progressPerHost(actions, test.host);
-        expect(progress).to.equal(test.e.progress);
-        expect(test.host.progress).to.equal(test.e.progress.toString());
+          c.reopen({content: {cluster: {status: test.cluster.status}}});
+          App.set('supports.skipComponentStartAfterInstall', test.s);
+          this.progress = c.progressPerHost(actions, test.host);
+        });
+
+        it('progress is ' + test.e.progress, function () {
+          expect(this.progress).to.equal(test.e.progress);
+        });
+
+        it('host progress is ' + test.e.progress.toString(), function () {
+          expect(test.host.progress).to.equal(test.e.progress.toString());
+        });
       });
     });
   });
@@ -1243,8 +1265,9 @@ describe('App.InstallerStep9Controller', function () {
       it(test.m, function () {
         c.reopen({hosts: [Em.Object.create({logTasks: test.tasks})]});
         c.setLogTasksStatePerHost(test.tasksPerHost, c.get('hosts')[0]);
-        expect(c.get('hosts')[0].get('logTasks').everyProperty('Tasks.status', test.e.m)).to.equal(true);
-        expect(c.get('hosts')[0].get('logTasks.length')).to.equal(test.e.l);
+        var host = c.get('hosts')[0];
+        expect(host.get('logTasks').everyProperty('Tasks.status', test.e.m)).to.equal(true);
+        expect(host.get('logTasks.length')).to.equal(test.e.l);
       });
     });
   });

+ 5 - 2
ambari-web/test/controllers/wizard_test.js

@@ -1208,8 +1208,7 @@ describe('App.WizardController', function () {
 
   describe('#enableStep', function () {
 
-    it('should update appropriate value in isStepDisabled', function () {
-
+    beforeEach(function () {
       c.set('isStepDisabled', [
         Em.Object.create({step: 1, value: true}),
         Em.Object.create({step: 2, value: true}),
@@ -1219,10 +1218,14 @@ describe('App.WizardController', function () {
         Em.Object.create({step: 6, value: true}),
         Em.Object.create({step: 7, value: true})
       ]);
+    });
 
+    it('should update 1st value in isStepDisabled', function () {
       c.enableStep(1);
       expect(c.get('isStepDisabled')[0].get('value')).to.be.false;
+    });
 
+    it('should update 6th value in isStepDisabled', function () {
       c.enableStep(7);
       expect(c.get('isStepDisabled')[6].get('value')).to.be.false;
     });

+ 2 - 0
ambari-web/test/helpers.js

@@ -15,6 +15,8 @@
  * the License.
  */
 
+/*eslint-disable mocha-cleanup/no-assertions-outside-it */
+
 module.exports = {
 
   /**

+ 2 - 0
ambari-web/test/mappers/stack_service_mapper_test.js

@@ -15,6 +15,8 @@
  * the License.
  */
 
+/*eslint-disable */
+
 var App = require('app');
 
 require('mappers/stack_service_mapper');

+ 19 - 10
ambari-web/test/mixins/common/serverValidator_test.js

@@ -158,19 +158,28 @@ describe('App.ServerValidatorMixin', function() {
           e: false
         }
       ].forEach(function(test) {
-        it('controller "name": {0} using "EnhancedConfigsMixin": {1} recommendations called: {2}'.format(test.controllerName, test.injectEnhancedConfigsMixin, test.e), function() {
+        describe('controller "name": {0} using "EnhancedConfigsMixin": {1} recommendations called: {2}'.format(test.controllerName, test.injectEnhancedConfigsMixin, test.e), function() {
           var mixed;
-          if (test.injectEnhancedConfigsMixin) {
-            mixed = Em.Object.extend(App.EnhancedConfigsMixin, App.ServerValidatorMixin);
-          } else {
-            mixed = Em.Object.extend(App.ServerValidatorMixin);
-          }
-          // mock controller name in mixed object directly
-          mixed.create({name: test.controllerName}).loadServerSideConfigsRecommendations();
-          expect(App.ajax.send.calledOnce).to.be.eql(test.e);
+          beforeEach(function () {
+            if (test.injectEnhancedConfigsMixin) {
+              mixed = Em.Object.extend(App.EnhancedConfigsMixin, App.ServerValidatorMixin);
+            } else {
+              mixed = Em.Object.extend(App.ServerValidatorMixin);
+            }
+            // mock controller name in mixed object directly
+            mixed.create({name: test.controllerName}).loadServerSideConfigsRecommendations();
+          });
+
+          it('request is ' + (test.e ? '' : 'not') + ' sent', function () {
+            expect(App.ajax.send.calledOnce).to.be.eql(test.e);
+          });
+
           if (test.e) {
-            expect(App.ajax.send.args[0][0].name).to.be.eql('config.recommendations');
+            it('request is valid', function () {
+              expect(App.ajax.send.args[0][0].name).to.be.eql('config.recommendations');
+            });
           }
+
         });
       });
     });

+ 2 - 1
ambari-web/test/models/form_test.js

@@ -19,7 +19,7 @@
 var App = require('app');
 
 require('models/form');
-
+/*eslint-disable mocha-cleanup/no-assertions-outside-it */
 var form,
   field,
   formField,
@@ -75,6 +75,7 @@ var form,
     formField.validate();
     expect(formField.get('errorMessage')).to.equal(message);
   };
+/*eslint-enable mocha-cleanup/no-assertions-outside-it */
 
 describe('App.Form', function () {
 

+ 28 - 17
ambari-web/test/utils/config_test.js

@@ -724,25 +724,36 @@ describe('App.config', function () {
       expect(App.config.createOverride.bind(App.config, null, {}, group)).to.throw(Error, 'serviceConfigProperty can\' be null');
     });
 
-    it('updates originalSCP object ', function() {
-      configProperty.set('overrides', null);
-      configProperty.set('overrideValues', []);
-      configProperty.set('overrideIsFinalValues', []);
-
-      var overridenTemplate2 = {
-        value: "v12",
-        recommendedValue: "rv12",
-        savedValue: "sv12",
-        isFinal: true,
-        recommendedIsFinal: false,
-        savedIsFinal: false
-      };
+    describe('updates originalSCP object ', function() {
+
+      var overridenTemplate2;
+      var override;
+
+      beforeEach(function () {
+        configProperty.set('overrides', null);
+        configProperty.set('overrideValues', []);
+        configProperty.set('overrideIsFinalValues', []);
+        overridenTemplate2 = {
+          value: "v12",
+          recommendedValue: "rv12",
+          savedValue: "sv12",
+          isFinal: true,
+          recommendedIsFinal: false,
+          savedIsFinal: false
+        };
+        override = App.config.createOverride(configProperty, overridenTemplate2, group);
+      });
 
-      var override = App.config.createOverride(configProperty, overridenTemplate2, group);
+      it('overrides.0 is valid', function () {
+        expect(configProperty.get('overrides')[0]).to.be.eql(override);
+      });
+      it('overrideValues is valid', function () {
+        expect(configProperty.get('overrideValues')).to.be.eql([overridenTemplate2.value]);
+      });
+      it('overrideIsFinalValues is valid', function () {
+        expect(configProperty.get('overrideIsFinalValues')).to.be.eql([overridenTemplate2.isFinal]);
+      });
 
-      expect(configProperty.get('overrides')[0]).to.be.eql(override);
-      expect(configProperty.get('overrideValues')).to.be.eql([overridenTemplate2.value]);
-      expect(configProperty.get('overrideIsFinalValues')).to.be.eql([overridenTemplate2.isFinal]);
     });
   });
 

+ 42 - 21
ambari-web/test/utils/configs/config_initializer_test.js

@@ -359,19 +359,29 @@ describe('App.ConfigInitializer', function () {
 
       cases['hive_database'].forEach(function (item) {
         var title = 'hive_database value should be set to {0}';
-        it(title.format(item.value), function () {
-          this.stub
-            .withArgs('supports.alwaysEnableManagedMySQLForHive').returns(item.alwaysEnableManagedMySQLForHive)
-            .withArgs('router.currentState.name').returns(item.currentStateName)
-            .withArgs('isManagedMySQLForHiveEnabled').returns(item.isManagedMySQLForHiveEnabled);
-          serviceConfigProperty.setProperties({
-            name: 'hive_database',
-            value: item.receivedValue,
-            options: item.options
+        describe(title.format(item.value), function () {
+
+          beforeEach(function () {
+            this.stub
+              .withArgs('supports.alwaysEnableManagedMySQLForHive').returns(item.alwaysEnableManagedMySQLForHive)
+              .withArgs('router.currentState.name').returns(item.currentStateName)
+              .withArgs('isManagedMySQLForHiveEnabled').returns(item.isManagedMySQLForHiveEnabled);
+            serviceConfigProperty.setProperties({
+              name: 'hive_database',
+              value: item.receivedValue,
+              options: item.options
+            });
+            App.ConfigInitializer.initialValue(serviceConfigProperty, {}, []);
+          });
+
+          it('value is ' + item.value, function () {
+            expect(serviceConfigProperty.get('value')).to.equal(item.value);
           });
-          App.ConfigInitializer.initialValue(serviceConfigProperty, {}, []);
-          expect(serviceConfigProperty.get('value')).to.equal(item.value);
-          expect(serviceConfigProperty.get('options').findProperty('displayName', 'New MySQL Database').hidden).to.equal(item.hidden);
+
+          it('`New MySQL Database` is ' + (item.hidden ? '' : 'not') + ' hidden', function () {
+            expect(serviceConfigProperty.get('options').findProperty('displayName', 'New MySQL Database').hidden).to.equal(item.hidden);
+          });
+
         });
       });
 
@@ -808,19 +818,30 @@ describe('App.ConfigInitializer', function () {
         expectedValue: 'thrift://h1:9083,thrift://h2:9083'
       }
     ]).forEach(function (test) {
-      it(test.m || test.config, function () {
-        serviceConfigProperty.setProperties({
-          name: test.config,
-          recommendedValue: test.rValue,
-          filename: test.filename
+      describe(test.m || test.config, function () {
+
+        beforeEach(function () {
+          serviceConfigProperty.setProperties({
+            name: test.config,
+            recommendedValue: test.rValue,
+            filename: test.filename
+          });
+          App.ConfigInitializer.initialValue(serviceConfigProperty, test.localDB, test.dependencies);
+        });
+
+        it('value is ' + test.expectedValue, function () {
+          expect(serviceConfigProperty.get('value')).to.eql(test.expectedValue);
         });
-        App.ConfigInitializer.initialValue(serviceConfigProperty, test.localDB, test.dependencies);
-        expect(serviceConfigProperty.get('value')).to.eql(test.expectedValue);
+
         if (Em.isNone(test.expectedRValue)) {
-          expect(serviceConfigProperty.get('recommendedValue')).to.eql(test.expectedValue);
+          it('recommendedValue is ' + test.expectedValue, function () {
+            expect(serviceConfigProperty.get('recommendedValue')).to.eql(test.expectedValue);
+          });
         }
         else {
-          expect(serviceConfigProperty.get('recommendedValue')).to.eql(test.expectedRValue);
+          it('recommendedValue is ' + test.expectedRValue, function () {
+            expect(serviceConfigProperty.get('recommendedValue')).to.eql(test.expectedRValue);
+          });
         }
 
       });

+ 53 - 30
ambari-web/test/views/common/configs/widgets/config_widget_view_test.js

@@ -180,7 +180,7 @@ describe('App.ConfigWidgetView', function () {
       view = App.ConfigWidgetView.create({
         controller: Em.Object.extend(App.EnhancedConfigsMixin, {
         }).create({
-          updateDependentConfigs: function() {},
+          updateDependentConfigs: function() {}
         }),
         config: Em.Object.create({ name: 'config1'})
       });
@@ -215,37 +215,60 @@ describe('App.ConfigWidgetView', function () {
       });
     });
 
-    it('when dependent configs has multiple parents appropriate parent config should be removed', function() {
-      view.set('controller.recommendations', [
-        {name: 'dependent1', parentConfigs: ['config1', 'config2']},
-        {name: 'dependent2', parentConfigs: ['config2', 'config1']},
-        {name: 'dependent3', parentConfigs: ['config1']}
-      ]);
-      view.restoreDependentConfigs(view.get('config'));
-      expect(view.get('controller.recommendations').findProperty('name', 'dependent1').parentConfigs.toArray()).to.be.eql(["config2"]);
-      expect(view.get('controller.recommendations').findProperty('name', 'dependent2').parentConfigs.toArray()).to.be.eql(["config2"]);
-      expect(view.get('controller.recommendations.length')).to.be.eql(2);
+    describe('when dependent configs has multiple parents appropriate parent config should be removed', function() {
+
+      beforeEach(function () {
+        view.set('controller.recommendations', [
+          {name: 'dependent1', parentConfigs: ['config1', 'config2']},
+          {name: 'dependent2', parentConfigs: ['config2', 'config1']},
+          {name: 'dependent3', parentConfigs: ['config1']}
+        ]);
+        view.restoreDependentConfigs(view.get('config'));
+      });
+
+      it('2 recommendations', function () {
+        expect(view.get('controller.recommendations.length')).to.be.equal(2);
+      });
+
+      it('dependent1 parent is ["config2"]', function () {
+        expect(view.get('controller.recommendations').findProperty('name', 'dependent1').parentConfigs.toArray()).to.be.eql(["config2"]);
+      });
+      it('dependent2 parent is ["config2"]', function () {
+        expect(view.get('controller.recommendations').findProperty('name', 'dependent2').parentConfigs.toArray()).to.be.eql(["config2"]);
+      });
+
     });
 
-    it('dependent config value should be set with inital or saved when it has one parent', function() {
-      var ctrl = view.get('controller');
-      ctrl.set('stepConfigs', [
-        Em.Object.create({
-          configs: Em.A([
-            Em.Object.create({ name: 'dependent3', savedValue: '1', value: 2, filename: 'some-file.xml' }),
-            Em.Object.create({ name: 'dependent2', savedValue: '4', value: '10', filename: 'some-file.xml' })
-          ])
-        })
-      ]);
-      view.set('controller.recommendations', [
-        {propertyName: 'dependent1', parentConfigs: ['config1', 'config2'], fileName: 'some-file' },
-        {propertyName: 'dependent2', parentConfigs: ['config2', 'config1'], fileName: 'some-file'},
-        {propertyName: 'dependent3', parentConfigs: ['config1'], fileName: 'some-file' }
-      ]);
-      view.restoreDependentConfigs(view.get('config'));
-      expect(view.get('controller').findConfigProperty('dependent3', 'some-file.xml').get('value')).to.be.eql('1');
-      // config with multi dependency should not be updated
-      expect(view.get('controller').findConfigProperty('dependent2', 'some-file.xml').get('value')).to.be.eql('10');
+    describe('dependent config value should be set with inital or saved when it has one parent', function() {
+      var ctrl;
+
+      beforeEach(function () {
+        ctrl = view.get('controller');
+        ctrl.set('stepConfigs', [
+          Em.Object.create({
+            configs: Em.A([
+              Em.Object.create({ name: 'dependent3', savedValue: '1', value: 2, filename: 'some-file.xml' }),
+              Em.Object.create({ name: 'dependent2', savedValue: '4', value: '10', filename: 'some-file.xml' })
+            ])
+          })
+        ]);
+        view.set('controller.recommendations', [
+          {propertyName: 'dependent1', parentConfigs: ['config1', 'config2'], fileName: 'some-file' },
+          {propertyName: 'dependent2', parentConfigs: ['config2', 'config1'], fileName: 'some-file'},
+          {propertyName: 'dependent3', parentConfigs: ['config1'], fileName: 'some-file' }
+        ]);
+        view.restoreDependentConfigs(view.get('config'));
+      });
+
+      it('dependent3 value is `1`', function () {
+        expect(view.get('controller').findConfigProperty('dependent3', 'some-file.xml').get('value')).to.be.equal('1');
+      });
+
+      it('dependent2 value is `10`', function () {
+        // config with multi dependency should not be updated
+        expect(view.get('controller').findConfigProperty('dependent2', 'some-file.xml').get('value')).to.be.equal('10');
+      });
+
     });
 
   });

+ 9 - 7
ambari-web/test/views/common/configs/widgets/list_config_widget_view_test.js

@@ -136,11 +136,12 @@ describe('App.ListConfigWidgetView', function () {
       view.sendRequestRorDependentConfigs.restore();
     });
     it('value updates if some option', function () {
-      view.toggleOption({context: view.get('options')[2]});
+      var options = view.get('options');
+      view.toggleOption({context: options[2]});
       expect(view.get('config.value')).to.equal('2,1,3');
-      view.toggleOption({context: view.get('options')[1]});
+      view.toggleOption({context: options[1]});
       expect(view.get('config.value')).to.equal('1,3');
-      view.toggleOption({context: view.get('options')[1]});
+      view.toggleOption({context: options[1]});
       expect(view.get('config.value')).to.equal('1,3,2');
     });
 
@@ -161,13 +162,14 @@ describe('App.ListConfigWidgetView', function () {
       view.sendRequestRorDependentConfigs.restore();
     });
     it('should restore saved value', function () {
-      view.toggleOption({context: view.get('options')[0]});
-      view.toggleOption({context: view.get('options')[1]});
-      view.toggleOption({context: view.get('options')[2]});
+      var options = view.get('options');
+      view.toggleOption({context: options[0]});
+      view.toggleOption({context: options[1]});
+      view.toggleOption({context: options[2]});
       expect(view.get('config.value')).to.equal('3');
       view.restoreValue();
       expect(view.get('config.value')).to.equal('2,1');
-      expect(view.get('controller.removeCurrentFromDependentList')).to.be.called
+      expect(view.get('controller.removeCurrentFromDependentList')).to.be.called;
     });
 
   });

+ 26 - 19
ambari-web/test/views/common/configs/widgets/slider_config_widget_view_test.js

@@ -544,28 +544,35 @@ describe('App.SliderConfigWidgetView', function () {
     ];
 
     tests.forEach(function(test) {
-      it('should generate ticks: {0} - tick labels: {1}'.format(test.e.ticks, test.e.ticksLabels), function() {
+      describe('should generate ticks: {0} - tick labels: {1}'.format(test.e.ticks, test.e.ticksLabels), function() {
         var ticks, ticksLabels;
-        this.view.reopen(test.viewSetup);
-        this.view.set('controller', {
-          isCompareMode: test.viewSetup.isCompareMode
-        });
-        var sliderCopy = window.Slider.prototype;
-        window.Slider = function(a, b) {
-          ticks = b.ticks;
-          ticksLabels = b.ticks_labels;
-          return {
-            on: function() {
-              return this;
-            }
+        beforeEach(function () {
+          this.view.reopen(test.viewSetup);
+          this.view.set('controller', {
+            isCompareMode: test.viewSetup.isCompareMode
+          });
+          var sliderCopy = window.Slider.prototype;
+          window.Slider = function(a, b) {
+            ticks = b.ticks;
+            ticksLabels = b.ticks_labels;
+            return {
+              on: function() {
+                return this;
+              }
+            };
           };
-        };
+          this.view.willInsertElement();
+          this.view.initSlider();
+          window.Slider.prototype = sliderCopy;
+        });
 
-        this.view.willInsertElement();
-        this.view.initSlider();
-        window.Slider.prototype = sliderCopy;
-        expect(ticks.toArray()).to.be.eql(test.e.ticks);
-        expect(ticksLabels.toArray()).to.be.eql(test.e.ticksLabels);
+        it('ticks are ' + test.e.ticks, function () {
+          expect(ticks.toArray()).to.be.eql(test.e.ticks);
+        });
+
+        it('ticksLabels are ' + test.e.ticksLabels, function () {
+          expect(ticksLabels.toArray()).to.be.eql(test.e.ticksLabels);
+        });
       });
     });
   });

+ 2 - 2
ambari-web/test/views/common/configs/widgets/toggle_config_widget_view_test.js

@@ -89,8 +89,8 @@ describe('App.ToggleConfigWidgetView', function () {
         isValid: true
       });
       expect(this.view.isValueCompatibleWithWidget()).to.be.false;
-      expect(this.view.get('warnMessage')).to.have.property('length').that.is.least(1);
-      expect(this.view.get('issueMessage')).to.have.property('length').that.is.least(1);
+      expect(this.view.get('warnMessage')).to.be.not.empty;
+      expect(this.view.get('issueMessage')).to.be.not.empty;
     });
 
   });

+ 23 - 12
ambari-web/test/views/common/controls_view_test.js

@@ -295,23 +295,34 @@ describe('App.ServiceConfigRadioButtons', function () {
     });
 
     cases.forEach(function (item) {
-      it(item.title, function () {
-        this.stub.withArgs('currentStackVersion').returns(item.currentStackVersion);
-        rangerVersion = item.rangerVersion;
-        view.reopen({controller: item.controller});
-        view.setProperties({
-          categoryConfigsAll: item.controller.get('selectedService.configs'),
-          serviceConfig: item.serviceConfig
-        });
+      describe(item.title, function () {
+
+        var additionalView1, additionalView2;
+        beforeEach(function () {
+          this.stub.withArgs('currentStackVersion').returns(item.currentStackVersion);
+          rangerVersion = item.rangerVersion;
+          view.reopen({controller: item.controller});
+          view.setProperties({
+            categoryConfigsAll: item.controller.get('selectedService.configs'),
+            serviceConfig: item.serviceConfig
+          });
 
-        var additionalView1 = view.get('categoryConfigsAll').findProperty('name', item.propertyAppendTo1).get('additionalView'),
+          additionalView1 = view.get('categoryConfigsAll').findProperty('name', item.propertyAppendTo1).get('additionalView');
           additionalView2 = view.get('categoryConfigsAll').findProperty('name', item.propertyAppendTo2).get('additionalView');
+        });
 
-        expect(Em.isNone(additionalView1)).to.equal(item.isAdditionalView1Null);
-        expect(Em.isNone(additionalView2)).to.equal(item.isAdditionalView2Null);
+        it('additionalView1 is ' + (item.isAdditionalView1Null ? '' : 'not') + ' null', function () {
+          expect(Em.isNone(additionalView1)).to.equal(item.isAdditionalView1Null);
+        });
+
+        it('additionalView2 is ' + (item.isAdditionalView2Null ? '' : 'not') + ' null', function () {
+          expect(Em.isNone(additionalView2)).to.equal(item.isAdditionalView2Null);
+        });
 
         if (!item.isAdditionalView2Null) {
-          expect(additionalView2.create().get('message')).to.equal(Em.I18n.t('services.service.config.database.msg.jdbcSetup').format(item.dbType, item.driver));
+          it('additionalView2.message is valid', function () {
+            expect(additionalView2.create().get('message')).to.equal(Em.I18n.t('services.service.config.database.msg.jdbcSetup').format(item.dbType, item.driver));
+          });
         }
 
       });

+ 18 - 9
ambari-web/test/views/common/rolling_restart_view_test.js

@@ -69,15 +69,24 @@ describe('App.RollingRestartView', function () {
     ];
 
     testCases.forEach(function (test) {
-      it(test.restartHostComponents.length + ' components to restart', function () {
-        view.set('batchSize', -1);
-        view.set('interBatchWaitTimeSeconds', -1);
-        view.set('tolerateSize', -1);
-        view.set('hostComponentName', test.hostComponentName);
-        view.set('restartHostComponents', test.restartHostComponents);
-        view.initialize();
-        expect(view.get('batchSize')).to.equal(test.result.batchSize);
-        expect(view.get('tolerateSize')).to.equal(test.result.tolerateSize);
+      describe(test.restartHostComponents.length + ' components to restart', function () {
+
+        beforeEach(function () {
+          view.set('batchSize', -1);
+          view.set('interBatchWaitTimeSeconds', -1);
+          view.set('tolerateSize', -1);
+          view.set('hostComponentName', test.hostComponentName);
+          view.set('restartHostComponents', test.restartHostComponents);
+          view.initialize();
+        });
+
+        it('batchSize is ' + test.result.batchSize, function() {
+          expect(view.get('batchSize')).to.equal(test.result.batchSize);
+        });
+
+        it('tolerateSize is ' + test.result.tolerateSize, function() {
+          expect(view.get('tolerateSize')).to.equal(test.result.tolerateSize);
+        });
       })
     }, this);
   });

+ 20 - 8
ambari-web/test/views/main/admin/stack_upgrade/upgrade_wizard_view_test.js

@@ -679,16 +679,28 @@ describe('App.upgradeWizardView', function () {
     });
 
     cases.forEach(function (item) {
-      it(item.title, function () {
-        view.set('controller.areSkippedServiceChecksLoaded', item.areSkippedServiceChecksLoaded);
-        view.reopen({
-          isFinalizeItem: item.isFinalizeItem
+      describe(item.title, function () {
+
+        beforeEach(function () {
+          view.set('controller.areSkippedServiceChecksLoaded', item.areSkippedServiceChecksLoaded);
+          view.reopen({
+            isFinalizeItem: item.isFinalizeItem
+          });
+          view.propertyDidChange('isFinalizeItem');
+        });
+
+        it('request is sent ' + item.ajaxSendCallCount + ' times', function (){
+          expect(App.ajax.send.callCount).to.equal(item.ajaxSendCallCount);
         });
-        view.propertyDidChange('isFinalizeItem');
-        expect(App.ajax.send.callCount).to.equal(item.ajaxSendCallCount);
-        expect(view.get('controller.areSkippedServiceChecksLoaded')).to.equal(item.areSkippedServiceChecksLoadedResult);
+
+        it('areSkippedServiceChecksLoaded is ' + item.areSkippedServiceChecksLoaded, function () {
+          expect(view.get('controller.areSkippedServiceChecksLoaded')).to.equal(item.areSkippedServiceChecksLoadedResult);
+        });
+
         if (item.ajaxSendCallCount) {
-          expect(App.ajax.send.firstCall.args[0].data.upgradeId).to.equal(1);
+          it('upgradeId is 1', function () {
+            expect(App.ajax.send.firstCall.args[0].data.upgradeId).to.equal(1);
+          });
         }
       });
     });

+ 18 - 8
ambari-web/test/views/main/alerts/manage_alert_groups/select_definitions_popup_body_view_test.js

@@ -228,15 +228,25 @@ describe('App.SelectDefinitionsPopupBodyView', function () {
       }
     ];
     testCases.forEach(function (test) {
-      it(test.title, function () {
-        view.set('parentView.availableDefs', test.data.defs);
-        view.set('showOnlySelectedDefs', test.data.showOnlySelectedDefs);
-        view.set('filterComponent', test.data.filterComponent);
-        view.set('filterService', test.data.filterService);
+      describe(test.title, function () {
+
+        beforeEach(function () {
+          view.set('parentView.availableDefs', test.data.defs);
+          view.set('showOnlySelectedDefs', test.data.showOnlySelectedDefs);
+          view.set('filterComponent', test.data.filterComponent);
+          view.set('filterService', test.data.filterService);
+
+          view.filterDefs();
+        });
+
+        it('availableDefs.@each.filtered is ' + test.result, function () {
+          expect(view.get('parentView.availableDefs').mapProperty('filtered')).to.eql(test.result);
+        });
+
+        it('startIndex is 1', function () {
+          expect(view.get('startIndex')).to.equal(1);
+        });
 
-        view.filterDefs();
-        expect(view.get('parentView.availableDefs').mapProperty('filtered')).to.eql(test.result);
-        expect(view.get('startIndex')).to.equal(1);
       });
     });
   });

+ 41 - 16
ambari-web/test/views/main/dashboard/widget_test.js

@@ -335,15 +335,28 @@ describe('App.DashboardWidgetView', function () {
         }
       ];
       testCases.forEach(function (test) {
-        it("thresh1 - " + test.data.thresh1 + ', maxValue - ' + test.data.maxValue, function () {
-          widget.set('isThresh2Error', false);
-          widget.set('thresh2', test.data.thresh2 || "");
-          widget.set('thresh1', test.data.thresh1);
-          widget.set('maxValue', test.data.maxValue);
-          widget.observeThresh1Value();
-          expect(widget.get('isThresh1Error')).to.equal(test.result.isThresh1Error);
-          expect(widget.get('errorMessage1')).to.equal(test.result.errorMessage1);
-          expect(widget.updateSlider.called).to.be.true;
+        describe("thresh1 - " + test.data.thresh1 + ', maxValue - ' + test.data.maxValue, function () {
+
+          beforeEach(function () {
+            widget.set('isThresh2Error', false);
+            widget.set('thresh2', test.data.thresh2 || "");
+            widget.set('thresh1', test.data.thresh1);
+            widget.set('maxValue', test.data.maxValue);
+            widget.observeThresh1Value();
+          });
+
+          it('isThresh1Error is ' + test.result.isThresh1Error, function () {
+            expect(widget.get('isThresh1Error')).to.equal(test.result.isThresh1Error);
+          });
+
+          it('errorMessage1 is ' + test.result.errorMessage1, function () {
+            expect(widget.get('errorMessage1')).to.equal(test.result.errorMessage1);
+          });
+
+          it('updateSlider is called', function () {
+            expect(widget.updateSlider.called).to.be.true;
+          });
+
         });
       });
     });
@@ -408,13 +421,25 @@ describe('App.DashboardWidgetView', function () {
         }
       ];
       testCases.forEach(function (test) {
-        it("thresh2 - " + test.data.thresh2 + ', maxValue - ' + test.data.maxValue, function () {
-          widget.set('thresh2', test.data.thresh2 || "");
-          widget.set('maxValue', test.data.maxValue);
-          widget.observeThresh2Value();
-          expect(widget.get('isThresh2Error')).to.equal(test.result.isThresh2Error);
-          expect(widget.get('errorMessage2')).to.equal(test.result.errorMessage2);
-          expect(widget.updateSlider.called).to.be.true;
+        describe("thresh2 - " + test.data.thresh2 + ', maxValue - ' + test.data.maxValue, function () {
+
+          beforeEach(function () {
+            widget.set('thresh2', test.data.thresh2 || "");
+            widget.set('maxValue', test.data.maxValue);
+            widget.observeThresh2Value();
+          });
+
+          it('isThresh2Error is ' + test.result.isThresh2Error, function () {
+            expect(widget.get('isThresh2Error')).to.equal(test.result.isThresh2Error);
+          });
+
+          it('errorMessage2 is ' + JSON.stringify(test.result.errorMessage2), function () {
+            expect(widget.get('errorMessage2')).to.equal(test.result.errorMessage2);
+          });
+
+          it('updateSlider is called', function () {
+            expect(widget.updateSlider.called).to.be.true;
+          });
         });
       });
     });

+ 18 - 8
ambari-web/test/views/main/dashboard/widgets_test.js

@@ -115,14 +115,24 @@ describe('App.MainDashboardWidgetsView', function () {
       }
     ]);
     tests.forEach(function (test) {
-      it(test.m, function () {
-        view.set('host_metrics_model', test.models.host_metrics_model);
-        view.set('hdfs_model', test.models.hdfs_model);
-        view.set('hbase_model', test.models.hbase_model);
-        view.set('yarn_model', test.models.yarn_model);
-        view.setInitPrefObject();
-        expect(view.get('initPrefObject.visible.length')).to.equal(test.e.visibleL);
-        expect(view.get('initPrefObject.hidden.length')).to.equal(test.e.hiddenL);
+      describe(test.m, function () {
+
+        beforeEach(function () {
+          view.set('host_metrics_model', test.models.host_metrics_model);
+          view.set('hdfs_model', test.models.hdfs_model);
+          view.set('hbase_model', test.models.hbase_model);
+          view.set('yarn_model', test.models.yarn_model);
+          view.setInitPrefObject();
+        });
+
+        it('visible.length is ' + test.e.visibleL, function () {
+          expect(view.get('initPrefObject.visible.length')).to.equal(test.e.visibleL);
+        });
+
+        it('hidden.length is ' + test.e.hiddenL, function () {
+          expect(view.get('initPrefObject.hidden.length')).to.equal(test.e.hiddenL);
+        });
+
       });
     });
   });

+ 7 - 1
ambari-web/test/views/main/host/details_test.js

@@ -132,8 +132,11 @@ describe('App.MainHostDetailsView', function () {
       App.set('services', Em.K);
     });
 
-    it('should get only clients with configs', function() {
+    it('should get only clients with configs (1)', function() {
       expect(view.get('clientsWithConfigs')).to.have.length(1);
+    });
+
+    it('should get only clients with configs (2)', function() {
       view.get('content.hostComponents').pushObject(Em.Object.create({
         isClient: true,
         service: Em.Object.create({
@@ -141,6 +144,9 @@ describe('App.MainHostDetailsView', function () {
         })
       }));
       expect(view.get('clientsWithConfigs')).to.have.length(1);
+    });
+
+    it('should get only clients with configs (3)', function() {
       view.get('content.hostComponents').pushObject(Em.Object.create({
         isClient: true,
         service: Em.Object.create({

+ 12 - 7
ambari-web/test/views/wizard/step5_view_test.js

@@ -105,14 +105,19 @@ describe('App.WizardStep5View', function() {
   });
 
   describe('#shouldUseInputs', function() {
-    it('should based on hosts count', function() {
-      view.set('controller.hosts', d3.range(0, 25).map(function() {return {};}));
-      expect(view.get('shouldUseInputs')).to.be.false;
-      view.set('controller.hosts', d3.range(0, 26).map(function() {return {};}));
-      expect(view.get('shouldUseInputs')).to.be.true;
-      view.set('controller.hosts', d3.range(0, 24).map(function() {return {};}));
-      expect(view.get('shouldUseInputs')).to.be.false;
+
+    Em.A([
+      {range: 25, e: false},
+      {range: 26, e: true},
+      {range: 24, e: false}
+    ]).forEach(function (test) {
+      it(test.e + ' for ' + test.range + ' hosts', function () {
+        view.set('controller.hosts', d3.range(0, test.range).map(function() {return {};}));
+        expect(view.get('shouldUseInputs')).to.be.equal(test.e);
+      });
+
     });
+
   });
 
 });