From f1abc4e4f352f0efdecddc2ed8a9d7cdf9a6bf98 Mon Sep 17 00:00:00 2001 From: "Didier (did)" Date: Tue, 3 Oct 2023 08:48:44 +0000 Subject: [PATCH] [FIX] mail: selfFollower should be included in the followers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before this PR, the current user was not considered has a follower, regarding the mention suggestions. This lead him to be lower than other entries. This PR fix the issue by adding him back to the follower list. Task-3531111 closes odoo/odoo#137583 X-original-commit: 50a785fedc5b5c7fd826548e52385bdf458c97a2 Signed-off-by: Alexandre Kühn (aku) Signed-off-by: Didier Debondt (did) --- .../static/src/core/common/partner_compare.js | 3 ++ .../tests/suggestion/suggestion_tests.js | 30 +++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/addons/mail/static/src/core/common/partner_compare.js b/addons/mail/static/src/core/common/partner_compare.js index 82e701c4a69..f494740a464 100644 --- a/addons/mail/static/src/core/common/partner_compare.js +++ b/addons/mail/static/src/core/common/partner_compare.js @@ -31,6 +31,9 @@ partnerCompareRegistry.add( (p1, p2, { thread }) => { if (thread) { const followerList = [...thread.followers]; + if (thread.selfFollower) { + followerList.push(thread.selfFollower); + } const isFollower1 = followerList.some((follower) => p1.eq(follower.partner)); const isFollower2 = followerList.some((follower) => p2.eq(follower.partner)); if (isFollower1 && !isFollower2) { diff --git a/addons/mail/static/tests/suggestion/suggestion_tests.js b/addons/mail/static/tests/suggestion/suggestion_tests.js index 119705743c9..238c89647f2 100644 --- a/addons/mail/static/tests/suggestion/suggestion_tests.js +++ b/addons/mail/static/tests/suggestion/suggestion_tests.js @@ -285,3 +285,33 @@ QUnit.test("Internal user should be displayed first", async () => { await contains(":nth-child(3 of .o-mail-Composer-suggestion) strong", { text: "Person B" }); await contains(":nth-child(4 of .o-mail-Composer-suggestion) strong", { text: "Person A" }); }); + +QUnit.test("Current user that is a follower should be considered as such", async () => { + const pyEnv = await startServer(); + const userId = pyEnv["res.users"].create({ share: true }); + pyEnv["res.partner"].create([ + { email: "a@test.com", name: "Person A" }, + { email: "b@test.com", name: "Person B", user_ids: [userId] }, + ]); + pyEnv["mail.followers"].create([ + { + is_active: true, + partner_id: pyEnv.currentPartnerId, + res_id: pyEnv.currentPartnerId, + res_model: "res.partner", + }, + ]); + const { openFormView } = await start(); + await openFormView("res.partner", pyEnv.currentPartnerId); + await click("button", { text: "Send message" }); + await insertText(".o-mail-Composer-input", "@"); + await contains(".o-mail-Composer-suggestion", { count: 3 }); + await contains(".o-mail-Composer-suggestion", { + text: "Mitchell Admin", + before: [".o-mail-Composer-suggestion", { text: "Person B(b@test.com)" }], + }); + await contains(".o-mail-Composer-suggestion", { + text: "Person B(b@test.com)", + before: [".o-mail-Composer-suggestion", { text: "Person A(a@test.com)" }], + }); +});