AMBARI-14297. Apply common tests for Em.computed macros (onechiporenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/43306594 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/43306594 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/43306594 Branch: refs/heads/trunk Commit: 43306594eae138b6b8e2bf6acfe1866c20cf67ae Parents: 240a27a Author: Oleg Nechiporenko <onechipore...@apache.org> Authored: Wed Dec 9 17:50:51 2015 +0200 Committer: Oleg Nechiporenko <onechipore...@apache.org> Committed: Thu Dec 10 15:45:37 2015 +0200 ---------------------------------------------------------------------- .../global/cluster_controller_test.js | 2 + .../global/update_controller_test.js | 2 + .../admin/kerberos/step2_controller_test.js | 13 +- .../admin/kerberos/step4_controller_test.js | 10 +- .../controllers/main/admin/kerberos_test.js | 4 + .../definitions_details_controller_test.js | 16 +- .../manage_alert_groups_controller_test.js | 9 +- .../controllers/main/charts/heatmap_test.js | 8 + .../test/controllers/main/host/details_test.js | 25 ++- .../main/host/host_alerts_controller_test.js | 9 +- .../main/service/info/config_test.js | 25 ++- .../test/controllers/main/service/item_test.js | 2 - .../widgets/create/step2_controller_test.js | 13 +- .../widgets/create/step3_controller_test.js | 30 +-- .../test/controllers/main/service_test.js | 47 +---- ambari-web/test/controllers/main_test.js | 24 +-- .../test/controllers/wizard/step10_test.js | 11 +- .../test/controllers/wizard/step2_test.js | 82 ++------ .../test/controllers/wizard/step3_test.js | 63 ++---- .../test/controllers/wizard/step6_test.js | 76 +++---- .../test/controllers/wizard/step7_test.js | 46 ++--- .../test/controllers/wizard/step8_test.js | 96 +++++---- .../test/controllers/wizard/step9_test.js | 50 +++-- ambari-web/test/models/authentication_test.js | 4 + ambari-web/test/models/cluster_states_test.js | 13 +- .../objects/service_config_category_test.js | 22 +-- .../objects/service_config_property_test.js | 8 +- ambari-web/test/models/configs/section_test.js | 56 +----- ambari-web/test/models/host_component_test.js | 63 +----- ambari-web/test/models/host_test.js | 10 + ambari-web/test/models/repository_test.js | 12 +- ambari-web/test/models/stack_service_test.js | 13 +- ambari-web/test/models/upgrade_entity_test.js | 8 +- ambari-web/test/models/user_test.js | 30 ++- .../common/configs/config_history_flow_test.js | 14 ++ .../notification_configs_view_test.js | 32 +-- .../service_configs_by_category_view_test.js | 3 + .../form/manage_kdc_credentials_form_test.js | 16 +- ambari-web/test/views/common/table_view_test.js | 8 + .../nameNode/step4_view_test.js | 14 +- .../stack_upgrade/upgrade_wizard_view_test.js | 14 +- .../views/main/alert_definitions_view_test.js | 8 +- .../alerts/manage_alert_groups_view_test.js | 14 +- .../widgets/hbase_average_load_test.js | 10 + .../widgets/hbase_regions_in_transition_test.js | 10 + .../main/dashboard/widgets/namenode_rpc_test.js | 8 + .../main/dashboard/widgets/text_widget_test.js | 8 + .../host/details/host_component_view_test.js | 197 +++---------------- ambari-web/test/views/main/host_test.js | 12 +- .../views/main/service/info/summary_test.js | 9 + ambari-web/test/views/main/service/item_test.js | 15 ++ ambari-web/test/views/wizard/step1_view_test.js | 41 +--- ambari-web/test/views/wizard/step2_view_test.js | 15 +- .../wizard/step3/hostLogPopupBody_view_test.js | 24 +-- .../step3/hostWarningPopupBody_view_test.js | 24 ++- ambari-web/test/views/wizard/step6_view_test.js | 21 +- .../wizard/step9/hostLogPopupBody_view_test.js | 25 ++- 57 files changed, 569 insertions(+), 875 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/controllers/global/cluster_controller_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/global/cluster_controller_test.js b/ambari-web/test/controllers/global/cluster_controller_test.js index 1cc5267..2b01ea0 100644 --- a/ambari-web/test/controllers/global/cluster_controller_test.js +++ b/ambari-web/test/controllers/global/cluster_controller_test.js @@ -35,6 +35,8 @@ describe('App.clusterController', function () { {service_name: 'GANGLIA'} ]; + App.TestAliases.testAsComputedAlias(controller, 'clusterName', 'App.clusterName', 'string'); + describe('#updateLoadStatus()', function () { controller.set('dataLoadList', Em.Object.create({ http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/controllers/global/update_controller_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/global/update_controller_test.js b/ambari-web/test/controllers/global/update_controller_test.js index 8e68b21..fc29aa0 100644 --- a/ambari-web/test/controllers/global/update_controller_test.js +++ b/ambari-web/test/controllers/global/update_controller_test.js @@ -28,6 +28,8 @@ describe('App.UpdateController', function () { updateServiceMetric: function(){} }); + App.TestAliases.testAsComputedAlias(App.UpdateController.create(), 'clusterName', 'App.router.clusterController.clusterName', 'string'); + describe('#getUrl()', function () { it('testMode = true', function () { http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/controllers/main/admin/kerberos/step2_controller_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/admin/kerberos/step2_controller_test.js b/ambari-web/test/controllers/main/admin/kerberos/step2_controller_test.js index 9a06024..c87c86c 100644 --- a/ambari-web/test/controllers/main/admin/kerberos/step2_controller_test.js +++ b/ambari-web/test/controllers/main/admin/kerberos/step2_controller_test.js @@ -19,14 +19,24 @@ var App = require('app'); var setups = require('test/init_model_test'); +function getController() { + return App.KerberosWizardStep2Controller.create({}); +} + describe('App.KerberosWizardStep2Controller', function() { + App.TestAliases.testAsComputedAlias(getController(), 'isBackBtnDisabled', 'testConnectionInProgress', 'boolean'); + + App.TestAliases.testAsComputedAlias(getController(), 'hostNames', 'App.allHostNames'); + + App.TestAliases.testAsComputedAlias(getController(), 'isConfigsLoaded', 'wizardController.stackConfigsLoaded', 'boolean'); + describe('#createKerberosSiteObj', function() { var controller; beforeEach(function() { setups.setupStackVersion(this, 'HDP-2.3'); - controller = App.KerberosWizardStep2Controller.create({}); + controller = getController(); sinon.stub(controller, 'tweakKdcTypeValue', Em.K); sinon.stub(controller, 'tweakManualKdcProperties', Em.K); }); @@ -84,4 +94,5 @@ describe('App.KerberosWizardStep2Controller', function() { }); }); }); + }); http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/controllers/main/admin/kerberos/step4_controller_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/admin/kerberos/step4_controller_test.js b/ambari-web/test/controllers/main/admin/kerberos/step4_controller_test.js index 18858cf..7b2f877 100644 --- a/ambari-web/test/controllers/main/admin/kerberos/step4_controller_test.js +++ b/ambari-web/test/controllers/main/admin/kerberos/step4_controller_test.js @@ -17,9 +17,15 @@ */ var App = require('app'); - +var c = App.KerberosWizardStep4Controller.create({ + wizardController: Em.Object.create({ + name: '' + }) +}); describe('App.KerberosWizardStep4Controller', function() { - + + App.TestAliases.testAsComputedEqual(c, 'isWithinAddService', 'wizardController.name', 'addServiceController'); + describe('#isSubmitDisabled', function() { var controller = App.KerberosWizardStep4Controller.create({}); var configs = Em.A([ http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/controllers/main/admin/kerberos_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/admin/kerberos_test.js b/ambari-web/test/controllers/main/admin/kerberos_test.js index 6eb2bab..8130941 100644 --- a/ambari-web/test/controllers/main/admin/kerberos_test.js +++ b/ambari-web/test/controllers/main/admin/kerberos_test.js @@ -22,6 +22,10 @@ describe('App.MainAdminKerberosController', function() { var controller = App.MainAdminKerberosController.create({}); + App.TestAliases.testAsComputedEqual(controller, 'isManualKerberos', 'kdc_type', 'none'); + + App.TestAliases.testAsComputedSomeBy(controller, 'isPropertiesChanged', 'stepConfigs', 'isPropertiesChanged', true); + describe('#prepareConfigProperties', function() { beforeEach(function() { sinon.stub(App.Service, 'find').returns([ http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/controllers/main/alerts/definitions_details_controller_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/alerts/definitions_details_controller_test.js b/ambari-web/test/controllers/main/alerts/definitions_details_controller_test.js index dea1f2a..7b56068 100644 --- a/ambari-web/test/controllers/main/alerts/definitions_details_controller_test.js +++ b/ambari-web/test/controllers/main/alerts/definitions_details_controller_test.js @@ -20,16 +20,22 @@ var App = require('app'); var controller; +function getController() { + return App.MainAlertDefinitionDetailsController.create({ + content: Em.Object.create({ + label: 'label' + }) + }); +} + describe('App.MainAlertDefinitionDetailsController', function () { beforeEach(function () { - controller = App.MainAlertDefinitionDetailsController.create({ - content: Em.Object.create({ - label: 'label' - }) - }); + controller = getController(); }); + App.TestAliases.testAsComputedMapBy(getController(), 'groupsList', 'content.groups', 'displayName'); + describe('#labelValidation()', function () { it('should set editing.label.isError to true', function () { http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/controllers/main/alerts/manage_alert_groups_controller_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/alerts/manage_alert_groups_controller_test.js b/ambari-web/test/controllers/main/alerts/manage_alert_groups_controller_test.js index dc1fc1f..db0f50a 100644 --- a/ambari-web/test/controllers/main/alerts/manage_alert_groups_controller_test.js +++ b/ambari-web/test/controllers/main/alerts/manage_alert_groups_controller_test.js @@ -19,12 +19,19 @@ var App = require('app'); var manageAlertGroupsController; + +function getController() { + return App.ManageAlertGroupsController.create({}); +} + describe('App.ManageAlertGroupsController', function () { beforeEach(function () { - manageAlertGroupsController = App.ManageAlertGroupsController.create({}); + manageAlertGroupsController = getController(); }); + App.TestAliases.testAsComputedFilterBy(getController(), 'alertGlobalNotifications', 'alertNotifications', 'global', true); + describe('#addAlertGroup', function () { beforeEach(function () { http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/controllers/main/charts/heatmap_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/charts/heatmap_test.js b/ambari-web/test/controllers/main/charts/heatmap_test.js index 56c672c..dbdf8c3 100644 --- a/ambari-web/test/controllers/main/charts/heatmap_test.js +++ b/ambari-web/test/controllers/main/charts/heatmap_test.js @@ -21,8 +21,16 @@ var App = require('app'); require('models/rack'); require('controllers/main/charts/heatmap'); +function getController() { + return App.MainChartsHeatmapController.create(); +} + describe('MainChartsHeatmapController', function () { + App.TestAliases.testAsComputedAlias(getController(), 'activeWidget', 'widgets.firstObject', 'object'); + + App.TestAliases.testAsComputedAlias(getController(), 'hostToSlotMap', 'selectedMetric.hostToSlotMap', 'object'); + describe('#validation()', function () { var controller = App.MainChartsHeatmapController.create({ allMetrics: [], http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/controllers/main/host/details_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/host/details_test.js b/ambari-web/test/controllers/main/host/details_test.js index 4608516..1ed9d47 100644 --- a/ambari-web/test/controllers/main/host/details_test.js +++ b/ambari-web/test/controllers/main/host/details_test.js @@ -26,24 +26,30 @@ var batchUtils = require('utils/batch_scheduled_requests'); var hostsManagement = require('utils/hosts'); var controller; -describe('App.MainHostDetailsController', function () { +function getController() { + return App.MainHostDetailsController.create(App.InstallComponent, { + content: Em.Object.create({ + hostComponents: [] + }) + }); +} +describe('App.MainHostDetailsController', function () { beforeEach(function () { sinon.stub(App.ajax, 'send').returns({ then: Em.K, complete: Em.K }); - controller = App.MainHostDetailsController.create(App.InstallComponent, { - content: Em.Object.create({ - hostComponents: [] - }) - }); + controller = getController(); }); + afterEach(function () { App.ajax.send.restore(); }); + App.TestAliases.testAsComputedFilterBy(getController(), 'serviceNonClientActiveComponents', 'serviceActiveComponents', 'isClient', false); + describe('#routeHome()', function () { it('transiotion to dashboard', function () { sinon.stub(App.router, 'transitionTo', Em.K); @@ -74,7 +80,7 @@ describe('App.MainHostDetailsController', function () { }); }); -describe('#stopComponent()', function () { + describe('#stopComponent()', function () { beforeEach(function () { sinon.stub(App, 'showConfirmationPopup', function (callback) { @@ -295,7 +301,6 @@ describe('#stopComponent()', function () { }); }); - describe('#serviceActiveComponents', function () { it('No host-components', function () { @@ -2105,7 +2110,6 @@ describe('#stopComponent()', function () { }); }); - describe('#setRackId', function () { beforeEach(function () { sinon.stub(hostsManagement, 'setRackInfo', Em.K); @@ -2312,6 +2316,7 @@ describe('#stopComponent()', function () { }))).to.equal(0); }); }); + describe('#downloadClientConfigsCall', function () { beforeEach(function () { @@ -2929,7 +2934,6 @@ describe('#stopComponent()', function () { }); }); - describe("#installVersion()", function () { it("call App.ajax.send", function () { controller.set('content.hostName', 'host1'); @@ -3398,4 +3402,5 @@ describe('#stopComponent()', function () { expect(controller.checkComponentDependencies('C1', opt)).to.eql(['C3']); }); }); + }); http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/controllers/main/host/host_alerts_controller_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/host/host_alerts_controller_test.js b/ambari-web/test/controllers/main/host/host_alerts_controller_test.js index ac75090..2cfdac5 100644 --- a/ambari-web/test/controllers/main/host/host_alerts_controller_test.js +++ b/ambari-web/test/controllers/main/host/host_alerts_controller_test.js @@ -22,12 +22,18 @@ require('controllers/main/host/host_alerts_controller'); var controller; +function getController() { + return App.MainHostAlertsController.create(); +} + describe('App.MainHostAlertsController', function () { beforeEach(function() { - controller = App.MainHostAlertsController.create(); + controller = getController(); }); + App.TestAliases.testAsComputedAlias(getController(), 'selectedHost', 'App.router.mainHostDetailsController.content', 'object'); + describe("#routeToAlertDefinition()", function () { beforeEach(function () { @@ -45,4 +51,5 @@ describe('App.MainHostAlertsController', function () { expect(App.router.transitionTo.calledWith('main.alerts.alertDetails', 'alertDefinition')).to.be.true; }); }); + }); http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/controllers/main/service/info/config_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/service/info/config_test.js b/ambari-web/test/controllers/main/service/info/config_test.js index b324b12..aec369f 100644 --- a/ambari-web/test/controllers/main/service/info/config_test.js +++ b/ambari-web/test/controllers/main/service/info/config_test.js @@ -20,21 +20,28 @@ var App = require('app'); require('controllers/main/service/info/configs'); var batchUtils = require('utils/batch_scheduled_requests'); var mainServiceInfoConfigsController = null; + +function getController() { + return App.MainServiceInfoConfigsController.create({ + dependentServiceNames: [], + loadDependentConfigs: function () { + return {done: Em.K} + }, + loadConfigTheme: function () { + return $.Deferred().resolve().promise(); + } + }); +} + describe("App.MainServiceInfoConfigsController", function () { beforeEach(function () { sinon.stub(App.themesMapper, 'generateAdvancedTabs').returns(Em.K); - mainServiceInfoConfigsController = App.MainServiceInfoConfigsController.create({ - dependentServiceNames: [], - loadDependentConfigs: function () { - return {done: Em.K} - }, - loadConfigTheme: function () { - return $.Deferred().resolve().promise(); - } - }); + mainServiceInfoConfigsController = getController(); }); + App.TestAliases.testAsComputedAlias(getController(), 'serviceConfigs', 'App.config.preDefinedServiceConfigs', 'array'); + afterEach(function() { App.themesMapper.generateAdvancedTabs.restore(); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/controllers/main/service/item_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/service/item_test.js b/ambari-web/test/controllers/main/service/item_test.js index b3151dd..4934d21 100644 --- a/ambari-web/test/controllers/main/service/item_test.js +++ b/ambari-web/test/controllers/main/service/item_test.js @@ -318,7 +318,6 @@ describe('App.MainServiceItemController', function () { }); }); - describe("#turnOnOffPassive", function () { var mainServiceItemController = App.MainServiceItemController.create({turnOnOffPassiveRequest: Em.K}); beforeEach(function () { @@ -1058,7 +1057,6 @@ describe('App.MainServiceItemController', function () { }); }); - describe('#downloadClientConfigs()', function () { var mainServiceItemController = App.MainServiceItemController.create({ http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/controllers/main/service/widgets/create/step2_controller_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/service/widgets/create/step2_controller_test.js b/ambari-web/test/controllers/main/service/widgets/create/step2_controller_test.js index fc9f66d..9d3efde 100644 --- a/ambari-web/test/controllers/main/service/widgets/create/step2_controller_test.js +++ b/ambari-web/test/controllers/main/service/widgets/create/step2_controller_test.js @@ -26,18 +26,7 @@ describe('App.WidgetWizardStep2Controller', function () { content: Em.Object.create() }); - describe("#isEditWidget", function () { - it("empty name", function () { - controller.set('content.controllerName', ''); - controller.propertyDidChange('isEditWidget'); - expect(controller.get('isEditWidget')).to.be.false; - }); - it("correct name", function () { - controller.set('content.controllerName', 'widgetEditController'); - controller.propertyDidChange('isEditWidget'); - expect(controller.get('isEditWidget')).to.be.true; - }); - }); + App.TestAliases.testAsComputedEqual(controller, 'isEditWidget', 'content.controllerName', 'widgetEditController'); describe("#filteredMetrics", function () { var testCases = [ http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/controllers/main/service/widgets/create/step3_controller_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/service/widgets/create/step3_controller_test.js b/ambari-web/test/controllers/main/service/widgets/create/step3_controller_test.js index c603b48..b6f46f3 100644 --- a/ambari-web/test/controllers/main/service/widgets/create/step3_controller_test.js +++ b/ambari-web/test/controllers/main/service/widgets/create/step3_controller_test.js @@ -26,31 +26,13 @@ describe('App.WidgetWizardStep3Controller', function () { content: Em.Object.create() }); - describe("#isEditController", function () { - it("empty name", function () { - controller.set('content.controllerName', ''); - controller.propertyDidChange('isEditController'); - expect(controller.get('isEditController')).to.be.false; - }); - it("widgetEditController name", function () { - controller.set('content.controllerName', 'widgetEditController'); - controller.propertyDidChange('isEditController'); - expect(controller.get('isEditController')).to.be.true; - }); - }); + App.TestAliases.testAsComputedEqual(controller, 'isEditController', 'content.controllerName', 'widgetEditController'); - describe("#widgetScope", function () { - it("isSharedChecked - false", function () { - controller.set('isSharedChecked', false); - controller.propertyDidChange('widgetScope'); - expect(controller.get('widgetScope')).to.equal('User'); - }); - it("isSharedChecked - true", function () { - controller.set('isSharedChecked', true); - controller.propertyDidChange('widgetScope'); - expect(controller.get('widgetScope')).to.equal('Cluster'); - }); - }); + App.TestAliases.testAsComputedIfThenElse(controller, 'widgetScope', 'isSharedChecked', 'Cluster', 'User'); + + App.TestAliases.testAsComputedGte(controller, 'isNameInvalid', 'widgetName.length', 129); + + App.TestAliases.testAsComputedGte(controller, 'isDescriptionInvalid', 'widgetDescription.length', 2049); describe("#isSubmitDisabled", function () { it("widgetName - null", function () { http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/controllers/main/service_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/service_test.js b/ambari-web/test/controllers/main/service_test.js index cad39f9..c134419 100644 --- a/ambari-web/test/controllers/main/service_test.js +++ b/ambari-web/test/controllers/main/service_test.js @@ -21,6 +21,10 @@ require('controllers/main/service'); var mainServiceController; +function getController() { + return App.MainServiceController.create({}); +} + describe('App.MainServiceController', function () { var tests = Em.A([ @@ -74,11 +78,12 @@ describe('App.MainServiceController', function () { } ]); - beforeEach(function() { - mainServiceController = App.MainServiceController.create(); + mainServiceController = getController(); }); + App.TestAliases.testAsComputedNotEqual(getController(), 'isStartStopAllClicked', 'App.router.backgroundOperationsController.allOperationsCount', 0); + describe('#isStartAllDisabled', function () { tests.forEach(function (test) { it(test.mStart, function () { @@ -103,22 +108,6 @@ describe('App.MainServiceController', function () { }); }); - describe('#isStartStopAllClicked', function () { - - beforeEach(function () { - sinon.stub(App, 'get').withArgs('router.backgroundOperationsController.allOperationsCount').returns(1); - }); - - afterEach(function () { - App.get.restore(); - }); - - it('should be based on BG ops count', function () { - expect(mainServiceController.get('isStartStopAllClicked')).to.be.true; - }); - - }); - describe('#cluster', function() { var tests = Em.A([ @@ -326,27 +315,7 @@ describe('App.MainServiceController', function () { }); - describe('#isRestartAllRequiredDisabled', function () { - - it('should be false if there is at least one service with isRestartRequired=true', function () { - mainServiceController.reopen({ - content: [ - {isRestartRequired: false}, {isRestartRequired: false}, {isRestartRequired: true} - ] - }); - expect(mainServiceController.get('isRestartAllRequiredDisabled')).to.be.false; - }); - - it('should be true if there is no services with isRestartRequired=true', function () { - mainServiceController.reopen({ - content: [ - {isRestartRequired: false}, {isRestartRequired: false}, {isRestartRequired: false} - ] - }); - expect(mainServiceController.get('isRestartAllRequiredDisabled')).to.be.true; - }); - - }); + App.TestAliases.testAsComputedEveryBy(getController(), 'isRestartAllRequiredDisabled', 'content', 'isRestartRequired', false); describe('#restartAllRequired', function () { http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/controllers/main_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main_test.js b/ambari-web/test/controllers/main_test.js index 867fc4b..f9f092a 100644 --- a/ambari-web/test/controllers/main_test.js +++ b/ambari-web/test/controllers/main_test.js @@ -56,29 +56,9 @@ describe('App.MainController', function () { }); }); - describe('#isClusterDataLoaded', function() { - beforeEach(function () { - sinon.stub(App.router, 'get').returns(true); - }); - afterEach(function () { - App.router.get.restore(); - }); - it ('Should return true', function() { - expect(mainController.get('isClusterDataLoaded')).to.be.true; - }); - }); + App.TestAliases.testAsComputedAlias(mainController, 'isClusterDataLoaded', 'App.router.clusterController.isLoaded', 'boolean'); - describe('#clusterDataLoadedPercent', function() { - beforeEach(function () { - sinon.stub(App, 'get').withArgs('router.clusterController.clusterDataLoadedPercent').returns(16); - }); - afterEach(function () { - App.get.restore(); - }); - it ('Should return 16', function() { - expect(mainController.get('clusterDataLoadedPercent')).to.be.equal(16); - }); - }); + App.TestAliases.testAsComputedAlias(mainController, 'clusterDataLoadedPercent', 'App.router.clusterController.clusterDataLoadedPercent', 'string'); describe('#initialize', function() { var initialize = false; http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/controllers/wizard/step10_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/wizard/step10_test.js b/ambari-web/test/controllers/wizard/step10_test.js index 0c2bbef..8238e89 100644 --- a/ambari-web/test/controllers/wizard/step10_test.js +++ b/ambari-web/test/controllers/wizard/step10_test.js @@ -23,17 +23,24 @@ require('controllers/wizard/step10_controller'); var controller; +function getController() { + return App.WizardStep10Controller.create({ + content: {cluster: {controllerName: '', status: 'INSTALL COMPLETE'}} + }); +} + describe('App.WizardStep10Controller', function () { beforeEach(function() { - controller = App.WizardStep10Controller.create(); - controller.set('content', {cluster: {status: 'INSTALL COMPLETE'}}); + controller = getController(); }); afterEach(function() { controller.clearStep(); }); + App.TestAliases.testAsComputedEqual(getController(), 'isAddServiceWizard', 'content.controllerName', 'addServiceController'); + describe('#clearStep', function() { it('should clear clusterInfo', function() { controller.get('clusterInfo').pushObject({}); http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/controllers/wizard/step2_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/wizard/step2_test.js b/ambari-web/test/controllers/wizard/step2_test.js index b137669..9afad41 100644 --- a/ambari-web/test/controllers/wizard/step2_test.js +++ b/ambari-web/test/controllers/wizard/step2_test.js @@ -23,6 +23,11 @@ require('models/host'); require('models/host_component'); require('messages'); var c; + +function getController() { + return App.WizardStep2Controller.create({content: {controllerName: ''}}); +} + describe('App.WizardStep2Controller', function () { var userErrorTests = Em.A([ @@ -54,28 +59,20 @@ describe('App.WizardStep2Controller', function () { beforeEach(function() { - c = App.WizardStep2Controller.create(); + c = getController(); }); - describe('#isInstaller', function() { - it('true if controllerName is installerController', function() { - var controller = App.WizardStep2Controller.create({content: {controllerName: 'installerController'}}); - expect(controller.get('isInstaller')).to.equal(true); - }); - it('false if controllerName isn\'t installerController', function() { - var controller = App.WizardStep2Controller.create({content: {controllerName: 'addServiceController'}}); - expect(controller.get('isInstaller')).to.equal(false); - }); - }); + App.TestAliases.testAsComputedEqual(getController(), 'isInstaller', 'content.controllerName', 'installerController'); - describe('#manualInstall', function() { - it('should be equal to content.installOptions.manualInstall', function() { - var controller = App.WizardStep2Controller.create({content: {installOptions: {manualInstall: true}}}); - expect(controller.get('manualInstall')).to.equal(true); - controller.toggleProperty('content.installOptions.manualInstall'); - expect(controller.get('manualInstall')).to.equal(false); - }); - }); + App.TestAliases.testAsComputedAlias(getController(), 'manualInstall', 'content.installOptions.manualInstall', 'boolean'); + + App.TestAliases.testAsComputedAlias(getController(), 'sshKey', 'content.installOptions.sshKey', 'string'); + + App.TestAliases.testAsComputedAlias(getController(), 'sshUser', 'content.installOptions.sshUser', 'string'); + + App.TestAliases.testAsComputedAlias(getController(), 'sshPort', 'content.installOptions.sshPort', 'string'); + + App.TestAliases.testAsComputedAlias(getController(), 'agentUser', 'content.installOptions.agentUser', 'string'); describe('#hostNames', function() { it('should be equal to content.installOptions.hostNames', function() { @@ -86,52 +83,7 @@ describe('App.WizardStep2Controller', function () { }); }); - describe('#sshKey', function() { - it('should be equal to content.installOptions.sshKey', function() { - var controller = App.WizardStep2Controller.create({content: {installOptions: {sshKey: '123'}}}); - expect(controller.get('sshKey')).to.equal('123'); - controller.set('content.installOptions.sshKey', '321'); - expect(controller.get('sshKey')).to.equal('321'); - }); - }); - - describe('#sshUser', function() { - it('should be equal to content.installOptions.sshUser', function() { - var controller = App.WizardStep2Controller.create({content: {installOptions: {sshUser: '123'}}}); - expect(controller.get('sshUser')).to.equal('123'); - controller.set('content.installOptions.sshUser', '321'); - expect(controller.get('sshUser')).to.equal('321'); - }); - }); - - describe('#sshPort', function() { - it('should be equal to content.installOptions.sshPort', function() { - var controller = App.WizardStep2Controller.create({content: {installOptions: {sshPort: '123'}}}); - expect(controller.get('sshPort')).to.equal('123'); - controller.set('content.installOptions.sshPort', '321'); - expect(controller.get('sshPort')).to.equal('321'); - }); - }); - - describe('#agentUser', function() { - it('should be equal to content.installOptions.agentUser', function() { - var controller = App.WizardStep2Controller.create({content: {installOptions: {agentUser: '123'}}}); - expect(controller.get('agentUser')).to.equal('123'); - controller.set('content.installOptions.agentUser', '321'); - expect(controller.get('agentUser')).to.equal('321'); - }); - }); - - describe('#installType', function() { - it('should be manualDriven if manualInstall is selected', function() { - var controller = App.WizardStep2Controller.create({content: {installOptions: {manualInstall: true}}}); - expect(controller.get('installType')).to.equal('manualDriven'); - }); - it('should be ambariDriven if manualInstall isn\'t selected', function() { - var controller = App.WizardStep2Controller.create({content: {installOptions: {manualInstall: false}}}); - expect(controller.get('installType')).to.equal('ambariDriven'); - }); - }); + App.TestAliases.testAsComputedIfThenElse(getController(), 'installType', 'manualInstall', 'manualDriven', 'ambariDriven'); describe('#updateHostNameArr()', function () { http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/controllers/wizard/step3_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/wizard/step3_test.js b/ambari-web/test/controllers/wizard/step3_test.js index f48514c..a699dcc 100644 --- a/ambari-web/test/controllers/wizard/step3_test.js +++ b/ambari-web/test/controllers/wizard/step3_test.js @@ -25,16 +25,20 @@ require('utils/http_client'); require('models/host'); require('controllers/wizard/step3_controller'); +function getController() { + return App.WizardStep3Controller.create({ + content: Em.Object.create({installedHosts: Em.A([]), installOptions: {}, controllerName: ''}), + wizardController: App.InstallerController.create(), + setRegistrationInProgressOnce: Em.K, + disablePreviousSteps: Em.K + }); +} + describe('App.WizardStep3Controller', function () { beforeEach(function () { - c = App.WizardStep3Controller.create({ - content: Em.Object.create({installedHosts: Em.A([]), installOptions: {}}), - wizardController: App.InstallerController.create(), - setRegistrationInProgressOnce: Em.K, - disablePreviousSteps: Em.K - }); + c = getController(); sinon.stub(App.db, 'getDisplayLength', Em.K); sinon.stub(App.db, 'getFilterConditions').returns([]); @@ -47,6 +51,12 @@ describe('App.WizardStep3Controller', function () { App.db.getFilterConditions.restore(); }); + App.TestAliases.testAsComputedGt(getController(), 'isHostHaveWarnings', 'warnings.length', 0); + + App.TestAliases.testAsComputedEqual(getController(), 'isAddHostWizard', 'content.controllerName', 'addHostController'); + + App.TestAliases.testAsComputedIfThenElse(getController(), 'registrationTimeoutSecs', 'content.installOptions.manualInstall', 15, 120); + describe('#getAllRegisteredHostsCallback', function () { it('One host is already in the cluster, one host is registered', function () { @@ -137,47 +147,6 @@ describe('App.WizardStep3Controller', function () { }); - describe('#registrationTimeoutSecs', function () { - - it('Manual install', function () { - c.set('content.installOptions.manualInstall', true); - expect(c.get('registrationTimeoutSecs')).to.equal(15); - }); - - it('Not manual install', function () { - c.set('content.installOptions.manualInstall', false); - expect(c.get('registrationTimeoutSecs')).to.equal(120); - }); - - }); - - describe('#isHostHaveWarnings', function () { - - var tests = [ - { - warnings: [ - {}, - {} - ], - m: 'Warnings exist', - e: true - }, - { - warnings: [], - m: 'Warnings don\'t exist', - e: false - } - ]; - - tests.forEach(function (test) { - it(test.m, function () { - c.set('warnings', test.warnings); - expect(c.get('isHostHaveWarnings')).to.equal(test.e); - }); - }); - - }); - describe('#isWarningsBoxVisible', function () { afterEach(function () { http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/controllers/wizard/step6_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/wizard/step6_test.js b/ambari-web/test/controllers/wizard/step6_test.js index b2524e4..056c30a 100644 --- a/ambari-web/test/controllers/wizard/step6_test.js +++ b/ambari-web/test/controllers/wizard/step6_test.js @@ -44,44 +44,42 @@ var controller, isSelected: true }) ]; -describe('App.WizardStep6Controller', function () { - beforeEach(function () { - controller = App.WizardStep6Controller.create(); - controller.set('content', Em.Object.create({ +function getController() { + var controller = App.WizardStep6Controller.create({ + content: Em.Object.create({ hosts: {}, masterComponentHosts: {}, - services: services - })); + services: services, + controllerName: '' + }) + }); - var h = {}, m = []; - Em.A(['host0', 'host1', 'host2', 'host3']).forEach(function (hostName) { - var obj = Em.Object.create({ - name: hostName, - hostName: hostName, - bootStatus: 'REGISTERED' - }); - h[hostName] = obj; - m.push(obj); + var h = {}, m = []; + Em.A(['host0', 'host1', 'host2', 'host3']).forEach(function (hostName) { + var obj = Em.Object.create({ + name: hostName, + hostName: hostName, + bootStatus: 'REGISTERED' }); + h[hostName] = obj; + m.push(obj); + }); - controller.set('content.hosts', h); - controller.set('content.masterComponentHosts', m); - controller.set('isMasters', false); + controller.set('content.hosts', h); + controller.set('content.masterComponentHosts', m); + controller.set('isMasters', false); + return controller; +} - }); +describe('App.WizardStep6Controller', function () { - describe('#isAddHostWizard', function () { - it('true if content.controllerName is addHostController', function () { - controller.set('content.controllerName', 'addHostController'); - expect(controller.get('isAddHostWizard')).to.equal(true); - }); - it('false if content.controllerName is not addHostController', function () { - controller.set('content.controllerName', 'mainController'); - expect(controller.get('isAddHostWizard')).to.equal(false); - }); + beforeEach(function () { + controller = getController(); }); + App.TestAliases.testAsComputedEqual(getController(), 'isAddHostWizard', 'content.controllerName', 'addHostController'); + describe('#installedServiceNames', function () { it(' should filter content.services by isInstalled property', function () { var services = Em.A([]); @@ -348,27 +346,9 @@ describe('App.WizardStep6Controller', function () { }); }); - describe('#isInstallerWizard', function () { - it('true if content.controllerName is addHostController', function () { - controller.set('content.controllerName', 'installerController'); - expect(controller.get('isInstallerWizard')).to.equal(true); - }); - it('false if content.controllerName is not addHostController', function () { - controller.set('content.controllerName', 'mainController'); - expect(controller.get('isInstallerWizard')).to.equal(false); - }); - }); + App.TestAliases.testAsComputedEqual(getController(), 'isInstallerWizard', 'content.controllerName', 'installerController'); - describe('#isAddServiceWizard', function () { - it('true if content.controllerName is addServiceController', function () { - controller.set('content.controllerName', 'addServiceController'); - expect(controller.get('isAddServiceWizard')).to.equal(true); - }); - it('false if content.controllerName is not addServiceController', function () { - controller.set('content.controllerName', 'mainController'); - expect(controller.get('isAddServiceWizard')).to.equal(false); - }); - }); + App.TestAliases.testAsComputedEqual(getController(), 'isAddServiceWizard', 'content.controllerName', 'addServiceController'); describe('#selectClientHost', function () { it('true if isClientsSet false', function () { http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/controllers/wizard/step7_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/wizard/step7_test.js b/ambari-web/test/controllers/wizard/step7_test.js index 35b7a5b..4d43a09 100644 --- a/ambari-web/test/controllers/wizard/step7_test.js +++ b/ambari-web/test/controllers/wizard/step7_test.js @@ -96,23 +96,31 @@ var installerStep7Controller, controller.get('filterColumns').findProperty('attributeName', 'hasIssues').set('selected', testCase.isIssuesFilterActive); }; +function getController() { + return App.WizardStep7Controller.create({ + content: Em.Object.create({ + services: [], + advancedServiceConfig: [], + serviceConfigProperties: [] + }) + }); +} + describe('App.InstallerStep7Controller', function () { beforeEach(function () { sinon.stub(App.config, 'setPreDefinedServiceConfigs', Em.K); - installerStep7Controller = App.WizardStep7Controller.create({ - content: Em.Object.create({ - services: [], - advancedServiceConfig: [], - serviceConfigProperties: [] - }) - }); + installerStep7Controller = getController(); }); afterEach(function() { App.config.setPreDefinedServiceConfigs.restore(); }); + App.TestAliases.testAsComputedAlias(getController(), 'masterComponentHosts', 'content.masterComponentHosts', 'array'); + + App.TestAliases.testAsComputedAlias(getController(), 'slaveComponentHosts', 'content.slaveGroupProperties', 'array'); + describe('#installedServiceNames', function () { var tests = Em.A([ @@ -248,30 +256,6 @@ describe('App.InstallerStep7Controller', function () { }); }); - describe('#masterComponentHosts', function () { - it('should be equal to content.masterComponentHosts', function () { - var masterComponentHosts = [ - {}, - {}, - {} - ]; - installerStep7Controller.reopen({content: {masterComponentHosts: masterComponentHosts}}); - expect(installerStep7Controller.get('masterComponentHosts')).to.eql(masterComponentHosts); - }); - }); - - describe('#slaveComponentHosts', function () { - it('should be equal to content.slaveGroupProperties', function () { - var slaveGroupProperties = [ - {}, - {}, - {} - ]; - installerStep7Controller.reopen({content: {slaveGroupProperties: slaveGroupProperties}}); - expect(installerStep7Controller.get('slaveComponentHosts')).to.eql(slaveGroupProperties); - }); - }); - describe('#_createSiteToTagMap', function () { it('should return filtered map', function () { var desired_configs = { http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/controllers/wizard/step8_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/wizard/step8_test.js b/ambari-web/test/controllers/wizard/step8_test.js index 71d1e48..0e120a2 100644 --- a/ambari-web/test/controllers/wizard/step8_test.js +++ b/ambari-web/test/controllers/wizard/step8_test.js @@ -23,42 +23,47 @@ require('controllers/main/service/info/configs'); require('controllers/wizard/step8_controller'); var installerStep8Controller, configurationController; -describe('App.WizardStep8Controller', function () { +var configs = Em.A([ + Em.Object.create({filename: 'hdfs-site.xml', name: 'p1', value: 'v1'}), + Em.Object.create({filename: 'hdfs-site.xml', name: 'p2', value: 'v2'}), + Em.Object.create({filename: 'hue-site.xml', name: 'p1', value: 'v1'}), + Em.Object.create({filename: 'hue-site.xml', name: 'p2', value: 'v2'}), + Em.Object.create({filename: 'mapred-site.xml', name: 'p1', value: 'v1'}), + Em.Object.create({filename: 'mapred-site.xml', name: 'p2', value: 'v2'}), + Em.Object.create({filename: 'yarn-site.xml', name: 'p1', value: 'v1'}), + Em.Object.create({filename: 'yarn-site.xml', name: 'p2', value: 'v2'}), + Em.Object.create({filename: 'capacity-scheduler.xml', name: 'p1', value: 'v1'}), + Em.Object.create({filename: 'capacity-scheduler.xml', name: 'p2', value: 'v2'}), + Em.Object.create({filename: 'mapred-queue-acls.xml', name: 'p1', value: 'v1'}), + Em.Object.create({filename: 'mapred-queue-acls.xml', name: 'p2', value: 'v2'}), + Em.Object.create({filename: 'hbase-site.xml', name: 'p1', value: 'v1'}), + Em.Object.create({filename: 'hbase-site.xml', name: 'p2', value: 'v2'}), + Em.Object.create({filename: 'oozie-site.xml', name: 'p1', value: 'v1'}), + Em.Object.create({filename: 'oozie-site.xml', name: 'p2', value: 'v2'}), + Em.Object.create({filename: 'hive-site.xml', name: 'p1', value: 'v1'}), + Em.Object.create({filename: 'hive-site.xml', name: 'p2', value: 'v2'}), + Em.Object.create({filename: 'pig-properties.xml', name: 'p1', value: 'v1'}), + Em.Object.create({filename: 'webhcat-site.xml', name: 'p1', value: 'v1'}), + Em.Object.create({filename: 'webhcat-site.xml', name: 'p2', value: 'v2'}), + Em.Object.create({filename: 'tez-site.xml', name: 'p1', value: 'v1'}), + Em.Object.create({filename: 'tez-site.xml', name: 'p2', value: 'v2'}), + Em.Object.create({filename: 'falcon-startup.properties.xml', name: 'p1', value: 'v1'}), + Em.Object.create({filename: 'falcon-startup.properties.xml', name: 'p2', value: 'v2'}), + Em.Object.create({filename: 'falcon-runtime.properties.xml', name: 'p1', value: 'v1'}), + Em.Object.create({filename: 'falcon-runtime.properties.xml', name: 'p2', value: 'v2'}) +]); + +function getController() { + return App.WizardStep8Controller.create({ + configs: configs, + content: {controllerName: ''} + }); +} - var configs = Em.A([ - Em.Object.create({filename: 'hdfs-site.xml', name: 'p1', value: 'v1'}), - Em.Object.create({filename: 'hdfs-site.xml', name: 'p2', value: 'v2'}), - Em.Object.create({filename: 'hue-site.xml', name: 'p1', value: 'v1'}), - Em.Object.create({filename: 'hue-site.xml', name: 'p2', value: 'v2'}), - Em.Object.create({filename: 'mapred-site.xml', name: 'p1', value: 'v1'}), - Em.Object.create({filename: 'mapred-site.xml', name: 'p2', value: 'v2'}), - Em.Object.create({filename: 'yarn-site.xml', name: 'p1', value: 'v1'}), - Em.Object.create({filename: 'yarn-site.xml', name: 'p2', value: 'v2'}), - Em.Object.create({filename: 'capacity-scheduler.xml', name: 'p1', value: 'v1'}), - Em.Object.create({filename: 'capacity-scheduler.xml', name: 'p2', value: 'v2'}), - Em.Object.create({filename: 'mapred-queue-acls.xml', name: 'p1', value: 'v1'}), - Em.Object.create({filename: 'mapred-queue-acls.xml', name: 'p2', value: 'v2'}), - Em.Object.create({filename: 'hbase-site.xml', name: 'p1', value: 'v1'}), - Em.Object.create({filename: 'hbase-site.xml', name: 'p2', value: 'v2'}), - Em.Object.create({filename: 'oozie-site.xml', name: 'p1', value: 'v1'}), - Em.Object.create({filename: 'oozie-site.xml', name: 'p2', value: 'v2'}), - Em.Object.create({filename: 'hive-site.xml', name: 'p1', value: 'v1'}), - Em.Object.create({filename: 'hive-site.xml', name: 'p2', value: 'v2'}), - Em.Object.create({filename: 'pig-properties.xml', name: 'p1', value: 'v1'}), - Em.Object.create({filename: 'webhcat-site.xml', name: 'p1', value: 'v1'}), - Em.Object.create({filename: 'webhcat-site.xml', name: 'p2', value: 'v2'}), - Em.Object.create({filename: 'tez-site.xml', name: 'p1', value: 'v1'}), - Em.Object.create({filename: 'tez-site.xml', name: 'p2', value: 'v2'}), - Em.Object.create({filename: 'falcon-startup.properties.xml', name: 'p1', value: 'v1'}), - Em.Object.create({filename: 'falcon-startup.properties.xml', name: 'p2', value: 'v2'}), - Em.Object.create({filename: 'falcon-runtime.properties.xml', name: 'p1', value: 'v1'}), - Em.Object.create({filename: 'falcon-runtime.properties.xml', name: 'p2', value: 'v2'}) - ]); +describe('App.WizardStep8Controller', function () { beforeEach(function () { - installerStep8Controller = App.WizardStep8Controller.create({ - configs: configs - }); + installerStep8Controller = getController(); configurationController = App.MainServiceInfoConfigsController.create({}); }); @@ -92,6 +97,12 @@ describe('App.WizardStep8Controller', function () { }); }); + App.TestAliases.testAsComputedFilterBy(getController(), 'installedServices', 'content.services', 'isInstalled', true); + + App.TestAliases.testAsComputedEqual(getController(), 'isManualKerberos', 'App.router.mainAdminKerberosController.kdc_type', 'none'); + + App.TestAliases.testAsComputedAlias(getController(), 'clusterName', 'content.cluster.name', 'string'); + describe('#createSelectedServicesData', function () { var tests = Em.A([ @@ -228,13 +239,6 @@ describe('App.WizardStep8Controller', function () { }); - describe('#clusterName', function () { - it('should be equal to content.cluster.name', function () { - installerStep8Controller.set('content', {cluster: {name: 'new_name'}}); - expect(installerStep8Controller.get('clusterName')).to.equal('new_name'); - }); - }); - describe('#createCoreSiteObj', function () { it('should return config', function () { var content = Em.Object.create({ @@ -1887,17 +1891,7 @@ describe('App.WizardStep8Controller', function () { }); - describe('#isAllClusterDeleteRequestsCompleted', function () { - it('should depend on completed cluster delete requests number', function () { - installerStep8Controller.setProperties({ - clusterDeleteRequestsCompleted: 0, - clusterNames: ['c0'] - }); - expect(installerStep8Controller.get('isAllClusterDeleteRequestsCompleted')).to.be.false; - installerStep8Controller.incrementProperty('clusterDeleteRequestsCompleted'); - expect(installerStep8Controller.get('isAllClusterDeleteRequestsCompleted')).to.be.true; - }); - }); + App.TestAliases.testAsComputedEqualProperties(getController(), 'isAllClusterDeleteRequestsCompleted', 'clusterDeleteRequestsCompleted', 'clusterNames.length'); describe('#deleteClusterSuccessCallback', function () { http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/controllers/wizard/step9_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/wizard/step9_test.js b/ambari-web/test/controllers/wizard/step9_test.js index fabdc2d..fc52920 100644 --- a/ambari-web/test/controllers/wizard/step9_test.js +++ b/ambari-web/test/controllers/wizard/step9_test.js @@ -29,27 +29,32 @@ require('utils/ajax/ajax'); var modelSetup = require('test/init_model_test'); var c, obj; + +function getController() { + return App.WizardStep9Controller.create({ + content: {controllerName: '', cluster: {status: ''}}, + saveClusterStatus: Em.K, + saveInstalledHosts: Em.K, + togglePreviousSteps: Em.K, + setFinishState: Em.K, + changeParseHostInfo: Em.K, + parseHostInfoPolling: Em.K, + wizardController: Em.Object.create({ + requestsId: [], + cluster: {oldRequestsId: []}, + getDBProperty: function(name) { + return this.get(name); + } + }) + }); +} + describe('App.InstallerStep9Controller', function () { beforeEach(function () { App.set('supports.skipComponentStartAfterInstall', false); modelSetup.setupStackServiceComponent(); - c = App.WizardStep9Controller.create({ - content: {controllerName: ''}, - saveClusterStatus: Em.K, - saveInstalledHosts: Em.K, - togglePreviousSteps: Em.K, - setFinishState: Em.K, - changeParseHostInfo: Em.K, - parseHostInfoPolling: Em.K, - wizardController: Em.Object.create({ - requestsId: [], - cluster: {oldRequestsId: []}, - getDBProperty: function(name) { - return this.get(name); - } - }) - }); + c = getController(); obj = App.InstallerController.create(); sinon.stub(App.ajax, 'send', function() { return { @@ -72,6 +77,8 @@ describe('App.InstallerStep9Controller', function () { App.ajax.send.restore(); }); + App.TestAliases.testAsComputedEqual(getController(), 'showRetry', 'content.cluster.status', 'INSTALL FAILED'); + describe('#isSubmitDisabled', function () { var tests = Em.A([ {controllerName: 'addHostController', state: 'STARTED', e: false}, @@ -181,17 +188,6 @@ describe('App.InstallerStep9Controller', function () { }); }); - describe('#showRetry', function () { - it('cluster status is not INSTALL FAILED', function () { - c.reopen({content: {cluster: {status: 'INSTALLED'}}}); - expect(c.get('showRetry')).to.equal(false); - }); - it('cluster status is INSTALL FAILED', function () { - c.reopen({content: {cluster: {status: 'INSTALL FAILED'}}}); - expect(c.get('showRetry')).to.equal(true); - }); - }); - describe('#resetHostsForRetry', function () { it('All should have status "pending" and message "Waiting"', function () { var hosts = {'host1': Em.Object.create({status: 'failed', message: 'Failed'}), 'host2': Em.Object.create({status: 'success', message: 'Success'})}; http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/models/authentication_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/models/authentication_test.js b/ambari-web/test/models/authentication_test.js index 3e7f44d..f0002cd 100644 --- a/ambari-web/test/models/authentication_test.js +++ b/ambari-web/test/models/authentication_test.js @@ -63,6 +63,10 @@ describe('App.AuthenticationForm', function () { }); }); + App.TestAliases.testAsComputedIfThenElse(App.AuthenticationForm.create(), 'testConfigurationMessage', 'testResult', Em.I18n.t('admin.authentication.form.test.success'), Em.I18n.t('admin.authentication.form.test.fail')); + + App.TestAliases.testAsComputedIfThenElse(App.AuthenticationForm.create(), 'testConfigurationClass', 'testResult', 'text-success', 'text-error'); + describe('#testResult', function () { it('should be 0 or 1', function () { form.testConfiguration(); http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/models/cluster_states_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/models/cluster_states_test.js b/ambari-web/test/models/cluster_states_test.js index f114b3d..3f12d9f 100644 --- a/ambari-web/test/models/cluster_states_test.js +++ b/ambari-web/test/models/cluster_states_test.js @@ -45,18 +45,7 @@ var compressedResponse = LZString.compressToBase64(JSON.stringify(response2)); describe('App.clusterStatus', function () { - describe('#isInstalled', function () { - notInstalledStates.forEach(function (item) { - it('should be false', function () { - status.set('clusterState', item); - expect(status.get('isInstalled')).to.be.false; - }); - }); - it('should be true', function () { - status.set('clusterState', 'DEFAULT'); - expect(status.get('isInstalled')).to.be.true; - }); - }); + App.TestAliases.testAsComputedNotExistsIn(status, 'isInstalled', 'clusterState', notInstalledStates); describe('#value', function () { it('should be set from properties', function () { http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/models/configs/objects/service_config_category_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/models/configs/objects/service_config_category_test.js b/ambari-web/test/models/configs/objects/service_config_category_test.js index 33521fe..87e1616 100644 --- a/ambari-web/test/models/configs/objects/service_config_category_test.js +++ b/ambari-web/test/models/configs/objects/service_config_category_test.js @@ -1,4 +1,3 @@ - /** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -104,12 +103,18 @@ var serviceConfigCategory, ] }; +function getCategory() { + return App.ServiceConfigCategory.create(); +} + describe('App.ServiceConfigCategory', function () { beforeEach(function () { - serviceConfigCategory = App.ServiceConfigCategory.create(); + serviceConfigCategory = getCategory(); }); + App.TestAliases.testAsComputedSumProperties(getCategory(), 'errorCount', ['slaveErrorCount', 'nonSlaveErrorCount']); + describe('#primaryName', function () { nameCases.forEach(function (item) { it('should return ' + item.primary, function () { @@ -156,19 +161,6 @@ describe('App.ServiceConfigCategory', function () { }); }); - describe('#errorCount', function () { - it('should sum all errors for category', function () { - serviceConfigCategory.reopen({ - slaveErrorCount: 1 - }); - expect(serviceConfigCategory.get('errorCount')).to.equal(1); - serviceConfigCategory.set('nonSlaveErrorCount', 2); - expect(serviceConfigCategory.get('errorCount')).to.equal(3); - serviceConfigCategory.set('slaveErrorCount', 0); - expect(serviceConfigCategory.get('errorCount')).to.equal(2); - }); - }); - describe('#isAdvanced', function () { it('should be true', function () { serviceConfigCategory.set('name', 'Advanced'); http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/models/configs/objects/service_config_property_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/models/configs/objects/service_config_property_test.js b/ambari-web/test/models/configs/objects/service_config_property_test.js index 0421ab4..11ea4ab 100644 --- a/ambari-web/test/models/configs/objects/service_config_property_test.js +++ b/ambari-web/test/models/configs/objects/service_config_property_test.js @@ -321,12 +321,18 @@ var serviceConfigProperty, } ]; +function getProperty() { + return App.ServiceConfigProperty.create(); +} + describe('App.ServiceConfigProperty', function () { beforeEach(function () { - serviceConfigProperty = App.ServiceConfigProperty.create(); + serviceConfigProperty = getProperty(); }); + App.TestAliases.testAsComputedFirstNotBlank(getProperty(), 'placeholder', ['placeholderText', 'savedValue']); + describe('#overrideErrorTrigger', function () { it('should be an increment', function () { serviceConfigProperty.set('overrides', configsData[0].overrides); http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/models/configs/section_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/models/configs/section_test.js b/ambari-web/test/models/configs/section_test.js index 967534e..3c9ab40 100644 --- a/ambari-web/test/models/configs/section_test.js +++ b/ambari-web/test/models/configs/section_test.js @@ -19,10 +19,14 @@ var App = require('app'); var model; +function getModel() { + return App.Section.createRecord(); +} + describe('App.Section', function () { beforeEach(function () { - model = App.Section.createRecord(); + model = getModel(); }); describe('#errorsCount', function () { @@ -46,54 +50,6 @@ describe('App.Section', function () { }); - describe('#isHiddenByFilter', function () { - - Em.A([ - { - subSections: [], - m: 'no subsections', - e: true - }, - { - subSections: [ - App.SubSection.createRecord({configs: [Em.Object.create({isHiddenByFilter: false, isVisible: true}), Em.Object.create({isHiddenByFilter: false, isVisible: true})]}), - App.SubSection.createRecord({configs: [Em.Object.create({isHiddenByFilter: false, isVisible: true}), Em.Object.create({isHiddenByFilter: false, isVisible: true})]}) - ], - m: 'no subsections are hidden', - e: false - }, - { - subSections: [ - App.SubSection.createRecord({configs: [Em.Object.create({isHiddenByFilter: true, isVisible: false, hiddenBySection: false}), Em.Object.create({isHiddenByFilter: true, isVisible: true, hiddenBySection: true})]}) - ], - m: 'no subsections are hidden (hiddenBySection)', - e: false - }, - { - subSections: [ - App.SubSection.createRecord({configs: [Em.Object.create({isHiddenByFilter: true, isVisible: true}), Em.Object.create({isHiddenByFilter: true, isVisible: true})]}), - App.SubSection.createRecord({configs: [Em.Object.create({isHiddenByFilter: false, isVisible: true}), Em.Object.create({isHiddenByFilter: false, isVisible: true})]}) - ], - m: 'one subsection is hidden', - e: false - }, - { - subSections: [ - App.SubSection.createRecord({configs: [Em.Object.create({isHiddenByFilter: true, isVisible: true}), Em.Object.create({isHiddenByFilter: true, isVisible: true})]}), - App.SubSection.createRecord({configs: [Em.Object.create({isHiddenByFilter: true, isVisible: true}), Em.Object.create({isHiddenByFilter: true, isVisible: true})]}) - ], - m: 'all subsections are hidden', - e: true - } - ]).forEach(function (test) { - it(test.m, function () { - model.reopen({ - subSections: test.subSections - }); - expect(model.get('isHiddenByFilter')).to.equal(test.e); - }); - }); - - }); + App.TestAliases.testAsComputedEveryBy(getModel(), 'isHiddenByFilter', 'subSections', 'isSectionVisible', false); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/models/host_component_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/models/host_component_test.js b/ambari-web/test/models/host_component_test.js index 6ba6fb0..ef68fb6 100644 --- a/ambari-web/test/models/host_component_test.js +++ b/ambari-web/test/models/host_component_test.js @@ -27,15 +27,6 @@ describe('App.HostComponent', function() { }); var hc = App.HostComponent.find('COMP_host'); - - describe('#getStatusesList', function() { - it('allowed statuses', function() { - var statuses = ["STARTED","STARTING","INSTALLED","STOPPING","INSTALL_FAILED","INSTALLING","UPGRADE_FAILED","UNKNOWN","DISABLED","INIT"]; - expect(App.HostComponentStatus.getStatusesList()).to.include.members(statuses); - expect(statuses).to.include.members(App.HostComponentStatus.getStatusesList()); - }); - }); - describe('#getStatusesList', function() { it('allowed statuses', function() { var statuses = ["STARTED","STARTING","INSTALLED","STOPPING","INSTALL_FAILED","INSTALLING","UPGRADE_FAILED","UNKNOWN","DISABLED","INIT"]; @@ -94,29 +85,9 @@ describe('App.HostComponent', function() { }); }); - describe('#isRunning', function() { - var testCases = [ - { - workStatus: 'INSTALLED', - result: false - }, - { - workStatus: 'STARTING', - result: true - }, - { - workStatus: 'STARTED', - result: true - } - ]; - testCases.forEach(function(test){ - it('workStatus - ' + test.workStatus, function() { - hc.set('workStatus', test.workStatus); - hc.propertyDidChange('isRunning'); - expect(hc.get('isRunning')).to.equal(test.result); - }); - }); - }); + App.TestAliases.testAsComputedIfThenElse(hc, 'passiveTooltip', 'isActive', '', Em.I18n.t('hosts.component.passive.mode')); + + App.TestAliases.testAsComputedExistsIn(hc, 'isRunning', 'workStatus', ['STARTED', 'STARTING']); describe('#isDecommissioning', function() { var mock = []; @@ -157,6 +128,10 @@ describe('App.HostComponent', function() { }); }); + App.TestAliases.testAsComputedEqual(hc, 'isActive', 'passiveState', 'OFF'); + + App.TestAliases.testAsComputedIfThenElse(hc, 'passiveTooltip', 'isActive', '', Em.I18n.t('hosts.component.passive.mode')); + describe('#isActive', function() { it('passiveState is ON', function() { hc.set('passiveState', "ON"); @@ -315,28 +290,6 @@ describe('App.HostComponent', function() { }); }); - describe('#isNotInstalled', function () { - - Em.A([ - { - p: {workStatus: 'INIT'}, - e: true - }, - { - p: {workStatus: 'INSTALL_FAILED'}, - e: true - }, - { - p: {workStatus: 'STARTED'}, - e: false - } - ]).forEach(function (test, index) { - it('#' + (index + 1), function() { - hc.setProperties(test.p); - expect(hc.get('isNotInstalled')).to.equal(test.e); - }); - }); - - }); + App.TestAliases.testAsComputedExistsIn(hc, 'isNotInstalled', 'workStatus', ['INIT', 'INSTALL_FAILED']); }); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/models/host_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/models/host_test.js b/ambari-web/test/models/host_test.js index 30bc5e2..9642c41 100644 --- a/ambari-web/test/models/host_test.js +++ b/ambari-web/test/models/host_test.js @@ -52,16 +52,25 @@ describe('App.Host', function () { last_heart_beat_time: (new Date()).getTime() } ]; + before(function() { App.set('testMode', false); }); + App.Host.reopen({ hostComponents: [] }); + App.store.loadMany(App.Host, data); var host1 = App.Host.find('host1'); + App.TestAliases.testAsComputedAlias(host1, 'componentsInPassiveStateCount', 'componentsInPassiveState.length', 'number'); + + App.TestAliases.testAsComputedAlias(host1, 'componentsWithStaleConfigsCount', 'componentsWithStaleConfigs.length', 'number'); + + App.TestAliases.testAsComputedAlias(host1, 'disksMounted', 'diskInfo.length', 'number'); + describe('#diskUsedFormatted', function () { it('host1 - 10GB ', function () { @@ -460,4 +469,5 @@ describe('App.Host', function () { }); }); }); + }); http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/models/repository_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/models/repository_test.js b/ambari-web/test/models/repository_test.js index 2c65907..d3a2875 100644 --- a/ambari-web/test/models/repository_test.js +++ b/ambari-web/test/models/repository_test.js @@ -20,14 +20,24 @@ var App = require('app'); require('models/repository'); +function getModel() { + return App.Repository.createRecord(); +} + describe('App.Repository', function () { var model; beforeEach(function () { - model = App.Repository.createRecord(); + model = getModel(); }); + App.TestAliases.testAsComputedNotEqualProperties(getModel(), 'undo', 'baseUrl', 'latestBaseUrl'); + + App.TestAliases.testAsComputedAlias(getModel(), 'isSelected', 'operatingSystem.isSelected', 'boolean'); + + App.TestAliases.testAsComputedAlias(getModel(), 'clearAll', 'baseUrl', 'string'); // string?? + describe('#invalidFormatError', function () { var cases = [ http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/models/stack_service_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/models/stack_service_test.js b/ambari-web/test/models/stack_service_test.js index 8299cce..0d3fdf6 100644 --- a/ambari-web/test/models/stack_service_test.js +++ b/ambari-web/test/models/stack_service_test.js @@ -212,18 +212,7 @@ describe('App.StackService', function () { }); }); - describe('#isClientOnlyService', function () { - it('Has not only client serviceComponents', function () { - ss.set('serviceComponents', [Em.Object.create({isSlave: true}), Em.Object.create({isClient: true})]); - ss.propertyDidChange('isClientOnlyService'); - expect(ss.get('isClientOnlyService')).to.be.false; - }); - it('Has only client serviceComponents', function () { - ss.set('serviceComponents', [Em.Object.create({isClient: true})]); - ss.propertyDidChange('isClientOnlyService'); - expect(ss.get('isClientOnlyService')).to.be.true; - }); - }); + App.TestAliases.testAsComputedEveryBy(ss, 'isClientOnlyService', 'serviceComponents', 'isClient', true); describe('#isNoConfigTypes', function () { it('configTypes is null', function () { http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/models/upgrade_entity_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/models/upgrade_entity_test.js b/ambari-web/test/models/upgrade_entity_test.js index 0aa9248c..38fa093 100644 --- a/ambari-web/test/models/upgrade_entity_test.js +++ b/ambari-web/test/models/upgrade_entity_test.js @@ -19,13 +19,19 @@ var App = require('app'); require('models/upgrade_entity'); +function getModel() { + return App.upgradeEntity.create(); +} + describe('App.upgradeEntity', function () { var model; beforeEach(function () { - model = App.upgradeEntity.create(); + model = getModel(); }); + App.TestAliases.testAsComputedNotEqual(getModel(), 'isVisible', 'status', 'PENDING'); + describe("#isRunning", function() { it("status IN_PROGRESS", function() { model.set('status', 'IN_PROGRESS'); http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/models/user_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/models/user_test.js b/ambari-web/test/models/user_test.js index 607f4dd..4a3a48d 100644 --- a/ambari-web/test/models/user_test.js +++ b/ambari-web/test/models/user_test.js @@ -28,16 +28,22 @@ var user, id: 'user' }; +function getUser() { + return App.User.createRecord(userData); +} + describe('App.User', function () { beforeEach(function () { - user = App.User.createRecord(userData); + user = getUser(); }); afterEach(function () { modelSetup.deleteRecord(user); }); + App.TestAliases.testAsComputedAlias(getUser(), 'id', 'userName', 'string'); + describe('#id', function () { it('should take value from userName', function () { user.set('userName', 'name'); @@ -57,27 +63,17 @@ describe('App.User', function () { }); }); +function getForm() { + return App.CreateUserForm.create(); +} + describe('App.CreateUserForm', function () { beforeEach(function () { - form = App.CreateUserForm.create(); + form = getForm(); }); - describe('#object', function () { - - before(function () { - sinon.stub(App, 'get').withArgs('router.mainAdminUserCreateController.content').returns(userData); - }); - - after(function () { - App.get.restore(); - }); - - it('should take data from controller', function () { - expect(form.get('object')).to.eql(userData); - }); - - }); + App.TestAliases.testAsComputedAlias(getForm(), 'object', 'App.router.mainAdminUserCreateController.content', 'object'); describe('#field.userName.toLowerCase', function () { it('should convert userName into lower case', function () { http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/views/common/configs/config_history_flow_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/common/configs/config_history_flow_test.js b/ambari-web/test/views/common/configs/config_history_flow_test.js index 8d76946..ab3383e 100644 --- a/ambari-web/test/views/common/configs/config_history_flow_test.js +++ b/ambari-web/test/views/common/configs/config_history_flow_test.js @@ -31,6 +31,8 @@ describe.skip('App.ConfigHistoryFlowView', function () { serviceVersions: [] }); + App.TestAliases.testAsComputedAlias(view, 'serviceName', 'controller.selectedService.serviceName', 'string'); + describe('#isSaveDisabled', function () { var testCases = [ { @@ -725,3 +727,15 @@ describe.skip('App.ConfigHistoryFlowView', function () { }); }); }); + +function getView() { + return App.ConfigsServiceVersionBoxView.create(); +} + +describe('App.ConfigsServiceVersionBoxView', function () { + + App.TestAliases.testAsComputedAlias(getView(), 'disabledActionAttr', 'serviceVersion.disabledActionAttr', 'object'); + + App.TestAliases.testAsComputedAlias(getView(), 'disabledActionMessages', 'serviceVersion.disabledActionMessages', 'object'); + +}); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/views/common/configs/custom_category_views/notification_configs_view_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/common/configs/custom_category_views/notification_configs_view_test.js b/ambari-web/test/views/common/configs/custom_category_views/notification_configs_view_test.js index 0cf2992..ce0dd39 100644 --- a/ambari-web/test/views/common/configs/custom_category_views/notification_configs_view_test.js +++ b/ambari-web/test/views/common/configs/custom_category_views/notification_configs_view_test.js @@ -20,24 +20,30 @@ var App = require('app'); require('views/common/configs/custom_category_views/notification_configs_view'); var view; +function getView() { + return App.NotificationsConfigsView.create({ + $: function() { + return {show: Em.K, hide: Em.K}; + }, + category: { + name: 'name' + }, + serviceConfigs: [], + parentView: Em.View.create({ + filter: '', + columns: [] + }) + }); +} + describe('App.NotificationsConfigsView', function () { beforeEach(function () { - view = App.NotificationsConfigsView.create({ - $: function() { - return {show: Em.K, hide: Em.K}; - }, - category: { - name: 'name' - }, - serviceConfigs: [], - parentView: Em.View.create({ - filter: '', - columns: [] - }) - }); + view = getView(); }); + App.TestAliases.testAsComputedFindBy(getView(), 'useAuthConfig', 'categoryConfigs', 'name', 'smtp_use_auth'); + describe('#didInsertElement', function () { beforeEach(function () { http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/views/common/configs/service_configs_by_category_view_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/common/configs/service_configs_by_category_view_test.js b/ambari-web/test/views/common/configs/service_configs_by_category_view_test.js index 59ac49c..167c007 100644 --- a/ambari-web/test/views/common/configs/service_configs_by_category_view_test.js +++ b/ambari-web/test/views/common/configs/service_configs_by_category_view_test.js @@ -94,6 +94,8 @@ describe('App.ServiceConfigsByCategoryView', function () { } ]; + App.TestAliases.testAsComputedIfThenElse(view, 'isCategoryBodyVisible', 'category.isCollapsed', 'display: none;', 'display: block;'); + describe('#sortByIndex', function () { testData.forEach(function(_test){ it(_test.title, function () { @@ -402,4 +404,5 @@ describe('App.ServiceConfigsByCategoryView', function () { }); }); }); + }); http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/views/common/form/manage_kdc_credentials_form_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/common/form/manage_kdc_credentials_form_test.js b/ambari-web/test/views/common/form/manage_kdc_credentials_form_test.js index 76b6763..6addbed 100644 --- a/ambari-web/test/views/common/form/manage_kdc_credentials_form_test.js +++ b/ambari-web/test/views/common/form/manage_kdc_credentials_form_test.js @@ -21,17 +21,27 @@ var credentialUtils = require('utils/credentials'); var view; +function getView() { + return App.ManageCredentialsFormView.create({ + parentView: Em.Object.create({}) + }); +} + describe('#App.ManageCredentialsFormView', function() { beforeEach(function() { - view = App.ManageCredentialsFormView.create({ - parentView: Em.Object.create({}) - }); + view = getView(); }); afterEach(function() { view.destroy(); }); + App.TestAliases.testAsComputedAlias(getView(), 'storePersisted', 'App.isCredentialStorePersistent', 'boolean'); + + App.TestAliases.testAsComputedIfThenElse(getView(), 'formHeader', 'isRemovable', Em.I18n.t('admin.kerberos.credentials.form.header.stored'), Em.I18n.t('admin.kerberos.credentials.form.header.not.stored')); + + App.TestAliases.testAsComputedIfThenElse(getView(), 'hintMessage', 'storePersisted', Em.I18n.t('admin.kerberos.credentials.store.hint.supported'), Em.I18n.t('admin.kerberos.credentials.store.hint.not.supported')); + describe('#prepareContent', function() { [ { http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/views/common/table_view_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/common/table_view_test.js b/ambari-web/test/views/common/table_view_test.js index ab7c89b..50a5ee3 100644 --- a/ambari-web/test/views/common/table_view_test.js +++ b/ambari-web/test/views/common/table_view_test.js @@ -24,6 +24,10 @@ require('mixins'); require('mixins/common/userPref'); require('views/common/table_view'); +function getView() { + return App.TableView.create(); +} + describe('App.TableView', function () { var view; @@ -38,6 +42,10 @@ describe('App.TableView', function () { App.db.setFilterConditions.restore(); }); + App.TestAliases.testAsComputedAlias(getView(), 'filteredCount', 'filteredContent.length', 'number'); + + App.TestAliases.testAsComputedAlias(getView(), 'totalCount', 'content.length', 'number'); + describe('#init', function() { it('should set filterConditions on instance', function() { http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/views/main/admin/highAvailability/nameNode/step4_view_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/main/admin/highAvailability/nameNode/step4_view_test.js b/ambari-web/test/views/main/admin/highAvailability/nameNode/step4_view_test.js index 6134f80..c3202f6 100644 --- a/ambari-web/test/views/main/admin/highAvailability/nameNode/step4_view_test.js +++ b/ambari-web/test/views/main/admin/highAvailability/nameNode/step4_view_test.js @@ -54,16 +54,6 @@ describe('App.HighAvailabilityWizardStep4View', function () { }); }); - describe("#nnCheckPointText", function() { - it("isNextEnabled true", function() { - view.set('controller.isNextEnabled', true); - view.propertyDidChange('nnCheckPointText'); - expect(view.get('nnCheckPointText')).to.equal(Em.I18n.t('admin.highAvailability.wizard.step4.ckCreated')); - }); - it("isNextEnabled false", function() { - view.set('controller.isNextEnabled', false); - view.propertyDidChange('nnCheckPointText'); - expect(view.get('nnCheckPointText')).to.equal(Em.I18n.t('admin.highAvailability.wizard.step4.ckNotCreated')); - }); - }); + App.TestAliases.testAsComputedIfThenElse(view, 'nnCheckPointText', 'controller.isNextEnabled', Em.I18n.t('admin.highAvailability.wizard.step4.ckCreated'), Em.I18n.t('admin.highAvailability.wizard.step4.ckNotCreated')); + }); http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/views/main/admin/stack_upgrade/upgrade_wizard_view_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/main/admin/stack_upgrade/upgrade_wizard_view_test.js b/ambari-web/test/views/main/admin/stack_upgrade/upgrade_wizard_view_test.js index bc50a51..a9fdfed 100644 --- a/ambari-web/test/views/main/admin/stack_upgrade/upgrade_wizard_view_test.js +++ b/ambari-web/test/views/main/admin/stack_upgrade/upgrade_wizard_view_test.js @@ -37,6 +37,8 @@ describe('App.upgradeWizardView', function () { }); view.removeObserver('App.clusterName', view, 'startPolling'); + App.TestAliases.testAsComputedEqualProperties(view, 'isFinalizeItem', 'manualItem.context', 'controller.finalizeContext'); + describe("#upgradeGroups", function () { it("upgradeGroups is null", function () { view.set('controller.upgradeData.upgradeGroups', null); @@ -434,18 +436,6 @@ describe('App.upgradeWizardView', function () { }); }); - describe("#isFinalizeItem", function () { - it("depends of manualItem.context", function () { - view.reopen({ - manualItem: { - context: 'Confirm Finalize' - } - }); - view.propertyDidChange('isFinalizeItem'); - expect(view.get('isFinalizeItem')).to.be.true; - }); - }); - describe("#toggleDetails()", function () { before(function () { sinon.stub(view, 'toggleProperty', Em.K); http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/views/main/alert_definitions_view_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/main/alert_definitions_view_test.js b/ambari-web/test/views/main/alert_definitions_view_test.js index ad62856..66d1188 100644 --- a/ambari-web/test/views/main/alert_definitions_view_test.js +++ b/ambari-web/test/views/main/alert_definitions_view_test.js @@ -22,10 +22,14 @@ require('views/main/alert_definitions_view'); var view; +function getView() { + return App.MainAlertDefinitionsView.create({}); +} + describe('App.MainAlertDefinitionsView', function () { beforeEach(function () { - view = App.MainAlertDefinitionsView.create({}); + view = getView(); sinon.stub(App.db, 'setFilterConditions', Em.K); sinon.stub(App.db, 'getFilterConditions', Em.K); sinon.stub(App.db, 'getDisplayLength', Em.K); @@ -41,6 +45,8 @@ describe('App.MainAlertDefinitionsView', function () { view.initFilters.restore(); }); + App.TestAliases.testAsComputedAlias(getView(), 'totalCount', 'content.length', 'number'); + describe('#serviceFilterView', function () { it('Add Ambari service to filters', function () { var serviceFilterClass = view.serviceFilterView; http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/views/main/alerts/manage_alert_groups_view_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/main/alerts/manage_alert_groups_view_test.js b/ambari-web/test/views/main/alerts/manage_alert_groups_view_test.js index 645856a..3c91949 100644 --- a/ambari-web/test/views/main/alerts/manage_alert_groups_view_test.js +++ b/ambari-web/test/views/main/alerts/manage_alert_groups_view_test.js @@ -20,14 +20,16 @@ var App = require('app'); var view; +function getView() { + return App.MainAlertsManageAlertGroupView.create({ + controller: Em.Object.create() + }); +} + describe('App.MainAlertsManageAlertGroupView', function () { beforeEach(function () { - - view = App.MainAlertsManageAlertGroupView.create({ - controller: Em.Object.create() - }); - + view = getView(); }); it('#buttonObserver', function () { @@ -89,4 +91,6 @@ describe('App.MainAlertsManageAlertGroupView', function () { }); + App.TestAliases.testAsComputedIfThenElse(getView(), 'removeButtonTooltip', 'controller.isRemoveButtonDisabled', Em.I18n.t('alerts.actions.manage_alert_groups_popup.removeButtonDisabled'), Em.I18n.t('alerts.actions.manage_alert_groups_popup.removeButton')) + }); http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/views/main/dashboard/widgets/hbase_average_load_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/main/dashboard/widgets/hbase_average_load_test.js b/ambari-web/test/views/main/dashboard/widgets/hbase_average_load_test.js index 932ff87..6fc484f 100644 --- a/ambari-web/test/views/main/dashboard/widgets/hbase_average_load_test.js +++ b/ambari-web/test/views/main/dashboard/widgets/hbase_average_load_test.js @@ -23,6 +23,10 @@ require('views/main/dashboard/widgets/hbase_average_load'); require('views/main/dashboard/widgets/text_widget'); require('views/main/dashboard/widget'); +function getView() { + return App.HBaseAverageLoadView.create({model_type: null}); +} + describe('App.HBaseAverageLoadView', function() { var tests = [ @@ -100,4 +104,10 @@ describe('App.HBaseAverageLoadView', function() { }); }); + App.TestAliases.testAsComputedAlias(getView(), 'data', 'model.averageLoad', 'number'); + + App.TestAliases.testAsComputedGtProperties(getView(), 'isRed', 'data', 'thresh2'); + + App.TestAliases.testAsComputedLteProperties(getView(), 'isGreen', 'data', 'thresh1'); + }); http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/views/main/dashboard/widgets/hbase_regions_in_transition_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/main/dashboard/widgets/hbase_regions_in_transition_test.js b/ambari-web/test/views/main/dashboard/widgets/hbase_regions_in_transition_test.js index 80a292b..3615ccc 100644 --- a/ambari-web/test/views/main/dashboard/widgets/hbase_regions_in_transition_test.js +++ b/ambari-web/test/views/main/dashboard/widgets/hbase_regions_in_transition_test.js @@ -22,6 +22,10 @@ require('views/main/dashboard/widgets/hbase_regions_in_transition'); require('views/main/dashboard/widgets/text_widget'); require('views/main/dashboard/widget'); +function getView() { + return App.HBaseRegionsInTransitionView.create({model_type:null}); +} + describe('App.HBaseRegionsInTransitionView', function() { var tests = [ @@ -99,4 +103,10 @@ describe('App.HBaseRegionsInTransitionView', function() { }); }); + App.TestAliases.testAsComputedAlias(getView(), 'data', 'model.regionsInTransition', 'number'); + + App.TestAliases.testAsComputedGtProperties(getView(), 'isRed', 'data', 'thresh2'); + + App.TestAliases.testAsComputedLteProperties(getView(), 'isGreen', 'data', 'thresh1'); + }); http://git-wip-us.apache.org/repos/asf/ambari/blob/43306594/ambari-web/test/views/main/dashboard/widgets/namenode_rpc_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/main/dashboard/widgets/namenode_rpc_test.js b/ambari-web/test/views/main/dashboard/widgets/namenode_rpc_test.js index 992b537..96cafc4 100644 --- a/ambari-web/test/views/main/dashboard/widgets/namenode_rpc_test.js +++ b/ambari-web/test/views/main/dashboard/widgets/namenode_rpc_test.js @@ -23,6 +23,10 @@ require('views/main/dashboard/widgets/namenode_rpc'); require('views/main/dashboard/widgets/text_widget'); require('views/main/dashboard/widget'); +function getView() { + return App.NameNodeRpcView.create({model_type:null}); +} + describe('App.NameNodeRpcView', function() { var tests = [ @@ -104,4 +108,8 @@ describe('App.NameNodeRpcView', function() { }); }); + App.TestAliases.testAsComputedGtProperties(getView(), 'isRed', 'data', 'thresh2'); + + App.TestAliases.testAsComputedLteProperties(getView(), 'isGreen', 'data', 'thresh1'); + });