From babc6ff819cb6087cdadc37e4430e271a5c86c3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Warnon?= Date: Mon, 16 May 2022 08:53:24 +0000 Subject: [PATCH] [FIX] website_livechat: fix chatbot tour race condition MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In some cases, the runbot running the tour was clicking on the "restart conversation" button before we had the chance to register the click event on it. This small commit adds a "ready" class on the button when we have correctly registered the click event, and makes the tour step wait for that class before clicking to restart. closes odoo/odoo#91505 X-original-commit: 623fdb15ce9a6f3f586254dca549a72869336729 Signed-off-by: Thibault Delavallee (tde) Signed-off-by: Warnon Aurélien (awa) --- .../static/tests/tours/website_livechat_chatbot_flow.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 c794711e3c7..3c0a3daf648 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 @@ -17,6 +17,12 @@ LivechatButton.include({ return this._super(...arguments); }, + _renderMessages: function () { + this._super(...arguments); + + this._chatWindow.$('.o_livechat_chatbot_main_restart') + .addClass('ready'); + }, /** * Small override that removes current messages when restarting. * This allows to easily check for new posted messages without having the old ones "polluting" @@ -118,7 +124,7 @@ tour.register('website_livechat_chatbot_flow_tour', { trigger: messagesContain("Ok bye!"), run: () => {} // last step is displayed }, { - trigger: '.o_livechat_chatbot_main_restart', + trigger: '.o_livechat_chatbot_main_restart.ready', run: 'click' }, { trigger: messagesContain("Restarting conversation..."),