소스 검색

AMBARI-15128. Fix UI UT (onechiporenko)

Oleg Nechiporenko 9 년 전
부모
커밋
4fcca627e1
23개의 변경된 파일72개의 추가작업 그리고 83개의 파일을 삭제
  1. 1 1
      ambari-web/test/controllers/installer_test.js
  2. 2 2
      ambari-web/test/controllers/main/admin/highAvailability/progress_popup_controller_test.js
  3. 2 6
      ambari-web/test/controllers/main/alerts/manage_alert_notifications_controller_test.js
  4. 1 1
      ambari-web/test/controllers/main/service/info/config_test.js
  5. 1 1
      ambari-web/test/controllers/main/service/widgets/create/step2_controller_test.js
  6. 0 12
      ambari-web/test/controllers/main/service_test.js
  7. 0 18
      ambari-web/test/controllers/wizard/step3_test.js
  8. 1 1
      ambari-web/test/controllers/wizard/step7_test.js
  9. 6 1
      ambari-web/test/controllers/wizard/step9_test.js
  10. 4 4
      ambari-web/test/mappers/server_data_mapper_test.js
  11. 5 5
      ambari-web/test/mixins/common/configs/configs_saver_test.js
  12. 1 1
      ambari-web/test/mixins/main/host/details/host_components/install_component_test.js
  13. 1 2
      ambari-web/test/models/alerts/alert_instance_test.js
  14. 1 1
      ambari-web/test/utils/form_field_test.js
  15. 2 2
      ambari-web/test/views/common/configs/widgets/slider_config_widget_view_test.js
  16. 1 1
      ambari-web/test/views/common/table_view_test.js
  17. 4 2
      ambari-web/test/views/main/admin/stack_upgrade/services_view_test.js
  18. 2 2
      ambari-web/test/views/main/alert_definitions_view_test.js
  19. 10 8
      ambari-web/test/views/main/dashboard/widget_test.js
  20. 1 1
      ambari-web/test/views/main/dashboard/widgets/hawqsegment_live_test.js
  21. 1 1
      ambari-web/test/views/main/service/info/metrics/ambari_metrics/regionserver_base_test.js
  22. 2 2
      ambari-web/test/views/wizard/step5_view_test.js
  23. 23 8
      ambari-web/test/views/wizard/step9_view_test.js

+ 1 - 1
ambari-web/test/controllers/installer_test.js

@@ -36,7 +36,7 @@ describe('App.InstallerController', function () {
       c = App.InstallerController.create({});
     });
     it('all steps are disabled by default', function () {
-      expect(c.get('isStepDisabled.length') > 0 ).to.be.ok;
+      expect(c.get('isStepDisabled.length')).to.be.above(0);
       expect(c.get('isStepDisabled').everyProperty('value', true)).to.be.ok;
     });
   });

+ 2 - 2
ambari-web/test/controllers/main/admin/highAvailability/progress_popup_controller_test.js

@@ -46,11 +46,11 @@ describe('App.HighAvailabilityProgressPopupController', function () {
       });
 
       it('taskInfo.id = 2', function () {
-        expect(controller.get('taskInfo.id'), 2);
+        expect(controller.get('taskInfo.id')).to.be.equal(2);
       });
 
       it('taskInfo.requestId = 1', function () {
-        expect(controller.get('taskInfo.requestId'), 1);
+        expect(controller.get('taskInfo.requestId')).to.be.equal(1);
       });
 
       it('App.updater.run is called once', function () {

+ 2 - 6
ambari-web/test/controllers/main/alerts/manage_alert_notifications_controller_test.js

@@ -1020,23 +1020,19 @@ describe('App.ManageAlertNotificationsController', function () {
       describe('#errorHandler', function () {
 
         it('should fire invalid name', function () {
-
           view.set('controller.newCustomProperty.name', '!!');
           view.errorsHandler();
           expect(view.get('isError')).to.be.true;
           expect(view.get('parentView.disablePrimary')).to.be.true;
-          expect(view.get('errorMessage.length') > 0).to.be.true;
-
+          expect(view.get('errorMessage.length')).to.be.above(0);
         });
 
         it('should fire existing property name', function () {
-
           view.set('controller.newCustomProperty.name', 'n1');
           view.errorsHandler();
           expect(view.get('isError')).to.be.true;
           expect(view.get('parentView.disablePrimary')).to.be.true;
-          expect(view.get('errorMessage.length') > 0).to.be.true;
-
+          expect(view.get('errorMessage.length')).to.be.above(0);
         });
 
       });

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

@@ -478,7 +478,7 @@ describe("App.MainServiceInfoConfigsController", function () {
     });
     it("ajax request to put cluster cfg", function () {
       mainServiceInfoConfigsController.set('stepConfigs', sc);
-      expect(mainServiceInfoConfigsController.putChangedConfigurations([]));
+      mainServiceInfoConfigsController.putChangedConfigurations([]);
       var args = testHelpers.findAjaxRequest('name', 'common.across.services.configurations');
       expect(args[0]).exists;
     });

+ 1 - 1
ambari-web/test/controllers/main/service/widgets/create/step2_controller_test.js

@@ -731,7 +731,7 @@ describe('App.WidgetWizardStep2Controller', function () {
     });
     it("user is moved to the next step", function () {
       controller.next();
-      expect(App.router.send.calledWith('next'));
+      expect(App.router.send.calledWith('next')).to.be.true;
     });
   });
 });

+ 0 - 12
ambari-web/test/controllers/main/service_test.js

@@ -178,12 +178,6 @@ describe('App.MainServiceController', function () {
       expect(r).to.be.null;
     });
 
-    it('nothing disabled', function() {
-      var event = {target: {}}, query = 'query';
-      mainServiceController.startAllService(event).onPrimary(query);
-      expect(mainServiceController.allServicesCall.calledWith('STARTED', query));
-    });
-
   });
 
   describe('#stopAllService', function() {
@@ -208,12 +202,6 @@ describe('App.MainServiceController', function () {
       expect(r).to.be.null;
     });
 
-    it('nothing disabled', function() {
-      var event = {target: {}}, query = 'query';
-      mainServiceController.stopAllService(event).onPrimary(query);
-      expect(mainServiceController.allServicesCall.calledWith('STARTED', query));
-    });
-
   });
 
   describe('#startStopAllService', function() {

+ 0 - 18
ambari-web/test/controllers/wizard/step3_test.js

@@ -380,24 +380,6 @@ describe('App.WizardStep3Controller', function () {
 
   });
 
-  describe('#removeHost', function () {
-
-    beforeEach(function () {
-      sinon.stub(c, 'removeHosts', Em.K);
-    });
-
-    afterEach(function () {
-      c.removeHosts.restore();
-    });
-
-    it('should call removeHosts with array as arg', function () {
-      var host = {a: ''};
-      c.removeHost(host);
-      expect(c.removeHosts.calledWith([host]));
-    });
-
-  });
-
   describe('#removeSelectedHosts', function () {
 
     beforeEach(function () {

+ 1 - 1
ambari-web/test/controllers/wizard/step7_test.js

@@ -1733,7 +1733,7 @@ describe('App.InstallerStep7Controller', function () {
     it('should copy properties from hdfs-site to hdfs-client for HAWQ', function() {
       installerStep7Controller.addHawqConfigsOnNnHa(configs);
       // ensure 6 new configs were added
-      expect(configs.length - oldConfigs.length).to.be.equal(6);
+      expect(configs.length).to.be.equal(oldConfigs.length + 6);
     });
 
     describe('find the same property in hdfs-client for HAWQ and see if attribute value matches with the corresponding property\'s attribute value in hdfs-site', function () {

+ 6 - 1
ambari-web/test/controllers/wizard/step9_test.js

@@ -974,7 +974,12 @@ describe('App.InstallerStep9Controller', function () {
     tests.forEach(function (test) {
       it(test.m, function () {
         c.onInProgressPerHost(test.actions, test.host);
-        expect(test.host.message === test.e.message).to.equal(test.e.b);
+        if (test.e.b) {
+          expect(test.host.message).to.be.equal(test.e.message);
+        }
+        else {
+          expect(test.host.message).to.be.not.equal(test.e.message);
+        }
       });
     });
   });

+ 4 - 4
ambari-web/test/mappers/server_data_mapper_test.js

@@ -113,11 +113,11 @@ describe('App.QuickDataMapper', function () {
     });
 
     it('numeric array. element doesn\'t exists', function () {
-      expect(mapper.binaryIndexOf(array1, 0) < 0).to.be.true;
+      expect(mapper.binaryIndexOf(array1, 0)).to.be.below(0);
     });
 
     it('numeric array. element doesn\'t exists 2', function () {
-      expect(mapper.binaryIndexOf(array1, 10) < 0).to.be.true;
+      expect(mapper.binaryIndexOf(array1, 10)).to.be.below(0);
     });
 
     array2.forEach(function(item, index) {
@@ -127,11 +127,11 @@ describe('App.QuickDataMapper', function () {
     });
 
     it('string array. element doesn\'t exists', function () {
-      expect(mapper.binaryIndexOf(array2, 'a') < 0).to.be.true;
+      expect(mapper.binaryIndexOf(array2, 'a')).to.be.below(0);
     });
 
     it('string array. element doesn\'t exists 2', function () {
-      expect(mapper.binaryIndexOf(array2, 'q') < 0).to.be.true;
+      expect(mapper.binaryIndexOf(array2, 'q')).to.be.below(0);
     });
 
   });

+ 5 - 5
ambari-web/test/mixins/common/configs/configs_saver_test.js

@@ -59,14 +59,14 @@ describe('App.ConfigsSaverMixin', function() {
       currentServices: stackServices[2],
       res: false,
       m: 'not ok'
-    }].forEach(function (c) {
+    }].forEach(function (c, index) {
         describe(c.m, function () {
           beforeEach(function () {
             instanceObject.reopen({
               currentServices: c.currentServices
             });
-            it('', function () {
-              expect(instanceObject.allowSaveCoreSite()).to.equal(c.res);
+            it('test #' + index, function () {
+              expect(instanceObject.allowSaveCoreSite()).to.be.equal(c.res);
             });
           });
         });
@@ -79,7 +79,7 @@ describe('App.ConfigsSaverMixin', function() {
       { fName: 'core-site', res: true, allowSaveCoreSite: true, m: 'core site is allowed to be saved' },
       { fName: 'core-site', res: false, allowSaveCoreSite: false, m: 'core site is not allowed to be saved' },
       { fName: 'other-file-name', res: true, m: 'file name has not restriction rule, so can be saved' }
-    ].forEach(function (c) {
+    ].forEach(function (c, index) {
         describe(c.m, function () {
           beforeEach(function() {
             sinon.stub(instanceObject, 'allowSaveCoreSite').returns(c.allowSaveCoreSite);
@@ -87,7 +87,7 @@ describe('App.ConfigsSaverMixin', function() {
           afterEach(function() {
             instanceObject.allowSaveCoreSite.restore();
           });
-          it('', function () {
+          it('test #' + index, function () {
             expect(instanceObject.allowSaveSite(c.fName)).to.equal(c.res);
           });
         });

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

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

+ 1 - 2
ambari-web/test/models/alerts/alert_instance_test.js

@@ -51,8 +51,7 @@ describe('App.AlertInstance', function () {
         lastTriggeredFormatted: lastTriggeredFormatted
       });
       var status = model.get('statusChangedAndLastCheckedFormatted');
-      expect(status.indexOf(lastCheckedFormatted) > status.indexOf(lastTriggeredFormatted)).to.be.true;
-
+      expect(status.indexOf(lastCheckedFormatted)).to.be.above(status.indexOf(lastTriggeredFormatted));
     });
 
   });

+ 1 - 1
ambari-web/test/utils/form_field_test.js

@@ -34,7 +34,7 @@ describe('App.FormField', function () {
       formField.set('value', '');
       formField.set('isRequired', true);
       formField.validate();
-      expect(formField.get('errorMessage') === '').to.equal(false);
+      expect(formField.get('errorMessage')).to.be.not.equal('');
     });
     /*REQUIRE END*/
 

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

@@ -127,8 +127,8 @@ describe('App.SliderConfigWidgetView', function () {
 
   describe('#mirrorValue', function () {
     it('should be equal to config.value after init', function () {
-      expect('' + viewInt.get('mirrorValue')).to.equal(viewInt.get('config.value'));
-      expect('' + viewFloat.get('mirrorValue')).to.equal(viewFloat.get('config.value'));
+      expect(viewInt.get('mirrorValue').toString()).to.be.equal(viewInt.get('config.value'));
+      expect(viewFloat.get('mirrorValue').toString()).to.be.equal(viewFloat.get('config.value'));
     });
 
     it('should be converted according to widget format', function() {

+ 1 - 1
ambari-web/test/views/common/table_view_test.js

@@ -50,7 +50,7 @@ describe('App.TableView', function () {
 
     it('should set filterConditions on instance', function() {
       var tableView = App.TableView.create();
-      expect(tableView.get('filterConditions') === App.TableView.prototype.filterConditions).to.be.false;
+      expect(tableView.get('filterConditions')).to.be.not.equal(App.TableView.prototype.filterConditions);
     });
 
   });

+ 4 - 2
ambari-web/test/views/main/admin/stack_upgrade/services_view_test.js

@@ -73,14 +73,16 @@ describe('App.MainAdminStackServicesView', function () {
     it("routes to Add Service Wizard and set redirect path on wizard close", function() {
       isAccessibleMock.returns(true);
       view.goToAddService({context: "serviceName"});
-      expect(App.router.get.calledWith('addServiceController') && mock.setDBProperty.calledWith('onClosePath', 'main.admin.stackAndUpgrade.services')).to.be.true;
+      expect(App.router.get.calledWith('addServiceController')).to.be.true;
+      expect(mock.setDBProperty.calledWith('onClosePath', 'main.admin.stackAndUpgrade.services')).to.be.true;
       expect(App.get('router').transitionTo.calledWith('main.serviceAdd')).to.be.true;
       expect(mock.get('serviceToInstall')).to.be.equal("serviceName");
     });
     it("routes to Security Wizard", function() {
       isAccessibleMock.returns(true);
       view.goToAddService({context: "KERBEROS"});
-      expect(App.router.get.calledWith('kerberosWizardController') && mock.setDBProperty.calledWith('onClosePath', 'main.admin.stackAndUpgrade.services')).to.be.true;
+      expect(App.router.get.calledWith('kerberosWizardController')).to.be.true;
+      expect(mock.setDBProperty.calledWith('onClosePath', 'main.admin.stackAndUpgrade.services')).to.be.true;
       expect(mock.checkAndStartKerberosWizard.calledOnce).to.be.true;
     });
   });

+ 2 - 2
ambari-web/test/views/main/alert_definitions_view_test.js

@@ -51,8 +51,8 @@ describe('App.MainAlertDefinitionsView', function () {
     it('Add Ambari service to filters', function () {
       var serviceFilterClass = view.serviceFilterView;
       var content = serviceFilterClass.create({}).get('content');
-      expect(content[0].label === Em.I18n.t('common.all'));
-      expect(content[content.length - 1].label === Em.I18n.t('app.name'));
+      expect(content[0].label).to.be.equal(Em.I18n.t('common.all'));
+      expect(content[content.length - 1].label).to.be.equal(Em.I18n.t('app.name'));
     });
   });
 

+ 10 - 8
ambari-web/test/views/main/dashboard/widget_test.js

@@ -103,20 +103,22 @@ describe('App.DashboardWidgetView', function () {
       dashboardWidgetView.get('parentView').translateToReal.restore();
     });
     it("postUserPref is called with correct data", function () {
-      expect(dashboardWidgetView.get('parentView').postUserPref.calledWith('key', {
+      var arg = JSON.parse(JSON.stringify(dashboardWidgetView.get('parentView').postUserPref.args[0][1]));
+      expect(arg).to.be.eql({
         dashboardVersion: 'new',
-        visible: ['2'],
-        hidden: ['1'],
+        visible: ['1', '2'],
+        hidden: [[5, null]],
         threshold: 'threshold'
-      }));
+      });
     });
     it("translateToReal is called with valid data", function () {
-      expect(dashboardWidgetView.get('parentView').translateToReal.calledWith({
+      var arg = JSON.parse(JSON.stringify(dashboardWidgetView.get('parentView').translateToReal.args[0][0]));
+      expect(arg).to.be.eql({
         dashboardVersion: 'new',
-        visible: ['2'],
-        hidden: ['1'],
+        visible: ['1', '2'],
+        hidden: [[5, null]],
         threshold: 'threshold'
-      }));
+      });
     });
   });
 

+ 1 - 1
ambari-web/test/views/main/dashboard/widgets/hawqsegment_live_test.js

@@ -52,7 +52,7 @@ describe('App.HawqSegmentUpView', function() {
   ];
 
   tests.forEach(function(test) {
-    describe('', function() {
+    describe('data -' + test.data, function() {
       var hawqSegmentUpView = App.HawqSegmentUpView.create({model_type:null, data: test.data, content: test.data.toString()});
       it('shows red', function() {
         expect(hawqSegmentUpView.get('isRed')).to.equal(test.e.isRed);

+ 1 - 1
ambari-web/test/views/main/service/info/metrics/ambari_metrics/regionserver_base_test.js

@@ -50,7 +50,7 @@ describe('App.ChartServiceMetricsAMS_RegionServerBaseView', function () {
     });
 
     it('displayName', function () {
-      expect(this.result[0].name === regionServerView.displayName).to.be.true;
+      expect(this.result[0].name).to.be.equal(regionServerView.displayName);
     });
 
     it('data.length', function () {

+ 2 - 2
ambari-web/test/views/wizard/step5_view_test.js

@@ -191,7 +191,7 @@ describe('App.SelectHostView', function() {
 
     it('should call assignHostToMaster', function() {
       view.changeHandler();
-      expect(view.get('controller').assignHostToMaster.calledWith('ZOOKEEPER_SERVER', 'h1', 1));
+      expect(view.get('controller').assignHostToMaster.args[0]).to.be.eql(['ZOOKEEPER_SERVER', 'h1 info', 1]);
     });
 
     it('should increment rebalanceComponentHostsCounter if component it is multiple', function() {
@@ -271,7 +271,7 @@ describe('App.InputHostView', function() {
 
     it('should call assignHostToMaster', function() {
       view.changeHandler();
-      expect(view.get('controller').assignHostToMaster.calledWith('ZOOKEEPER_SERVER', 'h1', 1));
+      expect(view.get('controller').assignHostToMaster.args[0]).to.be.eql(['ZOOKEEPER_SERVER', 'h1', 1]);
     });
 
     it('should increment rebalanceComponentHostsCounter if component it is multiple', function() {

+ 23 - 8
ambari-web/test/views/wizard/step9_view_test.js

@@ -701,14 +701,29 @@ describe('App.HostStatusView', function () {
           e: false
         }
       ]).forEach(function (test) {
-        it(JSON.stringify(test.obj) + ' ' + test.progress, function() {
-          hv.set('barColor', '');
-          hv.set('obj', test.obj);
-          hv.set('obj.message', '');
-          hv.set('controller', {progress: test.progress});
-          hv.onStatus();
-          expect(hv.get('obj.message') === Em.I18n.t('installer.step9.host.status.success')).to.equal(test.e);
-          expect(hv.get('barColor') === 'progress-success').to.equal(test.e);
+        describe(JSON.stringify(test.obj) + ' ' + test.progress, function() {
+          beforeEach(function () {
+            hv.setProperties({
+              barColor: '',
+              obj: test.obj
+            });
+            hv.set('obj.message', '');
+            hv.set('controller', {progress: test.progress});
+            hv.onStatus();
+          });
+
+          if (test.e) {
+            it('completed successful', function () {
+              expect(hv.get('obj.message')).to.be.equal(Em.I18n.t('installer.step9.host.status.success'));
+              expect(hv.get('barColor')).to.be.equal('progress-success');
+            });
+          }
+          else {
+            it('completed not successful', function () {
+              expect(hv.get('obj.message')).to.be.not.equal(Em.I18n.t('installer.step9.host.status.success'));
+              expect(hv.get('barColor')).to.be.not.equal('progress-success');
+            });
+          }
         });
       });
   });