[FIX] mail: fix test failing at "Write something in composer"

The issue is not easy to reproduce, so the fix is not a guaranteed one.

Estimation: the click on the "send message" buttons happens too early,
and it is either doing nothing, or being immediately reset by another
action that happens at page load.

Adding a little bit of extra delay (in particular waiting for messages
to be loaded) might resolve the issue.

Also back-port code allowing to use contains in tours.

runbot-27847

closes odoo/odoo#144435

X-original-commit: 3b261b6856e935f8fe9d4e23cfddc09df8ff7fdf
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-12-04 17:47:31 +00:00
parent d08ba20253
commit 5455bfcfdc
3 changed files with 14 additions and 5 deletions
@@ -34,10 +34,11 @@ class TestMailFullComposer(MailCommon, HttpCase):
'model_id': self.env.ref('mail.model_mail_compose_message').id,
})
automation.write({'action_server_ids': [(4, server_action.id)]})
partner = self.env["res.partner"].create({"name": "Jane", "email": "jane@example.com"})
user = self.env["res.users"].create({"name": "Not A Demo User", "login": "nadu"})
with self.mock_mail_app():
self.start_tour(
f"/web#id={self.user_employee.partner_id.id}&model=res.partner",
f"/web#id={partner.id}&model=res.partner",
"mail/static/tests/tours/mail_composer_test_tour.js",
login=self.user_employee.login
)
@@ -1,7 +1,7 @@
/* @odoo-module */
import { registry } from "@web/core/registry";
import { createFile, inputFiles } from "@web/../tests/utils";
import { contains, createFile, inputFiles } from "@web/../tests/utils";
/**
* This tour depends on data created by python test in charge of launching it.
@@ -12,6 +12,13 @@ import { createFile, inputFiles } from "@web/../tests/utils";
registry.category("web_tour.tours").add("mail/static/tests/tours/mail_composer_test_tour.js", {
test: true,
steps: () => [
{
content: "Wait for the chatter to be fully loaded",
trigger: ".o-mail-Chatter",
async run() {
await contains(".o-mail-Message", { count: 1 });
},
},
{
content: "Click on Send Message",
trigger: "button:contains(Send message)",
@@ -65,9 +72,9 @@ registry.category("web_tour.tours").add("mail/static/tests/tours/mail_composer_t
trigger: '[name="subject"] input',
run() {
const subjectValue = document.querySelector('[name="subject"] input').value;
if (subjectValue !== "Ernest Employee") {
if (subjectValue !== "Jane") {
console.error(
`Full composer should have "Ernest Employee" in subject input (actual: ${subjectValue})`
`Full composer should have "Jane" in subject input (actual: ${subjectValue})`
);
}
},
+2 -1
View File
@@ -275,10 +275,11 @@ class TestMailComposerUI(MailCommon, HttpCase):
self.user_employee.write({
'groups_id': [(4, self.env.ref('base.group_partner_manager').id)],
})
partner = self.env["res.partner"].create({"name": "Jane", "email": "jane@example.com"})
user = self.env["res.users"].create({"name": "Not A Demo User", "login": "nadu"})
with self.mock_mail_app():
self.start_tour(
f"/web#id={self.user_employee.partner_id.id}&model=res.partner",
f"/web#id={partner.id}&model=res.partner",
"mail/static/tests/tours/mail_composer_test_tour.js",
login=self.user_employee.login
)