This commit refactors discuss code to use OWL components and new tools and services in web/. Functionally, Discuss app should work relatively the same as before this commit. closes https://github.com/odoo/odoo/pull/110188 Related: https://github.com/odoo/enterprise/pull/38058 https://github.com/odoo/upgrade/pull/4423 closes odoo/odoo#110188 Related: odoo/upgrade#4423 Related: odoo/enterprise#38058 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com> Co-authored-by: Alexandre (aku) <aku@odoo.com> Co-authored-by: Didier (did) <did@odoo.com> Co-authored-by: Géry (ged) <ged@odoo.com> Co-authored-by: Louis (wil) <wil@odoo.com> Co-authored-by: Maël (mapa) <mapa@odoo.com> Co-authored-by: Maryam (maki) <maki@odoo.com> Co-authored-by: Sébastien (seb) <seb@odoo.com> Co-authored-by: Thanh (tso) <tso@odoo.com> Co-authored-by: Matthieu (tsm) <tsm@odoo.com> Co-authored-by: Zelong (zel) <zel@odoo.com>
57 lines
2.2 KiB
JavaScript
57 lines
2.2 KiB
JavaScript
/** @odoo-module **/
|
|
|
|
import { afterNextRender, start } from "@mail/../tests/helpers/test_utils";
|
|
|
|
QUnit.module("messaging");
|
|
|
|
QUnit.test(
|
|
"Posting a message to a partner out of discuss should open a chat window",
|
|
async (assert) => {
|
|
const { env, pyEnv } = await start();
|
|
const partnerId = pyEnv["res.partner"].create({ name: "Dumbledore" });
|
|
const userId = pyEnv["res.users"].create({ partner_id: partnerId });
|
|
const channelId = pyEnv["mail.channel"].create({
|
|
channel_member_ids: [
|
|
[0, 0, { partner_id: pyEnv.currentPartnerId }],
|
|
[0, 0, { partner_id: partnerId }],
|
|
],
|
|
channel_type: "chat",
|
|
});
|
|
const [channel] = pyEnv["mail.channel"].searchRead([["id", "=", channelId]]);
|
|
await afterNextRender(() =>
|
|
env.services.rpc("/mail/chat_post", {
|
|
context: { mockedUserId: userId },
|
|
message_content: "new message",
|
|
uuid: channel.uuid,
|
|
})
|
|
);
|
|
assert.containsOnce($, ".o-mail-ChatWindow-header:contains(Dumbledore)");
|
|
}
|
|
);
|
|
|
|
QUnit.test(
|
|
"Posting a message to a partner should open a chat window after leaving discuss",
|
|
async (assert) => {
|
|
const { env, openDiscuss, openFormView, pyEnv } = await start();
|
|
await openDiscuss();
|
|
const partnerId = pyEnv["res.partner"].create({ name: "Dumbledore" });
|
|
const userId = pyEnv["res.users"].create({ partner_id: partnerId });
|
|
const channelId = pyEnv["mail.channel"].create({
|
|
channel_member_ids: [
|
|
[0, 0, { partner_id: pyEnv.currentPartnerId }],
|
|
[0, 0, { partner_id: partnerId }],
|
|
],
|
|
channel_type: "chat",
|
|
});
|
|
const [channel] = pyEnv["mail.channel"].searchRead([["id", "=", channelId]]);
|
|
env.services.rpc("/mail/chat_post", {
|
|
context: { mockedUserId: userId },
|
|
message_content: "new message",
|
|
uuid: channel.uuid,
|
|
});
|
|
// leaving discuss.
|
|
await openFormView("res.partner", partnerId);
|
|
assert.containsOnce($, ".o-mail-ChatWindow-header:contains(Dumbledore)");
|
|
}
|
|
);
|