From d3b7ff500b43e078cf7798770688e188f4e20c41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Theys?= Date: Tue, 14 Nov 2023 14:37:32 +0100 Subject: [PATCH] [FIX] mail: fix race condition in load_message_order MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - adapt test to ensure consistent (scroll) state at each step The issue is hard to reproduce, so the complete resolution of the issue is not guaranteed, but the current change should do the job, and if it doesn't, it will help to pinpoint the issue. Estimated issue: the thread doesn't load more messages when scrolling to bottom because the scroll to bottom is overriden by the auto-scroll top when clicking on pin. Adding extra wait point should solve the issue. runbot-24512 closes odoo/odoo#141999 X-original-commit: 477b1c3aa1da7261273341338f3d37ee828715f8 Signed-off-by: Alexandre Kühn (aku) Signed-off-by: Sébastien Theys (seb) --- .../tours/mail_message_load_order_tour.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/addons/mail/static/tests/tours/mail_message_load_order_tour.js b/addons/mail/static/tests/tours/mail_message_load_order_tour.js index 54fad923cce..f3a22261ced 100644 --- a/addons/mail/static/tests/tours/mail_message_load_order_tour.js +++ b/addons/mail/static/tests/tours/mail_message_load_order_tour.js @@ -1,6 +1,7 @@ /* @odoo-module */ import { registry } from "@web/core/registry"; +import { contains, scroll } from "@web/../tests/utils"; registry.category("web_tour.tours").add("mail_message_load_order_tour", { test: true, @@ -9,6 +10,13 @@ registry.category("web_tour.tours").add("mail_message_load_order_tour", { trigger: ".o-mail-DiscussSidebarChannel:contains(MyTestChannel)", run: "click", }, + { + trigger: ".o-mail-Thread .o-mail-Message", + async run() { + await contains(".o-mail-Thread .o-mail-Message", { count: 30 }); + await contains(".o-mail-Thread", { scroll: "bottom" }); + }, + }, { trigger: "*[title='Pinned Messages']", run: "click", @@ -24,6 +32,8 @@ registry.category("web_tour.tours").add("mail_message_load_order_tour", { // are fetched after jumping to the message. trigger: ".o-mail-Thread .o-mail-Message:first:not(:contains(31))", async run() { + await contains(".o-mail-Thread .o-mail-Message", { count: 16 }); + await contains(".o-mail-Thread", { scroll: 0 }); // ensure 1 - 16 are loaded in order: 15 below and the // one we're loading messages around. const messages = Array.from( @@ -34,8 +44,7 @@ registry.category("web_tour.tours").add("mail_message_load_order_tour", { throw new Error("Wrong message order after loading around"); } } - const thread = document.querySelector(".o-mail-Thread"); - thread.scrollTop = thread.scrollHeight - thread.clientHeight; + await scroll(".o-mail-Thread", "bottom"); }, }, { @@ -44,7 +53,8 @@ registry.category("web_tour.tours").add("mail_message_load_order_tour", { // and the pinned message itself. This trigger ensures the // next messages are fetched after scrolling to the bottom. trigger: ".o-mail-Thread .o-mail-Message:contains(17)", - run() { + async run() { + await contains(".o-mail-Thread .o-mail-Message", { count: 46 }); // ensure 1 - 46 are loaded in order. const messages = Array.from( document.querySelectorAll(".o-mail-Thread .o-mail-Message-content") @@ -54,8 +64,6 @@ registry.category("web_tour.tours").add("mail_message_load_order_tour", { throw new Error("Wrong message order after loading after"); } } - const thread = document.querySelector(".o-mail-Thread"); - thread.scrollTop = thread.scrollHeight - thread.clientHeight; }, }, ],