AMBARI-8428. "Service actions" drop down menu is continuously re-created. Added UT (alexantonenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/9218a8eb Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/9218a8eb Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/9218a8eb Branch: refs/heads/trunk Commit: 9218a8ebf7011df6f4259c43aa88f14f11673851 Parents: a612715 Author: Alex Antonenko <hiv...@gmail.com> Authored: Wed Nov 26 18:05:14 2014 +0200 Committer: Alex Antonenko <hiv...@gmail.com> Committed: Wed Nov 26 18:40:09 2014 +0200 ---------------------------------------------------------------------- ambari-web/test/views/main/service/item_test.js | 50 +++++++++++--------- 1 file changed, 27 insertions(+), 23 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/9218a8eb/ambari-web/test/views/main/service/item_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/main/service/item_test.js b/ambari-web/test/views/main/service/item_test.js index b35aa6c..c4e847c 100644 --- a/ambari-web/test/views/main/service/item_test.js +++ b/ambari-web/test/views/main/service/item_test.js @@ -19,10 +19,13 @@ var App = require('app'); require('views/main/service/item'); +var view; + describe('App.MainServiceItemView', function () { describe('#mastersExcludedCommands', function () { - var view = App.MainServiceItemView.create({ + + view = App.MainServiceItemView.create({ controller: Em.Object.create({ content: Em.Object.create({ hostComponents: [] @@ -61,7 +64,7 @@ describe('App.MainServiceItemView', function () { }); }); - describe.skip('#observeMaintenance', function () { + describe('#observeMaintenance', function () { var mastersExcludedCommands = { NAMENODE: ["DECOMMISSION", "REBALANCEHDFS"], @@ -323,8 +326,14 @@ describe('App.MainServiceItemView', function () { beforeEach(function () { + view = App.MainServiceItemView.create({}); + sinon.stub(App, 'get', function (k) { switch (k) { + case 'supports.autoRollbackHA': + case 'isRMHaEnabled': + case 'isHaEnabled': + return false; case 'components.rollinRestartAllowed': return ["DATANODE", "JOURNALNODE", "ZKFC", "NODEMANAGER", "GANGLIA_MONITOR", "HBASE_REGIONSERVER", "SUPERVISOR", "FLUME_HANDLER"]; case 'components.reassignable': @@ -375,20 +384,22 @@ describe('App.MainServiceItemView', function () { testCases.forEach(function (testCase) { - var view = App.MainServiceItemView.create({ - controller: Em.Object.create({ - content: Em.Object.create({}) - }) - }); - it('Maintenance for ' + testCase.serviceName + ' service', function () { - view.set('controller.content', Em.Object.create({ - hostComponents: testCase.hostComponents, - serviceName: testCase.serviceName, - displayName: testCase.displayName, - serviceTypes: testCase.serviceTypes, - passiveState: 'OFF' - })); + view.reopen({ + controller: Em.Object.create({ + content: Em.Object.create({ + hostComponents: testCase.hostComponents, + serviceName: testCase.serviceName, + displayName: testCase.displayName, + serviceTypes: testCase.serviceTypes, + passiveState: 'OFF' + }), + isSeveralClients: false, + clientComponents: [] + }), + mastersExcludedCommands: mastersExcludedCommands, + hasConfigTab: hasConfigTab + }); if (testCase.controller) { testCase.controller.forEach(function (item) { Object.keys(item).forEach(function (key) { @@ -396,16 +407,9 @@ describe('App.MainServiceItemView', function () { }); }); } - view.set('controller.isSeveralClients', false); - view.set('controller.clientComponents', []); - view.set('mastersExcludedCommands', mastersExcludedCommands); - view.set('hasConfigTab', hasConfigTab); view.observeMaintenanceOnce(); expect(view.get('maintenance')).to.eql(testCase.result); - }); - - it('Change isPassive option in maintenance for ' + testCase.serviceName + ' service', function () { - var oldMaintenance = JSON.parse(JSON.stringify(view.maintenance)); + var oldMaintenance = JSON.parse(JSON.stringify(view.get('maintenance'))); view.set('controller.content.passiveState', 'ON'); view.observeMaintenanceOnce(); expect(view.get('maintenance')).to.not.eql(oldMaintenance);