You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by at...@apache.org on 2015/09/04 16:37:42 UTC
ambari git commit: AMBARI-13010 Fix UI unit tests. (atkach)
Repository: ambari
Updated Branches:
refs/heads/trunk cc93d351e -> cb3dd00b3
AMBARI-13010 Fix UI unit tests. (atkach)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/cb3dd00b
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/cb3dd00b
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/cb3dd00b
Branch: refs/heads/trunk
Commit: cb3dd00b3f9bb6c5dba33ae27795eab19d419b46
Parents: cc93d35
Author: Andrii Tkach <at...@hortonworks.com>
Authored: Fri Sep 4 17:37:25 2015 +0300
Committer: Andrii Tkach <at...@hortonworks.com>
Committed: Fri Sep 4 17:37:25 2015 +0300
----------------------------------------------------------------------
ambari-web/app/assets/test/tests.js | 7 +-
ambari-web/app/controllers/main/host/details.js | 16 ++--
.../app/controllers/wizard/step8_controller.js | 1 -
ambari-web/app/templates/wizard/step3.hbs | 5 +-
.../stack_upgrade/upgrade_version_box_view.js | 9 +--
ambari-web/app/views/wizard/step3_view.js | 8 --
ambari-web/app/views/wizard/step5_view.js | 2 +-
.../add_alert_definition_controller_test.js | 63 +++++++++++++++
.../test/controllers/main/host/details_test.js | 83 +++++++++++++-------
.../main/service/add_controller_test.js | 28 ++++---
.../service/reassign/step4_controller_test.js | 5 +-
ambari-web/test/init_test.js | 50 ++++++++++++
.../test/mixins/wizard/wizardEnableDone_test.js | 5 +-
.../admin/stack_upgrade/version_view_test.js | 2 +-
.../test/views/wizard/step10_view_test.js | 17 +++-
ambari-web/test/views/wizard/step4_view_test.js | 42 ++++++++++
ambari-web/test/views/wizard/step5_view_test.js | 59 ++++++++++++++
ambari-web/test/views/wizard/step6_view_test.js | 38 ++++++++-
ambari-web/test/views/wizard/step7_view_test.js | 45 +++++++++++
19 files changed, 411 insertions(+), 74 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/cb3dd00b/ambari-web/app/assets/test/tests.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/assets/test/tests.js b/ambari-web/app/assets/test/tests.js
index d5f4450..64ddb30 100644
--- a/ambari-web/app/assets/test/tests.js
+++ b/ambari-web/app/assets/test/tests.js
@@ -35,7 +35,9 @@ require('mappers');
require('utils/ajax/ajax');
require('utils/ajax/ajax_queue');
-var files = ['test/init_model_test',
+var files = [
+ 'test/init_test',
+ 'test/init_model_test',
'test/app_test',
'test/data/HDP2/secure_mapping_test',
'test/controllers/global/background_operations_test',
@@ -47,6 +49,7 @@ var files = ['test/init_model_test',
'test/controllers/main/alerts/definitions_configs_controller_test',
'test/controllers/main/alerts/definitions_details_controller_test',
'test/controllers/main/alerts/alert_instances_controller_test',
+ 'test/controllers/main/alerts/add_alert_definition/add_alert_definition_controller_test',
'test/controllers/main/alerts/add_alert_definition/step1_controller_test',
'test/controllers/main/alerts/manage_alert_notifications_controller_test',
'test/controllers/main/admin/kerberos_test',
@@ -262,8 +265,10 @@ var files = ['test/init_model_test',
'test/views/wizard/step1_view_test',
'test/views/wizard/step2_view_test',
'test/views/wizard/step3_view_test',
+ 'test/views/wizard/step4_view_test',
'test/views/wizard/step5_view_test',
'test/views/wizard/step6_view_test',
+ 'test/views/wizard/step7_view_test',
'test/views/wizard/step8_view_test',
'test/views/wizard/step9_view_test',
'test/views/wizard/step9/hostLogPopupBody_view_test',
http://git-wip-us.apache.org/repos/asf/ambari/blob/cb3dd00b/ambari-web/app/controllers/main/host/details.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/host/details.js b/ambari-web/app/controllers/main/host/details.js
index 20d5a67..bd3195f 100644
--- a/ambari-web/app/controllers/main/host/details.js
+++ b/ambari-web/app/controllers/main/host/details.js
@@ -1915,8 +1915,8 @@ App.MainHostDetailsController = Em.Controller.extend({
doStartAllComponents: function () {
var self = this;
var components = this.get('serviceNonClientActiveComponents');
- var componentsLength = Em.isNone(components) ? 0 : components.get('length');
- if (componentsLength > 0) {
+
+ if (components && components.get('length')) {
return App.showConfirmationPopup(function () {
self.sendComponentCommand(components, Em.I18n.t('hosts.host.maintainance.startAllComponents.context'), App.HostComponentStatus.started);
});
@@ -1930,12 +1930,12 @@ App.MainHostDetailsController = Em.Controller.extend({
doStopAllComponents: function () {
var self = this;
var components = this.get('serviceNonClientActiveComponents');
- var componentsLength = Em.isNone(components) ? 0 : components.get('length');
- if (componentsLength > 0) {
+
+ if (components && components.get('length')) {
if (components.someProperty('componentName', 'NAMENODE') &&
this.get('content.hostComponents').filterProperty('componentName', 'NAMENODE').someProperty('workStatus', App.HostComponentStatus.started)) {
this.checkNnLastCheckpointTime(function () {
- return App.showConfirmationPopup(function () {
+ App.showConfirmationPopup(function () {
self.sendComponentCommand(components, Em.I18n.t('hosts.host.maintainance.stopAllComponents.context'), App.HostComponentStatus.stopped);
});
});
@@ -1954,12 +1954,12 @@ App.MainHostDetailsController = Em.Controller.extend({
doRestartAllComponents: function () {
var self = this;
var components = this.get('serviceActiveComponents');
- var componentsLength = Em.isNone(components) ? 0 : components.get('length');
- if (componentsLength > 0) {
+
+ if (components && components.get('length')) {
if (components.someProperty('componentName', 'NAMENODE') &&
this.get('content.hostComponents').filterProperty('componentName', 'NAMENODE').someProperty('workStatus', App.HostComponentStatus.started)) {
this.checkNnLastCheckpointTime(function () {
- return App.showConfirmationPopup(function () {
+ App.showConfirmationPopup(function () {
batchUtils.restartHostComponents(components, Em.I18n.t('rollingrestart.context.allOnSelectedHost').format(self.get('content.hostName')), "HOST");
});
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/cb3dd00b/ambari-web/app/controllers/wizard/step8_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step8_controller.js b/ambari-web/app/controllers/wizard/step8_controller.js
index d03fe1b..729471a 100644
--- a/ambari-web/app/controllers/wizard/step8_controller.js
+++ b/ambari-web/app/controllers/wizard/step8_controller.js
@@ -1531,7 +1531,6 @@ App.WizardStep8Controller = Em.Controller.extend(App.AddSecurityConfigs, App.wiz
var clusterName = this.get('clusterName');
var sendData = [];
var updateData = [];
- var serviceConfigController = App.router.get('mainServiceInfoConfigsController');
var timeTag = (new Date).getTime();
var groupsToDelete = App.router.get(this.get('content.controllerName')).getDBProperty('groupsToDelete');
if (groupsToDelete && groupsToDelete.length > 0) {
http://git-wip-us.apache.org/repos/asf/ambari/blob/cb3dd00b/ambari-web/app/templates/wizard/step3.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/wizard/step3.hbs b/ambari-web/app/templates/wizard/step3.hbs
index b34c64d..f345b87 100644
--- a/ambari-web/app/templates/wizard/step3.hbs
+++ b/ambari-web/app/templates/wizard/step3.hbs
@@ -95,9 +95,6 @@
<td class="step3-table-action">
<a class="btn btn-mini" {{action remove target="view"}}{{bindAttr disabled="isBackDisabled"}}><i class="icon-trash"></i>
{{t common.remove}}</a>
- {{#if view.isRetryable}}<a class="btn btn-mini" {{action retry target="view"}}><i
- class="icon-repeat"></i>
- {{t common.retry}}</a>{{/if}}
</td>
{{/view}}
{{/each}}
@@ -152,4 +149,4 @@
<button class="btn pull-left installer-back-btn" {{bindAttr disabled="isBackDisabled"}} {{action back}}>← {{t common.back}}</button>
<button class="btn btn-success pull-right" {{bindAttr disabled="isSubmitDisabled"}} {{action submit target="controller"}}>{{t common.next}} →</button>
</div>
-</div>
\ No newline at end of file
+</div>
http://git-wip-us.apache.org/repos/asf/ambari/blob/cb3dd00b/ambari-web/app/views/main/admin/stack_upgrade/upgrade_version_box_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/admin/stack_upgrade/upgrade_version_box_view.js b/ambari-web/app/views/main/admin/stack_upgrade/upgrade_version_box_view.js
index 178a542..f4950c3 100644
--- a/ambari-web/app/views/main/admin/stack_upgrade/upgrade_version_box_view.js
+++ b/ambari-web/app/views/main/admin/stack_upgrade/upgrade_version_box_view.js
@@ -201,12 +201,11 @@ App.UpgradeVersionBoxView = Em.View.extend({
getStackVersionNumber: function(repository){
var stackVersion = null;
var systems = repository.get('operatingSystems');
-
- systems.forEach(function(os){
- repos = os.get('repositories');
- repos.forEach(function(repo){
+
+ systems.forEach(function (os) {
+ os.get('repositories').forEach(function (repo) {
stackVersion = repo.get('stackVersion');
- if(null != stackVersion)
+ if (null != stackVersion)
return stackVersion;
});
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/cb3dd00b/ambari-web/app/views/wizard/step3_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/wizard/step3_view.js b/ambari-web/app/views/wizard/step3_view.js
index 4f44c11..6ecfb41 100644
--- a/ambari-web/app/views/wizard/step3_view.js
+++ b/ambari-web/app/views/wizard/step3_view.js
@@ -324,14 +324,6 @@ App.WizardHostView = Em.View.extend({
hostInfo: null,
/**
- * @type {bool}
- */
- isRetryable: function() {
- // return ['FAILED'].contains(this.get('hostInfo.bootStatus'));
- return false;
- }.property('hostInfo.bootStatus'),
-
- /**
* Remove selected host
* @method remove
*/
http://git-wip-us.apache.org/repos/asf/ambari/blob/cb3dd00b/ambari-web/app/views/wizard/step5_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/wizard/step5_view.js b/ambari-web/app/views/wizard/step5_view.js
index be42c66..d20f874 100644
--- a/ambari-web/app/views/wizard/step5_view.js
+++ b/ambari-web/app/views/wizard/step5_view.js
@@ -22,7 +22,7 @@ var stringUtils = require('utils/string_utils');
App.WizardStep5View = App.AssignMasterComponentsView.extend({
title: function () {
- if (this.get('controller.content.controllerName') == 'reassignMasterController') {
+ if (this.get('controller.content.controllerName') === 'reassignMasterController') {
return Em.I18n.t('installer.step5.reassign.header');
}
return Em.I18n.t('installer.step5.header');
http://git-wip-us.apache.org/repos/asf/ambari/blob/cb3dd00b/ambari-web/test/controllers/main/alerts/add_alert_definition/add_alert_definition_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/alerts/add_alert_definition/add_alert_definition_controller_test.js b/ambari-web/test/controllers/main/alerts/add_alert_definition/add_alert_definition_controller_test.js
new file mode 100644
index 0000000..2e0208e
--- /dev/null
+++ b/ambari-web/test/controllers/main/alerts/add_alert_definition/add_alert_definition_controller_test.js
@@ -0,0 +1,63 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var App = require('app');
+require('controllers/main/alerts/add_alert_definition/add_alert_definition_controller');
+
+var controller;
+
+describe('App.AddAlertDefinitionController', function () {
+
+ beforeEach(function () {
+ controller = App.AddAlertDefinitionController.create();
+ });
+
+ describe("#createNewAlertDefinition()", function () {
+ beforeEach(function () {
+ sinon.stub(App.ajax, 'send', Em.K);
+ });
+ afterEach(function () {
+ App.ajax.send.restore();
+ });
+
+ it("", function () {
+ controller.createNewAlertDefinition('data');
+ expect(App.ajax.send.getCall(0).args[0]).to.eql({
+ name: 'alerts.create_alert_definition',
+ sender: controller,
+ data: {
+ data: 'data'
+ }
+ });
+ });
+ });
+
+ describe("#finish()", function () {
+ beforeEach(function () {
+ sinon.stub(controller, 'clear', Em.K);
+ });
+ afterEach(function () {
+ controller.clear.restore();
+ });
+
+ it("", function () {
+ controller.finish();
+ expect(controller.clear.calledOnce).to.be.true;
+ });
+ });
+});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/cb3dd00b/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 7ddb2dd..0841934 100644
--- a/ambari-web/test/controllers/main/host/details_test.js
+++ b/ambari-web/test/controllers/main/host/details_test.js
@@ -36,7 +36,9 @@ describe('App.MainHostDetailsController', function () {
complete: Em.K
});
controller = App.MainHostDetailsController.create({
- content: Em.Object.create()
+ content: Em.Object.create({
+ hostComponents: []
+ })
});
});
afterEach(function () {
@@ -1472,48 +1474,47 @@ describe('App.MainHostDetailsController', function () {
beforeEach(function () {
sinon.spy(App, "showConfirmationPopup");
- controller.reopen({serviceActiveComponents: []});
+ sinon.stub(controller, 'sendComponentCommand', Em.K);
});
afterEach(function () {
App.showConfirmationPopup.restore();
+ controller.sendComponentCommand.restore();
});
it('serviceNonClientActiveComponents is empty', function () {
controller.reopen({
- serviceNonClientActiveComponents: []
+ serviceNonClientActiveComponents: Em.A([])
});
controller.doStartAllComponents();
expect(App.showConfirmationPopup.called).to.be.false;
});
it('serviceNonClientActiveComponents is correct', function () {
controller.reopen({
- serviceNonClientActiveComponents: [
- {}
- ]
+ serviceNonClientActiveComponents: Em.A([{}])
});
- sinon.stub(controller, 'sendComponentCommand', Em.K);
var popup = controller.doStartAllComponents();
expect(App.showConfirmationPopup.calledOnce).to.be.true;
popup.onPrimary();
expect(controller.sendComponentCommand.calledWith(
- [
- {}
- ],
+ controller.get('serviceNonClientActiveComponents'),
Em.I18n.t('hosts.host.maintainance.startAllComponents.context'),
App.HostComponentStatus.started)
).to.be.true;
- controller.sendComponentCommand.restore();
});
});
describe('#doStopAllComponents()', function () {
-
beforeEach(function () {
sinon.spy(App, "showConfirmationPopup");
- controller.reopen({serviceActiveComponents: []});
+ sinon.stub(controller, 'sendComponentCommand', Em.K);
+ sinon.stub(controller, 'checkNnLastCheckpointTime', function(callback){
+ callback();
+ });
});
afterEach(function () {
App.showConfirmationPopup.restore();
+ controller.sendComponentCommand.restore();
+ controller.checkNnLastCheckpointTime.restore();
});
it('serviceNonClientActiveComponents is empty', function () {
@@ -1526,22 +1527,32 @@ describe('App.MainHostDetailsController', function () {
it('serviceNonClientActiveComponents is correct', function () {
controller.reopen({
- serviceNonClientActiveComponents: [
- {}
- ]
+ serviceNonClientActiveComponents: Em.A([{}])
});
- sinon.stub(controller, 'sendComponentCommand', Em.K);
+
var popup = controller.doStopAllComponents();
expect(App.showConfirmationPopup.calledOnce).to.be.true;
popup.onPrimary();
expect(controller.sendComponentCommand.calledWith(
- [
- {}
- ],
+ controller.get('serviceNonClientActiveComponents'),
Em.I18n.t('hosts.host.maintainance.stopAllComponents.context'),
App.HostComponentStatus.stopped)
).to.be.true;
- controller.sendComponentCommand.restore();
+ });
+ it('serviceNonClientActiveComponents is correct, NAMENODE started', function () {
+ controller.reopen({
+ serviceNonClientActiveComponents: Em.A([Em.Object.create({
+ componentName: 'NAMENODE',
+ workStatus: 'STARTED'
+ })])
+ });
+ controller.set('content.hostComponents', [Em.Object.create({
+ componentName: 'NAMENODE',
+ workStatus: 'STARTED'
+ })]);
+ controller.doStopAllComponents();
+ expect(controller.checkNnLastCheckpointTime.calledOnce).to.be.true;
+ expect(App.showConfirmationPopup.calledOnce).to.be.true;
});
});
@@ -1549,9 +1560,15 @@ describe('App.MainHostDetailsController', function () {
beforeEach(function () {
sinon.spy(App, "showConfirmationPopup");
+ sinon.stub(batchUtils, 'restartHostComponents', Em.K);
+ sinon.stub(controller, 'checkNnLastCheckpointTime', function(callback){
+ callback();
+ });
});
afterEach(function () {
App.showConfirmationPopup.restore();
+ batchUtils.restartHostComponents.restore();
+ controller.checkNnLastCheckpointTime.restore();
});
it('serviceActiveComponents is empty', function () {
@@ -1568,7 +1585,6 @@ describe('App.MainHostDetailsController', function () {
{}
]
});
- sinon.stub(batchUtils, 'restartHostComponents', Em.K);
var popup = controller.doRestartAllComponents();
expect(App.showConfirmationPopup.calledOnce).to.be.true;
@@ -1578,8 +1594,21 @@ describe('App.MainHostDetailsController', function () {
{}
])
).to.be.true;
- batchUtils.restartHostComponents.restore();
-
+ });
+ it('serviceActiveComponents is correct, NAMENODE started', function () {
+ controller.reopen({
+ serviceActiveComponents: Em.A([Em.Object.create({
+ componentName: 'NAMENODE',
+ workStatus: 'STARTED'
+ })])
+ });
+ controller.set('content.hostComponents', [Em.Object.create({
+ componentName: 'NAMENODE',
+ workStatus: 'STARTED'
+ })]);
+ controller.doRestartAllComponents();
+ expect(controller.checkNnLastCheckpointTime.calledOnce).to.be.true;
+ expect(App.showConfirmationPopup.calledOnce).to.be.true;
});
});
@@ -1970,16 +1999,16 @@ describe('App.MainHostDetailsController', function () {
});
it('No components', function () {
- var event = {context: []};
+ var event = {context: Em.A([])};
controller.refreshConfigs(event);
expect(App.showConfirmationPopup.called).to.be.false;
});
it('Some components present', function () {
- var event = {context: [Em.Object.create()]};
+ var event = {context: Em.A([Em.Object.create()])};
var popup = controller.refreshConfigs(event);
expect(App.showConfirmationPopup.calledOnce).to.be.true;
popup.onPrimary();
- expect(batchUtils.restartHostComponents.calledWith([Em.Object.create()])).to.be.true;
+ expect(batchUtils.restartHostComponents.calledWith(event.context)).to.be.true;
});
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/cb3dd00b/ambari-web/test/controllers/main/service/add_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/service/add_controller_test.js b/ambari-web/test/controllers/main/service/add_controller_test.js
index 68a6cf7..58f930f 100644
--- a/ambari-web/test/controllers/main/service/add_controller_test.js
+++ b/ambari-web/test/controllers/main/service/add_controller_test.js
@@ -341,18 +341,24 @@ describe('App.AddServiceController', function() {
});
describe('#loadServices', function() {
+ var mock = {
+ db: {}
+ };
beforeEach(function() {
this.controller = App.AddServiceController.create({});
- this.db = {};
- sinon.stub(this.controller, 'getDBProperty');
+ this.mockGetDBProperty = sinon.stub(this.controller, 'getDBProperty');
sinon.stub(this.controller, 'setDBProperty', function(key, value) {
- this.db = value;
- }.bind(this));
+ mock.db = value;
+ });
+ this.mockStackService = sinon.stub(App.StackService, 'find');
+ this.mockService = sinon.stub(App.Service, 'find');
});
afterEach(function() {
- this.controller.getDBProperty.restore();
+ this.mockGetDBProperty.restore();
this.controller.setDBProperty.restore();
+ this.mockStackService.restore();
+ this.mockService.restore();
});
var tests = [
@@ -402,17 +408,15 @@ describe('App.AddServiceController', function() {
tests.forEach(function(test) {
it(test.m, function() {
- sinon.stub(App.StackService, 'find').returns(test.appStackService);
- sinon.stub(App.Service, 'find').returns(test.appService);
- this.controller.getDBProperty.withArgs('services').returns(test.servicesFromDB);
+ this.mockStackService.returns(test.appStackService);
+ this.mockService.returns(test.appService);
+ this.mockGetDBProperty.withArgs('services').returns(test.servicesFromDB);
this.controller.set('serviceToInstall', test.serviceToInstall);
this.controller.loadServices();
- App.StackService.find.restore();
- App.Service.find.restore();
if (!test.servicesFromDB) {
// verify saving to local db on first enter to the wizard
- expect(this.db.selectedServices).to.be.eql(test.e.selectedServices);
- expect(this.db.installedServices).to.be.eql(test.e.installedServices);
+ expect(mock.db.selectedServices).to.be.eql(test.e.selectedServices);
+ expect(mock.db.installedServices).to.be.eql(test.e.installedServices);
} else {
// verify values for App.StackService
expect(test.appStackService.filterProperty('isSelected', true).mapProperty('serviceName')).to.be.eql(test.e.selectedServices);
http://git-wip-us.apache.org/repos/asf/ambari/blob/cb3dd00b/ambari-web/test/controllers/main/service/reassign/step4_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/service/reassign/step4_controller_test.js b/ambari-web/test/controllers/main/service/reassign/step4_controller_test.js
index 7a7b576..b38c67e 100644
--- a/ambari-web/test/controllers/main/service/reassign/step4_controller_test.js
+++ b/ambari-web/test/controllers/main/service/reassign/step4_controller_test.js
@@ -1057,7 +1057,10 @@ describe('App.ReassignMasterWizardStep4Controller', function () {
}]);
controller.set('content.reassignHosts.source', 'host2');
controller.startNameNode();
- expect(controller.updateComponent.calledWith('NAMENODE', ['host1'], 'HDFS', 'Start')).to.be.true;
+ expect(controller.updateComponent.getCall(0).args[1][0]).to.equal('host1');
+ expect(controller.updateComponent.getCall(0).args[0]).to.equal('NAMENODE');
+ expect(controller.updateComponent.getCall(0).args[2]).to.equal('HDFS');
+ expect(controller.updateComponent.getCall(0).args[3]).to.equal('Start');
});
it('reassign host matches current', function () {
controller.set('content.masterComponentHosts', [{
http://git-wip-us.apache.org/repos/asf/ambari/blob/cb3dd00b/ambari-web/test/init_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/init_test.js b/ambari-web/test/init_test.js
new file mode 100644
index 0000000..5a4b223
--- /dev/null
+++ b/ambari-web/test/init_test.js
@@ -0,0 +1,50 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//
+/**
+ * Function.prototype.bind is not available in PhantomJS
+ * Polyfill used instead: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind
+ */
+if (!Function.prototype.bind) {
+ Function.prototype.bind = function(oThis) {
+ if (typeof this !== 'function') {
+ // closest thing possible to the ECMAScript 5
+ // internal IsCallable function
+ throw new TypeError('Function.prototype.bind - what is trying to be bound is not callable');
+ }
+
+ var aArgs = Array.prototype.slice.call(arguments, 1),
+ fToBind = this,
+ fNOP = function() {},
+ fBound = function() {
+ return fToBind.apply(this instanceof fNOP
+ ? this
+ : oThis,
+ aArgs.concat(Array.prototype.slice.call(arguments)));
+ };
+
+ if (this.prototype) {
+ // native functions don't have a prototype
+ fNOP.prototype = this.prototype;
+ }
+ fBound.prototype = new fNOP();
+
+ return fBound;
+ };
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/cb3dd00b/ambari-web/test/mixins/wizard/wizardEnableDone_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/mixins/wizard/wizardEnableDone_test.js b/ambari-web/test/mixins/wizard/wizardEnableDone_test.js
index 801a516..fafae36 100644
--- a/ambari-web/test/mixins/wizard/wizardEnableDone_test.js
+++ b/ambari-web/test/mixins/wizard/wizardEnableDone_test.js
@@ -24,7 +24,8 @@ describe('App.WizardEnableDone', function () {
isSubmitDisabled: true
}
}),
- mixedObject = baseObject.extend(App.WizardEnableDone);
+ mixedObject = baseObject.extend(App.WizardEnableDone),
+ mixedObjectInstance;
beforeEach(function () {
mixedObjectInstance = mixedObject.create({
tasks: [{id: 77, status: 'FAILED'}],
@@ -36,4 +37,4 @@ describe('App.WizardEnableDone', function () {
mixedObjectInstance.statusChangeCallback();
expect(mixedObjectInstance.isSubmitDisabled).to.be.false;
});
-});
\ No newline at end of file
+});
http://git-wip-us.apache.org/repos/asf/ambari/blob/cb3dd00b/ambari-web/test/views/main/admin/stack_upgrade/version_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/admin/stack_upgrade/version_view_test.js b/ambari-web/test/views/main/admin/stack_upgrade/version_view_test.js
index 887b25c..930af95 100644
--- a/ambari-web/test/views/main/admin/stack_upgrade/version_view_test.js
+++ b/ambari-web/test/views/main/admin/stack_upgrade/version_view_test.js
@@ -303,7 +303,7 @@ describe('App.mainAdminStackVersionsView', function () {
describe("#goToVersions()", function() {
before(function () {
- sinon.spy(App, 'showConfirmationPopup', Em.K);
+ sinon.spy(App, 'showConfirmationPopup');
sinon.stub(window.location, 'replace', Em.K);
var data = {
components: [{
http://git-wip-us.apache.org/repos/asf/ambari/blob/cb3dd00b/ambari-web/test/views/wizard/step10_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/wizard/step10_view_test.js b/ambari-web/test/views/wizard/step10_view_test.js
index 913e255..c101613 100644
--- a/ambari-web/test/views/wizard/step10_view_test.js
+++ b/ambari-web/test/views/wizard/step10_view_test.js
@@ -22,10 +22,12 @@ var view;
describe('App.WizardStep10View', function() {
beforeEach(function() {
view = App.WizardStep10View.create({
- controller: App.WizardStep10Controller.create()
+ controller: App.WizardStep10Controller.create({
+ isAddServiceWizard: false
+ })
});
});
- describe('didInsertElement', function() {
+ describe('#didInsertElement()', function() {
it('should call loadStep', function() {
sinon.stub(view.get('controller'), 'loadStep', Em.K);
view.didInsertElement();
@@ -33,4 +35,15 @@ describe('App.WizardStep10View', function() {
view.get('controller').loadStep.restore();
});
});
+
+ describe("#serviceRestartText", function() {
+ it("text is empty", function() {
+ view.set('controller.isAddServiceWizard', false);
+ expect(view.get('serviceRestartText')).to.be.empty;
+ });
+ it("text is complete", function() {
+ view.set('controller.isAddServiceWizard', true);
+ expect(view.get('serviceRestartText')).to.equal(Em.I18n.t('common.important') + Em.I18n.t('installer.step10.staleServicesRestartRequired'));
+ });
+ });
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/cb3dd00b/ambari-web/test/views/wizard/step4_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/wizard/step4_view_test.js b/ambari-web/test/views/wizard/step4_view_test.js
new file mode 100644
index 0000000..94f9830
--- /dev/null
+++ b/ambari-web/test/views/wizard/step4_view_test.js
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var App = require('app');
+require('views/wizard/step4_view');
+
+var view;
+
+describe('App.WizardStep4View', function () {
+
+ beforeEach(function () {
+ view = App.WizardStep4View.create();
+ });
+
+ describe('#didInsertElement()', function () {
+ beforeEach(function () {
+ sinon.stub(App.get('router'), 'set', Em.K);
+ });
+ afterEach(function () {
+ App.get('router').set.restore();
+ });
+ it('', function () {
+ view.didInsertElement();
+ expect(App.get('router').set.calledWith('transitionInProgress', false)).to.be.true;
+ });
+ });
+});
http://git-wip-us.apache.org/repos/asf/ambari/blob/cb3dd00b/ambari-web/test/views/wizard/step5_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/wizard/step5_view_test.js b/ambari-web/test/views/wizard/step5_view_test.js
index 74dc033..be01771 100644
--- a/ambari-web/test/views/wizard/step5_view_test.js
+++ b/ambari-web/test/views/wizard/step5_view_test.js
@@ -19,6 +19,7 @@
var App = require('app');
require('views/wizard/step5_view');
+var stringUtils = require('utils/string_utils');
var view;
describe('App.WizardStep5View', function() {
@@ -29,6 +30,64 @@ describe('App.WizardStep5View', function() {
});
});
+ describe("#title", function() {
+ beforeEach(function () {
+ view.set('controller.content', Em.Object.create());
+ });
+
+ it("controller name is reassignMasterController", function() {
+ view.set('controller.content.controllerName', 'reassignMasterController');
+ view.propertyDidChange('title');
+ expect(view.get('title')).to.equal(Em.I18n.t('installer.step5.reassign.header'));
+ });
+ it("controller name is ''", function() {
+ view.set('controller.content.controllerName', '');
+ view.propertyDidChange('title');
+ expect(view.get('title')).to.equal(Em.I18n.t('installer.step5.header'));
+ });
+ });
+
+ describe("#setCoHostedComponentText()", function () {
+ beforeEach(function () {
+ sinon.stub(App.StackServiceComponent, 'find').returns([
+ Em.Object.create({
+ componentName: 'C1',
+ displayName: 'c1',
+ isOtherComponentCoHosted: true,
+ stackService: {
+ isSelected: true
+ },
+ coHostedComponents: ['C2']
+ }),
+ Em.Object.create({
+ componentName: 'C2',
+ displayName: 'c2',
+ isOtherComponentCoHosted: false,
+ stackService: {
+ isSelected: true
+ }
+ })
+ ]);
+ sinon.stub(stringUtils, 'getFormattedStringFromArray', function(str){
+ return str;
+ });
+ });
+ afterEach(function () {
+ App.StackServiceComponent.find.restore();
+ stringUtils.getFormattedStringFromArray.restore();
+ });
+ it("isReassignWizard - true", function () {
+ view.set('controller.isReassignWizard', true);
+ view.setCoHostedComponentText();
+ expect(view.get('coHostedComponentText')).to.be.empty;
+ });
+ it("isReassignWizard - false", function () {
+ view.set('controller.isReassignWizard', false);
+ view.setCoHostedComponentText();
+ expect(view.get('coHostedComponentText')).to.equal('<br/>' + Em.I18n.t('installer.step5.body.coHostedComponents').format(['c1', 'c2']));
+ });
+ });
+
describe('#didInsertElement', function() {
it('should call controller.loadStep', function() {
sinon.stub(view.get('controller'), 'loadStep', Em.K);
http://git-wip-us.apache.org/repos/asf/ambari/blob/cb3dd00b/ambari-web/test/views/wizard/step6_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/wizard/step6_view_test.js b/ambari-web/test/views/wizard/step6_view_test.js
index b905a2d..199c24e 100644
--- a/ambari-web/test/views/wizard/step6_view_test.js
+++ b/ambari-web/test/views/wizard/step6_view_test.js
@@ -113,6 +113,42 @@ describe('App.WizardStep6View', function() {
});
});
+ describe("#checkboxClick()", function() {
+ beforeEach(function() {
+ sinon.stub(view.get('controller'), 'checkCallback', Em.K);
+ sinon.stub(view.get('controller'), 'callValidation', Em.K);
+ });
+ afterEach(function() {
+ view.get('controller').checkCallback.restore();
+ view.get('controller').callValidation.restore();
+ });
+
+ it("", function() {
+ var e = {context: {
+ checked: true,
+ component: 'c1'
+ }};
+ view.checkboxClick(e);
+ expect(e.context.checked).to.be.false;
+ expect(view.get('controller').checkCallback.calledWith('c1')).to.be.true;
+ expect(view.get('controller').callValidation.calledOnce).to.be.true;
+ });
+ });
+
+ describe("#columnCount", function() {
+ it("hosts present", function() {
+ view.set('controller.hosts', [
+ Em.Object.create({checkboxes: [{}, {}, {}]})
+ ]);
+ view.propertyDidChange('columnCount');
+ expect(view.get('columnCount')).to.equal(4);
+ });
+ it("hosts absent", function() {
+ view.set('controller.hosts', []);
+ view.propertyDidChange('columnCount');
+ expect(view.get('columnCount')).to.equal(1);
+ });
+ });
});
describe('App.WizardStep6HostView', function() {
@@ -146,4 +182,4 @@ describe('App.WizardStep6HostView', function() {
});
});
-});
\ No newline at end of file
+});
http://git-wip-us.apache.org/repos/asf/ambari/blob/cb3dd00b/ambari-web/test/views/wizard/step7_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/wizard/step7_view_test.js b/ambari-web/test/views/wizard/step7_view_test.js
new file mode 100644
index 0000000..87619d9
--- /dev/null
+++ b/ambari-web/test/views/wizard/step7_view_test.js
@@ -0,0 +1,45 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+var App = require('app');
+require('views/wizard/step7_view');
+var view;
+
+describe('App.WizardStep7View', function() {
+
+ beforeEach(function() {
+ view = App.WizardStep7View.create({
+ controller: App.WizardStep7Controller.create()
+ });
+ });
+
+ describe('#didInsertElement', function() {
+ beforeEach(function() {
+ sinon.stub(App.get('router'), 'set', Em.K);
+ });
+ afterEach(function() {
+ App.get('router').set.restore();
+ });
+
+ it('should call loadStep', function() {
+ view.didInsertElement();
+ expect(App.get('router').set.calledWith('transitionInProgress', false)).to.be.true;
+ });
+ });
+});
\ No newline at end of file