diff --git a/addons/im_livechat/static/tests/channel_invite_tests.js b/addons/im_livechat/static/tests/channel_invite_tests.js new file mode 100644 index 00000000000..bbb48f7d9da --- /dev/null +++ b/addons/im_livechat/static/tests/channel_invite_tests.js @@ -0,0 +1,34 @@ +/* @odoo-module */ + +import { startServer } from "@bus/../tests/helpers/mock_python_environment"; + +import { Command } from "@mail/../tests/helpers/command"; +import { click, start } from "@mail/../tests/helpers/test_utils"; + +QUnit.module("Channel invite"); + +QUnit.test("Can invite a partner to a livechat channel", async (assert) => { + const pyEnv = await startServer(); + const userId = pyEnv["res.users"].create({ name: "James" }); + pyEnv["res.partner"].create({ + name: "James", + user_ids: [userId], + }); + const channelId = pyEnv["discuss.channel"].create({ + anonymous_name: "Visitor 20", + name: "Visitor 20", + channel_member_ids: [ + Command.create({ partner_id: pyEnv.currentPartnerId }), + Command.create({ partner_id: pyEnv.publicPartnerId }), + ], + channel_type: "livechat", + livechat_operator_id: pyEnv.currentPartnerId, + }); + const { openDiscuss } = await start(); + await openDiscuss(channelId); + await click("button[title='Add Users']"); + await click(".o-discuss-ChannelInvitation-selectable:contains(James) input"); + await click("button:contains(Invite)"); + await click("button[title='Show Member List']"); + assert.containsOnce($, ".o-discuss-ChannelMember:contains(James)"); +}); diff --git a/addons/mail/static/src/discuss/core/common/channel_invitation.js b/addons/mail/static/src/discuss/core/common/channel_invitation.js index 0545c2efac1..15355cfe41f 100644 --- a/addons/mail/static/src/discuss/core/common/channel_invitation.js +++ b/addons/mail/static/src/discuss/core/common/channel_invitation.js @@ -105,7 +105,7 @@ export class ChannelInvitation extends Component { ...this.state.selectedPartners.map((partner) => partner.id), ]; await this.threadService.createGroupChat({ partners_to }); - } else if (["channel", "group"].includes(this.props.thread.type)) { + } else { await this.messaging.orm.call( "discuss.channel", "add_members",