From 37aca4a38e15bf481387f77613050f9d8dd80c44 Mon Sep 17 00:00:00 2001 From: Samuel Degueldre Date: Thu, 5 Aug 2021 07:00:29 +0000 Subject: [PATCH] [FIX] im_livechat: add missing dependencies to manifest MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The dependencies of the public_root module were recently updated, but the manifest of im_livechat was not, causing it to fail to load. This commit adds those missing dependencies to the manifest. This commit also adds a test that checks that all modules are properly loaded on the support page, since this has been broken on multiple occasions while changing the dependencies or the path of some of the modules this page needs to work. closes odoo/odoo#74756 Signed-off-by: Sébastien Theys (seb) --- addons/im_livechat/__manifest__.py | 5 ++- .../static/src/js/ajax_external.js | 2 +- addons/im_livechat/tests/__init__.py | 1 + .../tests/test_im_livechat_support_page.py | 34 +++++++++++++++++++ 4 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 addons/im_livechat/tests/test_im_livechat_support_page.py diff --git a/addons/im_livechat/__manifest__.py b/addons/im_livechat/__manifest__.py index d4692bb49f2..2cd4c10a2a5 100644 --- a/addons/im_livechat/__manifest__.py +++ b/addons/im_livechat/__manifest__.py @@ -100,8 +100,9 @@ Help your customers with this chat, and analyse their feedback. 'web/static/src/core/browser/feature_detection.js', 'web/static/src/core/dialog/dialog.js', 'web/static/src/core/errors/error_dialogs.js', - 'web/static/src/core/utils/hooks.js', + 'web/static/src/core/effects/**/*.js', 'web/static/src/core/hotkeys/hotkey_service.js', + 'web/static/src/core/hotkeys/hotkey_hook.js', 'web/static/src/core/l10n/dates.js', 'web/static/src/core/l10n/localization.js', 'web/static/src/core/l10n/localization_service.js', @@ -117,8 +118,10 @@ Help your customers with this chat, and analyse their feedback. 'web/static/src/core/user_service.js', 'web/static/src/core/utils/components.js', 'web/static/src/core/utils/functions.js', + 'web/static/src/core/utils/hooks.js', 'web/static/src/core/utils/strings.js', 'web/static/src/core/utils/timing.js', + 'web/static/src/core/utils/ui.js', 'web/static/src/env.js', 'web/static/src/legacy/utils.js', 'web/static/src/legacy/js/owl_compatibility.js', diff --git a/addons/im_livechat/static/src/js/ajax_external.js b/addons/im_livechat/static/src/js/ajax_external.js index 6bcd36952ed..debe12492bc 100644 --- a/addons/im_livechat/static/src/js/ajax_external.js +++ b/addons/im_livechat/static/src/js/ajax_external.js @@ -8,5 +8,5 @@ import ajax from 'web.ajax'; * As we're not in an Odoo website context, the calls will not work, and we avoid a 404 request. */ ajax.loadJS = function (url) { - console.warn('Tried to load the following script on an external website: ' + url); + console.log('Tried to load the following script on an external website: ' + url); }; diff --git a/addons/im_livechat/tests/__init__.py b/addons/im_livechat/tests/__init__.py index a22a67032d1..f8b445619bb 100644 --- a/addons/im_livechat/tests/__init__.py +++ b/addons/im_livechat/tests/__init__.py @@ -2,3 +2,4 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. from . import test_get_mail_channel +from . import test_im_livechat_support_page diff --git a/addons/im_livechat/tests/test_im_livechat_support_page.py b/addons/im_livechat/tests/test_im_livechat_support_page.py new file mode 100644 index 00000000000..503499e8f92 --- /dev/null +++ b/addons/im_livechat/tests/test_im_livechat_support_page.py @@ -0,0 +1,34 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +import odoo +from odoo.tests import HttpCase + +@odoo.tests.tagged('-at_install', 'post_install') +class TestImLivechatSupportPage(HttpCase): + def test_load_modules(self): + """Checks that all javascript modules load correctly on the livechat support page""" + test_ready = """ + if (!window.testSetupHasRun) { + window.testSetupHasRun = true; + const setReady = () => odoo.__DEBUG__.didLogInfo.then(() => { + window.testIsReady = true; + }); + if (document.readyState === "complete") { + setReady(); + } else { + window.addEventListener("load", setReady); + } + } + window.testIsReady; + """ + + check_js_modules = """ + const { missing, failed, unloaded } = odoo.__DEBUG__.jsModules; + if ([missing, failed, unloaded].some(arr => arr.length)) { + console.error("Couldn't load all JS modules.", JSON.stringify({ missing, failed, unloaded })); + } else { + console.log("test successful"); + } + """ + self.browser_js("/im_livechat/support/1", code=check_js_modules, ready=test_ready)