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; }, }, ],