Skip to content

Commit 5d0ff25

Browse files
committed
[FIX] mail: add test for mention suggestions in group-restricted channel
This commit adds a test for mention suggestions in group-restricted channels (`group_public_id`). task-5258925 closes odoo#236713 X-original-commit: 6e5a660 Signed-off-by: Giorgio Tocco (gito) <[email protected]>
1 parent 2faefe6 commit 5d0ff25

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { registry } from "@web/core/registry";
2+
3+
registry.category("web_tour.tours").add("discuss_mention_suggestions_group_restricted_channel.js", {
4+
steps: () => [
5+
{ trigger: ".o-mail-DiscussContent-threadName[title='R&D Channel']" },
6+
{ trigger: ".o-mail-Composer-input", run: "edit @" },
7+
{ trigger: ".o-mail-Composer-suggestion:count(3)" },
8+
{
9+
content: "Suggest channel member not in R&D group",
10+
trigger: ".o-mail-Composer-suggestion strong:text(Consultant User)",
11+
},
12+
{
13+
content: "Suggest non-channel member in R&D group",
14+
trigger: ".o-mail-Composer-suggestion strong:text(Dev User)",
15+
},
16+
],
17+
});

addons/mail/tests/discuss/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from . import test_discuss_channel_as_guest
1111
from . import test_discuss_channel_member
1212
from . import test_discuss_mail_presence
13+
from . import test_discuss_mention_suggestions
1314
from . import test_discuss_message_update_controller
1415
from . import test_discuss_reaction_controller
1516
from . import test_discuss_res_role
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Part of Odoo. See LICENSE file for full copyright and licensing details.
2+
3+
from odoo import Command
4+
from odoo.tests.common import HttpCase, new_test_user
5+
6+
7+
class TestDiscussMentionSuggestions(HttpCase):
8+
def test_mention_suggestions_group_restricted_channel(self):
9+
user_admin = self.env.ref("base.user_admin")
10+
user_group = self.env.ref("base.group_user")
11+
rd_group = self.env["res.groups"].create({"name": "R&D Group"})
12+
new_test_user(self.env, login="dev", name="Dev User", group_ids=[user_group.id, rd_group.id])
13+
# have a user that is not channel member and not in group -> should not be suggested as mention
14+
new_test_user(self.env, login="sales", name="Sales User", groups="base.group_user")
15+
consultant_user = new_test_user(self.env, login="consultant", name="Consultant User", groups="base.group_user")
16+
rd_channel = self.env['discuss.channel'].with_user(user_admin).create({
17+
"name": "R&D Channel",
18+
"channel_type": "channel",
19+
"group_public_id": rd_group.id,
20+
"channel_member_ids": [
21+
Command.create({"partner_id": consultant_user.partner_id.id}),
22+
Command.create({"partner_id": user_admin.partner_id.id}),
23+
],
24+
})
25+
self.start_tour(
26+
f"/odoo/discuss?active_id=discuss.channel_{rd_channel.id}",
27+
"discuss_mention_suggestions_group_restricted_channel.js",
28+
login="admin",
29+
)

0 commit comments

Comments
 (0)