Repository: ambari Updated Branches: refs/heads/branch-2.4 6919aa509 -> 7fff9d1db
AMBARI-17003 Background Ops Dialog Spinner, JS error. (atkach) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/7fff9d1d Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/7fff9d1d Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/7fff9d1d Branch: refs/heads/branch-2.4 Commit: 7fff9d1dbf173bbe2b9bcb69d6a072e99167e1cd Parents: 6919aa5 Author: Andrii Tkach <[email protected]> Authored: Thu Jun 2 14:26:51 2016 +0300 Committer: Andrii Tkach <[email protected]> Committed: Thu Jun 2 18:02:38 2016 +0300 ---------------------------------------------------------------------- ambari-web/app/utils/host_progress_popup.js | 10 ++-- .../common/host_progress_popup_body_view.js | 1 + .../host_progress_popup_body_view_test.js | 56 +++++++++++++++++++- 3 files changed, 61 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/7fff9d1d/ambari-web/app/utils/host_progress_popup.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/utils/host_progress_popup.js b/ambari-web/app/utils/host_progress_popup.js index 8fe928f..20ea220 100644 --- a/ambari-web/app/utils/host_progress_popup.js +++ b/ambari-web/app/utils/host_progress_popup.js @@ -91,9 +91,9 @@ App.HostPopup = Em.Object.create({ servicesInfo: [], /** - * @type {?wrappedHost[]} + * @type {wrappedHost[]} */ - hosts: null, + hosts: [], /** * @type {?object[]} @@ -697,8 +697,10 @@ App.HostPopup = Em.Object.create({ existedHosts.forEach(function (host) { var newHostInfo = hostsMap[host.get('name')]; //update only hosts with changed tasks or currently opened tasks of host - var hostShouldBeUpdated = !this.get('isBackgroundOperations') || newHostInfo.isModified || this.get('currentHostName') === host.get('name'); - if (newHostInfo && hostShouldBeUpdated) { + if (newHostInfo && + (!this.get('isBackgroundOperations') || + newHostInfo.isModified || + this.get('currentHostName') === host.get('name'))) { var hostStatus = self.getStatus(newHostInfo.logTasks); var hostProgress = self.getProgress(newHostInfo.logTasks); host.setProperties({ http://git-wip-us.apache.org/repos/asf/ambari/blob/7fff9d1d/ambari-web/app/views/common/host_progress_popup_body_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/host_progress_popup_body_view.js b/ambari-web/app/views/common/host_progress_popup_body_view.js index 19fabd0..b9181e2 100644 --- a/ambari-web/app/views/common/host_progress_popup_body_view.js +++ b/ambari-web/app/views/common/host_progress_popup_body_view.js @@ -373,6 +373,7 @@ App.HostProgressPopupBodyView = App.TableView.extend({ isServiceListHidden: false }); this.get("controller").setBackgroundOperationHeader(false); + this.get('controller.hosts').clear(); this.setOnStart(); this.rerender(); } http://git-wip-us.apache.org/repos/asf/ambari/blob/7fff9d1d/ambari-web/test/views/common/host_progress_popup_body_view_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/common/host_progress_popup_body_view_test.js b/ambari-web/test/views/common/host_progress_popup_body_view_test.js index 16c7b4d..534269b 100644 --- a/ambari-web/test/views/common/host_progress_popup_body_view_test.js +++ b/ambari-web/test/views/common/host_progress_popup_body_view_test.js @@ -24,8 +24,11 @@ describe('App.HostProgressPopupBodyView', function () { beforeEach(function () { view = App.HostProgressPopupBodyView.create({ controller: Em.Object.create({ - dataSourceController: Em.Object.create({}) - }) + dataSourceController: Em.Object.create({}), + setBackgroundOperationHeader: Em.K, + hosts: [] + }), + parentView: Em.Object.create() }); }); @@ -251,4 +254,53 @@ describe('App.HostProgressPopupBodyView', function () { }); }); }); + + describe("#resetState()", function () { + + beforeEach(function() { + sinon.stub(view.get('controller'), 'setBackgroundOperationHeader'); + sinon.stub(view, 'setOnStart'); + sinon.stub(view, 'rerender'); + sinon.stub(view, 'updateSelectView'); + }); + + afterEach(function() { + view.get('controller').setBackgroundOperationHeader.restore(); + view.setOnStart.restore(); + view.rerender.restore(); + view.updateSelectView.restore(); + }); + + it("should set properties of parentView", function() { + view.set('parentView.isOpen', true); + expect(JSON.stringify(view.get('parentView'))).to.be.equal(JSON.stringify({ + "isOpen": true, + "isLogWrapHidden": true, + "isTaskListHidden": true, + "isHostListHidden": true, + "isServiceListHidden": false + })); + }); + + it("setBackgroundOperationHeader should be called", function() { + view.set('parentView.isOpen', true); + expect(view.get('controller').setBackgroundOperationHeader.calledWith(false)).to.be.true; + }); + + it("controller.hosts should be empty", function() { + view.set('controller.hosts', [{}]); + view.set('parentView.isOpen', true); + expect(view.get('controller.hosts')).to.be.empty; + }); + + it("setOnStart should be called", function() { + view.set('parentView.isOpen', true); + expect(view.setOnStart.calledOnce).to.be.true; + }); + + it("rerender should be called", function() { + view.set('parentView.isOpen', true); + expect(view.rerender.calledOnce).to.be.true; + }); + }); });
