Ariel Weinberger pushed to branch feature/CC-CHANNELMGR-1591 at cms-community / hippo-addon-channel-manager
Commits: 06057f17 by Ariel Weinberger at 2017-11-29T15:13:13+01:00 CHANNELMGR-1591 Fix broken unit tests in editContent controller - - - - - 2 changed files: - frontend-ng/src/app/channel/sidePanels/rightSidePanel/editContent/editContent.controller.js - frontend-ng/src/app/channel/sidePanels/rightSidePanel/editContent/editContent.spec.js Changes: ===================================== frontend-ng/src/app/channel/sidePanels/rightSidePanel/editContent/editContent.controller.js ===================================== --- a/frontend-ng/src/app/channel/sidePanels/rightSidePanel/editContent/editContent.controller.js +++ b/frontend-ng/src/app/channel/sidePanels/rightSidePanel/editContent/editContent.controller.js @@ -129,7 +129,7 @@ class editContentController { return angular.noop(); } - this._resetBeforeStateChange(); + this._resetBeforeStateChange(); return this._dealWithPendingChanges('SAVE_CHANGES_ON_BLUR_MESSAGE', () => { this._deleteDraft().finally(() => { this._loadDocument(documentId); @@ -334,11 +334,19 @@ class editContentController { ? 'SAVE_CHANGES_ON_PUBLISH_MESSAGE' : 'SAVE_CHANGES_ON_SWITCH_TO_CONTENT_EDITOR_MESSAGE'; + // For some reason, the value in "this.documentId" is turned to + // "undefined" when we call "this._closePanelAndOpenContent" below. + // The reason is unknown and requires further investigation. + // Until then, we will store the value of "this.documentId" in an alternative variable. + const documentId = this.documentId; + this._dealWithPendingChanges(messageKey, () => { if (mode === 'view') { - this._deleteDraft().finally(() => this._closePanelAndOpenContent(mode)); + this._deleteDraft().finally(() => { + this._closePanelAndOpenContent(mode, documentId) + }); } else { - this._closePanelAndOpenContent(mode); + this._closePanelAndOpenContent(mode, documentId); } }); } @@ -349,7 +357,6 @@ class editContentController { if (action === 'SAVE') { // don't return the result of saveDocument so a failing save does not invoke the 'done' function this.saveDocument().then(() => done()); - this._resetState(); } else { done(); // discard this._resetState(); @@ -381,13 +388,13 @@ class editContentController { }); } - _closePanelAndOpenContent(mode) { + _closePanelAndOpenContent(mode, documentId = this.documentId) { // The CMS automatically unlocks content that is being viewed, so close the side-panel to reflect that. - // It will will unlock the document if needed, so don't delete the draft here. + // It will will unlock the document if needed, so don't delete the draft here. this.close(); // mode can be 'view' or 'edit', so the event names can be 'view-content' and 'edit-content' - this.CmsService.publish('open-content', this.documentId, mode); + this.CmsService.publish('open-content', documentId, mode); if (mode === 'view') { this.CmsService.reportUsageStatistic('CMSChannelsContentPublish'); ===================================== frontend-ng/src/app/channel/sidePanels/rightSidePanel/editContent/editContent.spec.js ===================================== --- a/frontend-ng/src/app/channel/sidePanels/rightSidePanel/editContent/editContent.spec.js +++ b/frontend-ng/src/app/channel/sidePanels/rightSidePanel/editContent/editContent.spec.js @@ -14,7 +14,7 @@ * limitations under the License. */ -describe('editContent', () => { +fdescribe('editContent', () => { let $componentController; let $q; let $rootScope; @@ -430,7 +430,6 @@ describe('editContent', () => { expect(CmsService.reportUsageStatistic).toHaveBeenCalledWith('CMSChannelsSaveDocument'); expectNewDocument(); }); - it('does not open the new document when saving pending changes in the old document failed', () => { $ctrl.form.$dirty = true; DialogService.show.and.returnValue($q.resolve('SAVE')); View it on GitLab: https://code.onehippo.org/cms-community/hippo-addon-channel-manager/commit/06057f17ce43372ee76f87cb4971ef92dc9f4e0e --- View it on GitLab: https://code.onehippo.org/cms-community/hippo-addon-channel-manager/commit/06057f17ce43372ee76f87cb4971ef92dc9f4e0e You're receiving this email because of your account on code.onehippo.org.
_______________________________________________ Hippocms-svn mailing list Hippocms-svn@lists.onehippo.org https://lists.onehippo.org/mailman/listinfo/hippocms-svn