[FIX] mail: fix race condition in load_message_order

- 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) <aku@odoo.com>
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
This commit is contained in:
Sébastien Theys
2023-11-14 15:16:08 +00:00
parent 3e3843114f
commit d3b7ff500b
@@ -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;
},
},
],