From b93ba8f631a3d0ac333f4899b40e1576a3dac44e Mon Sep 17 00:00:00 2001 From: tsm-odoo Date: Fri, 9 Feb 2024 10:27:11 +0100 Subject: [PATCH] [FIX] website_livechat: fix non deterministic reaction tour MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before this PR, the `test_complete_chatbot_flow_ui` would sometimes fail when checking if the user can add a reaction to a message. There are two issues: - This step uses the `contains` helper and specify the live chat `ShadowRoot` as the target. However, the `contains` helper uses a mutation observer that observes the light DOM thus, changes in the shadow root are not correctly observed. - The target passed to the `contains` helper is the `ChatWindow` DOM element but this element can be unmounted in-between. This PR fixes this issue. fixes runbot-56670 closes odoo/odoo#153382 Signed-off-by: Sébastien Theys (seb) --- addons/web/static/tests/utils.js | 2 +- .../static/tests/tours/website_livechat_chatbot_flow.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/web/static/tests/utils.js b/addons/web/static/tests/utils.js index e42eee759c9..f428ec92f8f 100644 --- a/addons/web/static/tests/utils.js +++ b/addons/web/static/tests/utils.js @@ -327,7 +327,7 @@ class Contains { this.def.reject(e); // prevents infinite loop in case of programming error } }); - this.observer.observe(document.body, { + this.observer.observe(this.options.target, { attributes: true, childList: true, subtree: true, diff --git a/addons/website_livechat/static/tests/tours/website_livechat_chatbot_flow.js b/addons/website_livechat/static/tests/tours/website_livechat_chatbot_flow.js index fbd1f46dad3..f6733e2e8e8 100644 --- a/addons/website_livechat/static/tests/tours/website_livechat_chatbot_flow.js +++ b/addons/website_livechat/static/tests/tours/website_livechat_chatbot_flow.js @@ -49,7 +49,7 @@ registry.category("web_tour.tours").add("website_livechat_chatbot_flow_tour", { // the thread has been persisted in the process async run() { await contains(".o-mail-Message-actions [title='Add a Reaction']", { - target: this.$anchor[0], + target: this.$anchor[0].getRootNode(), parent: [".o-mail-Message", { text: "I want to buy the software" }], }); },