From 8bf49da5a73228ab92d8988accccf0bef4380b06 Mon Sep 17 00:00:00 2001 From: tsm-odoo Date: Fri, 13 Oct 2023 06:55:15 +0200 Subject: [PATCH] [FIX] website_livechat: fix tour failing nondeterministically MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit fixes the `website_livechat_chatbot_flow_tour` that was failing in a nondeterministc way. This is due to the tour sometimes taking more than `60` seconds which is the default timeout for python tours. Most of the time is consumed waiting for the user to finish its multiline input. This issue is solved by shortening the delay to consider the multiline input as done: from `10`s to `500`ms. fixes runbot-24557 closes odoo/odoo#138629 X-original-commit: cdca70941dab1b20dca9bdf9d44d354327176b59 Signed-off-by: Alexandre Kühn (aku) Signed-off-by: Matthieu Stockbauer (tsm) --- .../static/src/embed/chatbot/chatbot_service.js | 8 ++++---- .../static/tests/tours/website_livechat_chatbot_flow.js | 8 ++++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/addons/im_livechat/static/src/embed/chatbot/chatbot_service.js b/addons/im_livechat/static/src/embed/chatbot/chatbot_service.js index f993a3e929a..d84499d71c8 100644 --- a/addons/im_livechat/static/src/embed/chatbot/chatbot_service.js +++ b/addons/im_livechat/static/src/embed/chatbot/chatbot_service.js @@ -14,11 +14,11 @@ import { debounce } from "@web/core/utils/timing"; const MESSAGE_DELAY = 1500; // Time between two messages coming from the bot. const STEP_DELAY = 500; -// Time to wait without user input before considering a multi line -// step as completed. -const MULTILINE_STEP_DEBOUNCE_DELAY = 10000; export class ChatBotService { + // Time to wait without user input before considering a multi line + // step as completed. + MULTILINE_STEP_DEBOUNCE_DELAY = 10_000; /** @type {import("@im_livechat/embed/chatbot/chatbot_model").Chatbot} */ chatbot; /** @type {import("@im_livechat/embed/chatbot/chatbot_step_model").ChatbotStep} */ @@ -54,7 +54,7 @@ export class ChatBotService { this.debouncedProcessUserAnswer = debounce( this._processUserAnswer.bind(this), - MULTILINE_STEP_DEBOUNCE_DELAY + this.MULTILINE_STEP_DEBOUNCE_DELAY ); if (this.livechatService.options.isTestChatbot) { this.livechatService.rule.chatbot = { 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 27099df4d2b..82b0957d876 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 @@ -10,6 +10,12 @@ registry.category("web_tour.tours").add("website_livechat_chatbot_flow_tour", { steps: () => [ { trigger: messagesContain("Hello! I'm a bot!"), + run() { + // Make chatbot faster + odoo.__WOWL_DEBUG__.root.env.services[ + "im_livechat.chatbot" + ].MULTILINE_STEP_DEBOUNCE_DELAY = 500; + }, }, { trigger: messagesContain("I help lost visitors find their way."), @@ -123,7 +129,6 @@ registry.category("web_tour.tours").add("website_livechat_chatbot_flow_tour", { }, { trigger: messagesContain("Ok bye!"), - timeout: 15000, // multiline step, so we need to wait a bit longer run: () => {}, // last step is displayed }, { @@ -198,7 +203,6 @@ registry.category("web_tour.tours").add("website_livechat_chatbot_flow_tour", { { // wait for chatbot script to finish. trigger: ".o-mail-ChatWindow-command[title='Restart Conversation']", - timeout: 15000, // multiline step, so we need to wait a bit longer run() {}, }, ],