From 72b75028d704f7d082224c12a525609c8c35bc3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20K=C3=BChn?= Date: Mon, 5 Mar 2018 15:37:02 +0100 Subject: [PATCH] [FIX] mail: tests: correctly destroy with createDiscuss helper Before this commit, when using createDiscuss and performing discuss.destroy, the parent widget was not destroyed. This is an issue, because the mocked environment is attached to the parent widget of discuss. Any call to this.getSession() is mocked by the addMockEnvironment, and this mocked behaviour is removed only when the corresponding widget is destroyed. This commit overrides discuss.destroy(), so that the parent widget is also destroyed, so that it removes the side effect on this.getSession() from the mocked environment. --- addons/mail/static/tests/helpers/test_utils.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/addons/mail/static/tests/helpers/test_utils.js b/addons/mail/static/tests/helpers/test_utils.js index 095da27be58..cd933bc2483 100644 --- a/addons/mail/static/tests/helpers/test_utils.js +++ b/addons/mail/static/tests/helpers/test_utils.js @@ -77,6 +77,15 @@ function createDiscuss(params) { var selector = params.debug ? 'body' : '#qunit-fixture'; discuss.appendTo($(selector)); + // override 'destroy' of discuss so that it calls 'destroy' on the parent + // instead, which is the parent of discuss and the mockServer. + discuss.destroy = function () { + // remove the override to properly destroy discuss and its children + // when it will be called the second time (by its parent) + delete discuss.destroy; + parent.destroy(); + }; + return discuss.call('chat_manager', 'isReady').then(function () { return discuss; });