[IMP] mail: replace hardcoded orm commands in tests

Using hardcoded ORM commands in tests is cumbersome and not reliable.
This commit introduces the same system as the one used on the server.

closes odoo/odoo#120670

Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This commit is contained in:
tsm-odoo
2023-05-05 15:58:50 +02:00
parent 48205129fa
commit e1f0811b22
22 changed files with 300 additions and 196 deletions
+3 -2
View File
@@ -9,6 +9,7 @@ import {
} from "@mail/../tests/helpers/test_utils";
import { editInput, nextTick, patchWithCleanup, triggerEvent } from "@web/../tests/helpers/utils";
import { browser } from "@web/core/browser/browser";
import { Command } from "../helpers/command";
QUnit.module("call");
@@ -39,8 +40,8 @@ QUnit.test("no call with odoobot", async (assert) => {
const pyEnv = await startServer();
const channelId = pyEnv["discuss.channel"].create({
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: pyEnv.odoobotId }],
Command.create({ partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: pyEnv.odoobotId }),
],
channel_type: "chat",
});
@@ -7,6 +7,7 @@ import {
CHAT_WINDOW_INBETWEEN_WIDTH,
CHAT_WINDOW_WIDTH,
} from "@mail/web/chat_window/chat_window_service";
import { Command } from "@mail/../tests/helpers/command";
QUnit.module("chat window manager");
@@ -15,17 +16,17 @@ QUnit.test("chat window does not fetch messages if hidden", async (assert) => {
pyEnv["discuss.channel"].create([
{
channel_member_ids: [
[0, 0, { is_minimized: true, partner_id: pyEnv.currentPartnerId }],
Command.create({ is_minimized: true, partner_id: pyEnv.currentPartnerId }),
],
},
{
channel_member_ids: [
[0, 0, { is_minimized: true, partner_id: pyEnv.currentPartnerId }],
Command.create({ is_minimized: true, partner_id: pyEnv.currentPartnerId }),
],
},
{
channel_member_ids: [
[0, 0, { is_minimized: true, partner_id: pyEnv.currentPartnerId }],
Command.create({ is_minimized: true, partner_id: pyEnv.currentPartnerId }),
],
},
]);
@@ -54,17 +55,17 @@ QUnit.test("click on hidden chat window should fetch its messages", async (asser
pyEnv["discuss.channel"].create([
{
channel_member_ids: [
[0, 0, { is_minimized: true, partner_id: pyEnv.currentPartnerId }],
Command.create({ is_minimized: true, partner_id: pyEnv.currentPartnerId }),
],
},
{
channel_member_ids: [
[0, 0, { is_minimized: true, partner_id: pyEnv.currentPartnerId }],
Command.create({ is_minimized: true, partner_id: pyEnv.currentPartnerId }),
],
},
{
channel_member_ids: [
[0, 0, { is_minimized: true, partner_id: pyEnv.currentPartnerId }],
Command.create({ is_minimized: true, partner_id: pyEnv.currentPartnerId }),
],
},
]);
@@ -8,6 +8,8 @@ import {
start,
startServer,
} from "@mail/../tests/helpers/test_utils";
import { Command } from "@mail/../tests/helpers/command";
import { makeDeferred } from "@web/../tests/helpers/utils";
import {
CHAT_WINDOW_END_GAP_WIDTH,
@@ -81,13 +83,13 @@ QUnit.test(
{
name: "channel-1",
channel_member_ids: [
[0, 0, { is_minimized: true, partner_id: pyEnv.currentPartnerId }],
Command.create({ is_minimized: true, partner_id: pyEnv.currentPartnerId }),
],
},
{
name: "channel-2",
channel_member_ids: [
[0, 0, { is_minimized: false, partner_id: pyEnv.currentPartnerId }],
Command.create({ is_minimized: false, partner_id: pyEnv.currentPartnerId }),
],
},
]);
@@ -163,7 +165,7 @@ QUnit.test(
partner_id: pyEnv.currentPartnerId,
},
],
[0, 0, { partner_id: partnerId }],
Command.create({ partner_id: partnerId }),
],
channel_type: "chat",
name: "Partner 131",
@@ -12,6 +12,8 @@ import {
startServer,
waitUntil,
} from "@mail/../tests/helpers/test_utils";
import { Command } from "@mail/../tests/helpers/command";
import {
CHAT_WINDOW_END_GAP_WIDTH,
CHAT_WINDOW_INBETWEEN_WIDTH,
@@ -31,8 +33,8 @@ QUnit.test(
const userId = pyEnv["res.users"].create({ partner_id: partnerId });
const channelId = pyEnv["discuss.channel"].create({
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId }],
Command.create({ partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId }),
],
channel_type: "chat",
});
@@ -57,7 +59,7 @@ QUnit.test(
const pyEnv = await startServer();
pyEnv["discuss.channel"].create({
channel_member_ids: [
[0, 0, { is_minimized: true, partner_id: pyEnv.currentPartnerId }],
Command.create({ is_minimized: true, partner_id: pyEnv.currentPartnerId }),
],
});
patchUiSize({ size: SIZES.SM });
@@ -119,7 +121,7 @@ QUnit.test(
const pyEnv = await startServer();
const channelId = pyEnv["discuss.channel"].create({
channel_member_ids: [
[0, 0, { fold_state: "closed", partner_id: pyEnv.currentPartnerId }],
Command.create({ fold_state: "closed", partner_id: pyEnv.currentPartnerId }),
],
});
patchUiSize({ size: SIZES.SM });
@@ -195,7 +197,7 @@ QUnit.test(
const pyEnv = await startServer();
const channelId = pyEnv["discuss.channel"].create({
channel_member_ids: [
[0, 0, { fold_state: "open", partner_id: pyEnv.currentPartnerId }],
Command.create({ fold_state: "open", partner_id: pyEnv.currentPartnerId }),
],
});
patchUiSize({ size: SIZES.SM });
@@ -217,7 +219,9 @@ QUnit.test(
QUnit.test("chat window: close on ESCAPE", async (assert) => {
const pyEnv = await startServer();
pyEnv["discuss.channel"].create({
channel_member_ids: [[0, 0, { is_minimized: true, partner_id: pyEnv.currentPartnerId }]],
channel_member_ids: [
Command.create({ is_minimized: true, partner_id: pyEnv.currentPartnerId }),
],
});
await start({
mockRPC(route, args) {
@@ -246,8 +250,8 @@ QUnit.test(
pyEnv["discuss.channel"].create({
name: "general",
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId, is_minimized: true }],
[0, 0, { partner_id: partnerId }],
Command.create({ partner_id: pyEnv.currentPartnerId, is_minimized: true }),
Command.create({ partner_id: partnerId }),
],
});
await start();
@@ -264,7 +268,7 @@ QUnit.test(
pyEnv["discuss.channel"].create({
name: "general",
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId, is_minimized: true }],
Command.create({ partner_id: pyEnv.currentPartnerId, is_minimized: true }),
],
});
await start();
@@ -562,7 +566,7 @@ QUnit.test(
partner_id: pyEnv.currentPartnerId,
},
],
[0, 0, { partner_id: partnerId }],
Command.create({ partner_id: partnerId }),
],
channel_type: "chat",
});
@@ -603,8 +607,8 @@ QUnit.test(
});
const channelId = pyEnv["discuss.channel"].create({
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId }],
Command.create({ partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId }),
],
channel_type: "chat",
});
@@ -628,8 +632,8 @@ QUnit.test("chat window should open when receiving a new DM", async (assert) =>
const userId = pyEnv["res.users"].create({ partner_id: partnerId });
const channelId = pyEnv["discuss.channel"].create({
channel_member_ids: [
[0, 0, { is_pinned: false, partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId }],
Command.create({ is_pinned: false, partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId }),
],
channel_type: "chat",
});
@@ -653,8 +657,8 @@ QUnit.test("chat window should not open when receiving a new DM from odoobot", a
const userId = pyEnv["res.users"].create({ partner_id: pyEnv.odoobotId });
const channelId = pyEnv["discuss.channel"].create({
channel_member_ids: [
[0, 0, { is_pinned: false, partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: pyEnv.odoobotId }],
Command.create({ is_pinned: false, partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: pyEnv.odoobotId }),
],
channel_type: "chat",
});
@@ -720,7 +724,7 @@ QUnit.test("chat window should remain folded when new message is received", asyn
partner_id: pyEnv.currentPartnerId,
},
],
[0, 0, { partner_id: partnerId }],
Command.create({ partner_id: partnerId }),
],
channel_type: "chat",
});
@@ -833,7 +837,7 @@ QUnit.test(
partner_id: pyEnv.currentPartnerId,
},
],
[0, 0, { partner_id: partnerId }],
Command.create({ partner_id: partnerId }),
],
channel_type: "chat",
});
@@ -977,7 +981,9 @@ QUnit.test("folded chat window should hide member-list and settings buttons", as
QUnit.test("Chat window in mobile are not foldable", async (assert) => {
const pyEnv = await startServer();
pyEnv["discuss.channel"].create({
channel_member_ids: [[0, 0, { fold_state: "open", partner_id: pyEnv.currentPartnerId }]],
channel_member_ids: [
Command.create({ fold_state: "open", partner_id: pyEnv.currentPartnerId }),
],
});
patchUiSize({ size: SIZES.SM });
await start();
@@ -13,6 +13,7 @@ import {
pasteFiles,
waitUntil,
} from "@mail/../tests/helpers/test_utils";
import { Command } from "@mail/../tests/helpers/command";
import { makeFakeNotificationService } from "@web/../tests/helpers/mock_services";
const { inputFiles } = file;
@@ -354,8 +355,8 @@ QUnit.test("add an emoji after a partner mention", async (assert) => {
const channelId = pyEnv["discuss.channel"].create({
name: "Mario Party",
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId }],
Command.create({ partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId }),
],
});
const { openDiscuss } = await start();
@@ -490,8 +491,8 @@ QUnit.test("leave command on chat", async (assert) => {
const partnerId = pyEnv["res.partner"].create({ name: "Chuck Norris" });
const channelId = pyEnv["discuss.channel"].create({
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId }],
Command.create({ partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId }),
],
channel_type: "chat",
});
@@ -533,8 +534,8 @@ QUnit.test(
const partnerId = pyEnv["res.partner"].create({ name: "Marc Demo" });
const channelId = pyEnv["discuss.channel"].create({
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId }],
Command.create({ partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId }),
],
channel_type: "chat",
});
@@ -606,8 +607,8 @@ QUnit.test("Select composer suggestion via Enter does not send the message", asy
const channelId = pyEnv["discuss.channel"].create({
name: "general",
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId }],
Command.create({ partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId }),
],
});
const { openDiscuss } = await start({
@@ -8,6 +8,8 @@ import {
start,
startServer,
} from "@mail/../tests/helpers/test_utils";
import { Command } from "@mail/../tests/helpers/command";
import { LONG_TYPING, SHORT_TYPING } from "@mail/composer/composer";
import { OTHER_LONG_TYPING } from "@mail/core/messaging_service";
@@ -19,8 +21,8 @@ QUnit.test('receive other member typing status "is typing"', async (assert) => {
const channelId = pyEnv["discuss.channel"].create({
name: "channel",
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId }],
Command.create({ partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId }),
],
});
const { env, openDiscuss } = await start();
@@ -46,8 +48,8 @@ QUnit.test(
const channelId = pyEnv["discuss.channel"].create({
name: "channel",
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId }],
Command.create({ partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId }),
],
});
const { env, openDiscuss } = await start();
@@ -84,8 +86,8 @@ QUnit.test(
const channelId = pyEnv["discuss.channel"].create({
name: "channel",
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId }],
Command.create({ partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId }),
],
});
const { advanceTime, env, openDiscuss } = await start({ hasTimeControl: true });
@@ -116,8 +118,8 @@ QUnit.test(
const channelId = pyEnv["discuss.channel"].create({
name: "channel",
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId }],
Command.create({ partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId }),
],
});
const { advanceTime, env, openDiscuss } = await start({ hasTimeControl: true });
@@ -162,10 +164,10 @@ QUnit.test('receive several other members typing status "is typing"', async (ass
const channelId = pyEnv["discuss.channel"].create({
name: "channel",
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId_1 }],
[0, 0, { partner_id: partnerId_2 }],
[0, 0, { partner_id: partnerId_3 }],
Command.create({ partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId_1 }),
Command.create({ partner_id: partnerId_2 }),
Command.create({ partner_id: partnerId_3 }),
],
});
const { env, openDiscuss } = await start();
@@ -327,8 +329,8 @@ QUnit.test("chat: correspondent is typing", async (assert) => {
});
const channelId = pyEnv["discuss.channel"].create({
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId }],
Command.create({ partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId }),
],
channel_type: "chat",
});
@@ -1,6 +1,8 @@
/* @odoo-module */
import { afterNextRender, start, startServer } from "@mail/../tests/helpers/test_utils";
import { Command } from "@mail/../tests/helpers/command";
import { makeFakeNotificationService } from "@web/../tests/helpers/mock_services";
QUnit.module("Open Chat test", {});
@@ -57,8 +59,12 @@ QUnit.test("openChat: open existing chat for user", async (assert) => {
pyEnv["res.users"].create({ partner_id: partnerId });
pyEnv["discuss.channel"].create({
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId, fold_state: "open", is_minimized: true }],
[0, 0, { partner_id: partnerId }],
Command.create({
partner_id: pyEnv.currentPartnerId,
fold_state: "open",
is_minimized: true,
}),
Command.create({ partner_id: partnerId }),
],
channel_type: "chat",
});
@@ -1,6 +1,7 @@
/* @odoo-module */
import { click, insertText, start, startServer } from "@mail/../tests/helpers/test_utils";
import { Command } from "@mail/../tests/helpers/command";
QUnit.module("channel invitation form");
@@ -16,8 +17,8 @@ QUnit.test(
const channelId = pyEnv["discuss.channel"].create({
name: "TestChanel",
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId }],
Command.create({ partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId }),
],
channel_type: "channel",
});
@@ -45,8 +46,8 @@ QUnit.test(
const channelId = pyEnv["discuss.channel"].create({
name: "TestChanel",
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId_1 }],
Command.create({ partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId_1 }),
],
channel_type: "channel",
});
@@ -70,7 +71,7 @@ QUnit.test("Invitation form should display channel group restriction", async (as
});
const channelId = pyEnv["discuss.channel"].create({
name: "TestChanel",
channel_member_ids: [[0, 0, { partner_id: pyEnv.currentPartnerId }]],
channel_member_ids: [Command.create({ partner_id: pyEnv.currentPartnerId })],
channel_type: "channel",
group_public_id: groupId,
});
@@ -98,8 +99,8 @@ QUnit.test("should be able to create a new group chat from an existing chat", as
const channelId = pyEnv["discuss.channel"].create({
name: "TestChanel",
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId_1 }],
Command.create({ partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId_1 }),
],
channel_type: "chat",
});
@@ -1,6 +1,8 @@
/* @odoo-module */
import { click, start, startServer } from "@mail/../tests/helpers/test_utils";
import { Command } from "@mail/../tests/helpers/command";
import { createLocalId } from "@mail/utils/misc";
import { nextTick } from "@web/../tests/helpers/utils";
@@ -14,8 +16,8 @@ QUnit.test(
const channelId = pyEnv["discuss.channel"].create({
name: "TestChanel",
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId }],
Command.create({ partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId }),
],
channel_type: "channel",
});
@@ -33,8 +35,8 @@ QUnit.test(
const channelId = pyEnv["discuss.channel"].create({
name: "TestChanel",
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId }],
Command.create({ partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId }),
],
channel_type: "channel",
});
@@ -51,8 +53,8 @@ QUnit.test("should have correct members in member list", async (assert) => {
const channelId = pyEnv["discuss.channel"].create({
name: "TestChanel",
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId }],
Command.create({ partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId }),
],
channel_type: "channel",
});
@@ -72,8 +74,8 @@ QUnit.test(
const channelId = pyEnv["discuss.channel"].create({
name: "TestChanel",
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId }],
Command.create({ partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId }),
],
channel_type: "channel",
});
@@ -91,8 +93,8 @@ QUnit.test("chat with member should be opened after clicking on channel member",
const channelId = pyEnv["discuss.channel"].create({
name: "TestChanel",
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId }],
Command.create({ partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId }),
],
channel_type: "channel",
});
@@ -111,7 +113,7 @@ QUnit.test(
const channel_member_ids = [];
for (let i = 0; i < 101; i++) {
const partnerId = pyEnv["res.partner"].create({ name: "name" + i });
channel_member_ids.push([0, 0, { partner_id: partnerId }]);
channel_member_ids.push(Command.create({ partner_id: partnerId }));
}
const channelId = pyEnv["discuss.channel"].create({
name: "TestChanel",
@@ -131,7 +133,7 @@ QUnit.test("Load more button should load more members", async (assert) => {
const channel_member_ids = [];
for (let i = 0; i < 101; i++) {
const partnerId = pyEnv["res.partner"].create({ name: "name" + i });
channel_member_ids.push([0, 0, { partner_id: partnerId }]);
channel_member_ids.push(Command.create({ partner_id: partnerId }));
}
const channelId = pyEnv["discuss.channel"].create({
name: "TestChanel",
@@ -168,8 +170,8 @@ QUnit.test("Channel member count update after user left", async (assert) => {
const channelId = pyEnv["discuss.channel"].create({
name: "General",
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId }],
Command.create({ partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId }),
],
});
const { env, openDiscuss } = await start();
@@ -1,6 +1,7 @@
/* @odoo-module */
import { click, start, startServer } from "@mail/../tests/helpers/test_utils";
import { Command } from "@mail/../tests/helpers/command";
QUnit.module("crosstab");
@@ -29,8 +30,8 @@ QUnit.test("Remove member from channel", async (assert) => {
const channelId = pyEnv["discuss.channel"].create({
name: "General",
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId }],
Command.create({ partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId }),
],
});
const { env, openDiscuss } = await start();
@@ -2,6 +2,7 @@
import { TEST_USER_IDS } from "@bus/../tests/helpers/test_constants";
import { patchUiSize } from "@mail/../tests/helpers/patch_ui_size";
import { Command } from "@mail/../tests/helpers/command";
import {
isScrolledToBottom,
@@ -369,22 +370,22 @@ QUnit.test("sidebar: chat im_status rendering", async (assert) => {
pyEnv["discuss.channel"].create([
{
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId_1 }],
Command.create({ partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId_1 }),
],
channel_type: "chat",
},
{
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId_2 }],
Command.create({ partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId_2 }),
],
channel_type: "chat",
},
{
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId_3 }],
Command.create({ partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId_3 }),
],
channel_type: "chat",
},
@@ -457,8 +458,8 @@ QUnit.test("sidebar: chat custom name", async (assert) => {
const partnerId = pyEnv["res.partner"].create({ name: "Marc Demo" });
pyEnv["discuss.channel"].create({
channel_member_ids: [
[0, 0, { custom_channel_name: "Marc", partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId }],
Command.create({ custom_channel_name: "Marc", partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId }),
],
channel_type: "chat",
});
@@ -738,7 +739,7 @@ QUnit.test("sidebar: chat rendering with unread counter", async (assert) => {
const pyEnv = await startServer();
pyEnv["discuss.channel"].create({
channel_member_ids: [
[0, 0, { message_unread_counter: 100, partner_id: pyEnv.currentPartnerId }],
Command.create({ message_unread_counter: 100, partner_id: pyEnv.currentPartnerId }),
],
channel_type: "chat",
});
@@ -1009,8 +1010,8 @@ QUnit.test("auto-focus composer on opening thread", async (assert) => {
{ name: "General" },
{
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId }],
Command.create({ partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId }),
],
channel_type: "chat",
},
@@ -1168,8 +1169,8 @@ QUnit.test("should auto-pin chat when receiving a new DM", async (assert) => {
const userId = pyEnv["res.users"].create({ partner_id: partnerId });
const channelId = pyEnv["discuss.channel"].create({
channel_member_ids: [
[0, 0, { is_pinned: false, partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId }],
Command.create({ is_pinned: false, partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId }),
],
channel_type: "chat",
});
@@ -1205,8 +1206,8 @@ QUnit.test("'Add Users' button should be displayed in the topbar of chats", asyn
const partnerId = pyEnv["res.partner"].create({ name: "Marc Demo" });
const channelId = pyEnv["discuss.channel"].create({
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId }],
Command.create({ partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId }),
],
channel_type: "chat",
});
@@ -1220,8 +1221,8 @@ QUnit.test("'Add Users' button should be displayed in the topbar of groups", asy
const partnerId = pyEnv["res.partner"].create({ name: "Demo" });
const channelId = pyEnv["discuss.channel"].create({
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId }],
Command.create({ partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId }),
],
channel_type: "group",
});
@@ -1283,36 +1284,36 @@ QUnit.test(
pyEnv["discuss.channel"].create([
{
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId_1 }],
Command.create({ partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId_1 }),
],
channel_type: "chat",
},
{
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId_2 }],
Command.create({ partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId_2 }),
],
channel_type: "chat",
},
{
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId_3 }],
Command.create({ partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId_3 }),
],
channel_type: "chat",
},
{
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId_4 }],
Command.create({ partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId_4 }),
],
channel_type: "chat",
},
{
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: TEST_USER_IDS.odoobotId }],
Command.create({ partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: TEST_USER_IDS.odoobotId }),
],
channel_type: "chat",
},
@@ -1814,7 +1815,9 @@ QUnit.test(
const pyEnv = await startServer();
pyEnv["discuss.channel"].create({
name: "General",
channel_member_ids: [[0, 0, { is_pinned: false, partner_id: pyEnv.currentPartnerId }]],
channel_member_ids: [
Command.create({ is_pinned: false, partner_id: pyEnv.currentPartnerId }),
],
group_based_subscription: true,
});
const { openDiscuss } = await start();
@@ -1886,7 +1889,7 @@ QUnit.test("Message shows up even if channel data is incomplete", async (assert)
partner_id: pyEnv.currentPartnerId,
},
],
[0, 0, { partner_id: correspondentPartnerId }],
Command.create({ partner_id: correspondentPartnerId }),
],
channel_type: "chat",
});
@@ -2,6 +2,8 @@
import { UPDATE_BUS_PRESENCE_DELAY } from "@bus/im_status_service";
import { start, startServer, afterNextRender, click } from "@mail/../tests/helpers/test_utils";
import { Command } from "@mail/../tests/helpers/command";
import { createLocalId } from "@mail/utils/misc";
import { nextTick } from "@web/../tests/helpers/utils";
@@ -100,8 +102,8 @@ QUnit.test("show im status in messaging menu preview of chat", async (assert) =>
const partnerId = pyEnv["res.partner"].create({ name: "Demo", im_status: "online" });
pyEnv["discuss.channel"].create({
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId }],
Command.create({ partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId }),
],
channel_type: "chat",
});
@@ -9,6 +9,8 @@ import {
startServer,
waitUntil,
} from "@mail/../tests/helpers/test_utils";
import { Command } from "@mail/../tests/helpers/command";
import { editInput, makeDeferred, nextTick } from "@web/../tests/helpers/utils";
import { makeFakeNotificationService } from "@web/../tests/helpers/mock_services";
@@ -242,8 +244,8 @@ QUnit.test("sidebar: basic chat rendering", async (assert) => {
const partnerId = pyEnv["res.partner"].create({ name: "Demo" });
pyEnv["discuss.channel"].create({
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId }],
Command.create({ partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId }),
],
channel_type: "chat",
});
@@ -284,7 +286,11 @@ QUnit.test("sidebar: open channel and leave it", async (assert) => {
const channelId = pyEnv["discuss.channel"].create({
name: "General",
channel_member_ids: [
[0, 0, { fold_state: "open", is_minimized: true, partner_id: pyEnv.currentPartnerId }],
Command.create({
fold_state: "open",
is_minimized: true,
partner_id: pyEnv.currentPartnerId,
}),
],
});
const { openDiscuss } = await start({
@@ -332,8 +338,8 @@ QUnit.test("chat - channel should count unread message [REQUIRE FOCUS]", async (
});
const channelId = pyEnv["discuss.channel"].create({
channel_member_ids: [
[0, 0, { message_unread_counter: 1, partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId }],
Command.create({ message_unread_counter: 1, partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId }),
],
channel_type: "chat",
});
@@ -357,7 +363,7 @@ QUnit.test("mark channel as seen on last message visible [REQUIRE FOCUS]", async
const channelId = pyEnv["discuss.channel"].create({
name: "test",
channel_member_ids: [
[0, 0, { message_unread_counter: 1, partner_id: pyEnv.currentPartnerId }],
Command.create({ message_unread_counter: 1, partner_id: pyEnv.currentPartnerId }),
],
});
pyEnv["mail.message"].create({
@@ -498,7 +504,7 @@ QUnit.test(
});
pyEnv["discuss.channel"].create({
channel_member_ids: [
[0, 0, { message_unread_counter: 0, partner_id: pyEnv.currentPartnerId }],
Command.create({ message_unread_counter: 0, partner_id: pyEnv.currentPartnerId }),
],
channel_type: "chat",
});
@@ -518,7 +524,7 @@ QUnit.test(
});
pyEnv["discuss.channel"].create({
channel_member_ids: [
[0, 0, { message_unread_counter: 10, partner_id: pyEnv.currentPartnerId }],
Command.create({ message_unread_counter: 10, partner_id: pyEnv.currentPartnerId }),
],
channel_type: "chat",
});
@@ -538,7 +544,7 @@ QUnit.test(
});
pyEnv["discuss.channel"].create({
channel_member_ids: [
[0, 0, { message_unread_counter: 0, partner_id: pyEnv.currentPartnerId }],
Command.create({ message_unread_counter: 0, partner_id: pyEnv.currentPartnerId }),
],
channel_type: "chat",
});
@@ -559,13 +565,19 @@ QUnit.test(
pyEnv["discuss.channel"].create([
{
channel_member_ids: [
[0, 0, { message_unread_counter: 10, partner_id: pyEnv.currentPartnerId }],
Command.create({
message_unread_counter: 10,
partner_id: pyEnv.currentPartnerId,
}),
],
channel_type: "chat",
},
{
channel_member_ids: [
[0, 0, { message_unread_counter: 20, partner_id: pyEnv.currentPartnerId }],
Command.create({
message_unread_counter: 20,
partner_id: pyEnv.currentPartnerId,
}),
],
channel_type: "chat",
},
@@ -652,7 +664,7 @@ QUnit.test(
async (assert) => {
const pyEnv = await startServer();
pyEnv["discuss.channel"].create({
channel_member_ids: [[0, 0, { partner_id: pyEnv.currentPartnerId }]],
channel_member_ids: [Command.create({ partner_id: pyEnv.currentPartnerId })],
channel_type: "channel",
group_public_id: false,
name: "test",
@@ -1002,8 +1014,8 @@ QUnit.test("chat - avatar: should have correct avatar", async (assert) => {
});
const channelId = pyEnv["discuss.channel"].create({
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId }],
Command.create({ partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId }),
],
channel_type: "chat",
});
@@ -1033,7 +1045,7 @@ QUnit.test("chat should be sorted by last activity time [REQUIRE FOCUS]", async
partner_id: pyEnv.currentPartnerId,
},
],
[0, 0, { partner_id: demo_id }],
Command.create({ partner_id: demo_id }),
],
channel_type: "chat",
},
@@ -1047,7 +1059,7 @@ QUnit.test("chat should be sorted by last activity time [REQUIRE FOCUS]", async
partner_id: pyEnv.currentPartnerId,
},
],
[0, 0, { partner_id: yoshi_id }],
Command.create({ partner_id: yoshi_id }),
],
channel_type: "chat",
},
@@ -1146,8 +1158,8 @@ QUnit.test("Group unread counter up to date after mention is marked as seen", as
const partnerId = pyEnv["res.partner"].create({ name: "Chuck" });
const channelId = pyEnv["discuss.channel"].create({
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId }],
Command.create({ partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId }),
],
channel_type: "group",
});
@@ -0,0 +1,51 @@
/** @odoo-module */
export class Command {
/**
* @param {number} id
*/
static link(id) {
return [4, id, 0];
}
/**
* @param {number} id
*/
static unlink(id) {
return [3, id, 0];
}
/**
* @param {object} values
*/
static create(values) {
return [0, 0, values];
}
/**
*
* @param {number} id
* @param {object} values
*/
static update(id, values) {
return [1, id, values];
}
/**
* @param {object} values
*/
static delete(id) {
return [2, id, 0];
}
static clear() {
return [5, 0, 0];
}
/**
* @param {number[]} ids
*/
static set(ids) {
return [6, 0, ids];
}
}
@@ -6,6 +6,7 @@ import { MockServer } from "@web/../tests/helpers/mock_server";
import { datetime_to_str } from "web.time";
import { assignDefined } from "@mail/utils/misc";
import { formatDate } from "@web/core/l10n/dates";
import { Command } from "@mail/../tests/helpers/command";
patch(MockServer.prototype, "mail/models/discuss_channel", {
async _performRPC(route, args) {
@@ -768,7 +769,9 @@ patch(MockServer.prototype, "mail/models/discuss_channel", {
const partners = this.getRecords("res.partner", [["id", "in", partners_to]]);
const id = this.pyEnv["discuss.channel"].create({
channel_type: "group",
channel_member_ids: partners.map((partner) => [0, 0, { partner_id: partner.id }]),
channel_member_ids: partners.map((partner) =>
Command.create({ partner_id: partner.id })
),
name: "",
});
this._mockDiscussChannel_broadcast(
@@ -7,6 +7,7 @@ import {
insertModelFields,
insertRecords,
} from "@bus/../tests/helpers/model_definitions_helpers";
import { Command } from "@mail/../tests/helpers/command";
//--------------------------------------------------------------------------
// Models
@@ -61,7 +62,7 @@ insertModelFields("discuss.channel", {
avatarCacheKey: { string: "Avatar Cache Key", type: "datetime" },
channel_member_ids: {
default() {
return [[0, 0, { partner_id: this.currentPartnerId }]];
return [Command.create({ partner_id: this.currentPartnerId })];
},
},
channel_type: { default: "channel" },
@@ -1,6 +1,7 @@
/** @odoo-module **/
import { startServer, start, afterNextRender } from "@mail/../tests/helpers/test_utils";
import { Command } from "@mail/../tests/helpers/command";
QUnit.module("message_seen_indicator");
@@ -11,9 +12,9 @@ QUnit.test("rendering when just one has received the message", async (assert) =>
const channelId = pyEnv["discuss.channel"].create({
name: "test",
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId_1 }],
[0, 0, { partner_id: partnerId_2 }],
Command.create({ partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId_1 }),
Command.create({ partner_id: partnerId_2 }),
],
channel_type: "chat", // only chat channel have seen notification
});
@@ -45,9 +46,9 @@ QUnit.test("rendering when everyone have received the message", async (assert) =
const channelId = pyEnv["discuss.channel"].create({
name: "test",
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId_1 }],
[0, 0, { partner_id: partnerId_2 }],
Command.create({ partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId_1 }),
Command.create({ partner_id: partnerId_2 }),
],
channel_type: "chat",
});
@@ -76,9 +77,9 @@ QUnit.test("rendering when just one has seen the message", async (assert) => {
const channelId = pyEnv["discuss.channel"].create({
name: "test",
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId_1 }],
[0, 0, { partner_id: partnerId_2 }],
Command.create({ partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId_1 }),
Command.create({ partner_id: partnerId_2 }),
],
channel_type: "chat",
});
@@ -114,9 +115,9 @@ QUnit.test("rendering when just one has seen & received the message", async (ass
const channelId = pyEnv["discuss.channel"].create({
name: "test",
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId_1 }],
[0, 0, { partner_id: partnerId_2 }],
Command.create({ partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId_1 }),
Command.create({ partner_id: partnerId_2 }),
],
channel_type: "chat",
});
@@ -148,9 +149,9 @@ QUnit.test("rendering when just everyone has seen the message", async (assert) =
const channelId = pyEnv["discuss.channel"].create({
name: "test",
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId_1 }],
[0, 0, { partner_id: partnerId_2 }],
Command.create({ partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId_1 }),
Command.create({ partner_id: partnerId_2 }),
],
channel_type: "chat",
});
@@ -178,8 +179,8 @@ QUnit.test("'channel_fetch' notification received is correctly handled", async (
const channelId = pyEnv["discuss.channel"].create({
name: "test",
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId }],
Command.create({ partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId }),
],
channel_type: "chat",
});
@@ -212,8 +213,8 @@ QUnit.test("'channel_seen' notification received is correctly handled", async (a
const channelId = pyEnv["discuss.channel"].create({
name: "test",
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId }],
Command.create({ partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId }),
],
channel_type: "chat",
});
@@ -248,8 +249,8 @@ QUnit.test(
const channelId = pyEnv["discuss.channel"].create({
name: "test",
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId }],
Command.create({ partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId }),
],
channel_type: "chat",
});
@@ -296,8 +297,8 @@ QUnit.test(
name: "test",
channel_type: "chat",
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId }],
Command.create({ partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId }),
],
});
const messageId = pyEnv["mail.message"].create({
@@ -324,8 +325,8 @@ QUnit.test(
name: "test",
channel_type: "chat",
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId }],
Command.create({ partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId }),
],
});
const [, messageId_2] = pyEnv["mail.message"].create([
@@ -367,8 +368,8 @@ QUnit.test(
name: "test",
channel_type: "chat",
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId }],
Command.create({ partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId }),
],
});
const messageId = pyEnv["mail.message"].create({
@@ -9,6 +9,8 @@ import {
nextAnimationFrame,
waitUntil,
} from "@mail/../tests/helpers/test_utils";
import { Command } from "@mail/../tests/helpers/command";
import { deserializeDateTime } from "@web/core/l10n/dates";
const { DateTime } = luxon;
import {
@@ -642,8 +644,8 @@ QUnit.test("redirect to author (open chat)", async (assert) => {
{ name: "General" },
{
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId }],
Command.create({ partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId }),
],
channel_type: "chat",
},
@@ -668,7 +670,7 @@ QUnit.test("open chat from avatar should not work on self-authored messages", as
const [channelId] = pyEnv["discuss.channel"].create([
{ name: "General" },
{
channel_member_ids: [[0, 0, { partner_id: pyEnv.currentPartnerId }]],
channel_member_ids: [Command.create({ partner_id: pyEnv.currentPartnerId })],
channel_type: "chat",
},
]);
@@ -1273,8 +1275,8 @@ QUnit.test(
const channelId = pyEnv["discuss.channel"].create({
name: "test",
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId }],
Command.create({ partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId }),
],
channel_type: "chat",
});
@@ -7,6 +7,7 @@ import {
start,
startServer,
} from "@mail/../tests/helpers/test_utils";
import { Command } from "@mail/../tests/helpers/command";
QUnit.module("messaging");
@@ -18,8 +19,8 @@ QUnit.test(
const userId = pyEnv["res.users"].create({ partner_id: partnerId });
const channelId = pyEnv["discuss.channel"].create({
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId }],
Command.create({ partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId }),
],
channel_type: "chat",
});
@@ -45,8 +46,8 @@ QUnit.test(
const userId = pyEnv["res.users"].create({ partner_id: partnerId });
const channelId = pyEnv["discuss.channel"].create({
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId }],
Command.create({ partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId }),
],
channel_type: "chat",
});
@@ -72,8 +73,8 @@ QUnit.test(
const partnerId = pyEnv["res.partner"].create({ name: "Dumbledore" });
const channelId = pyEnv["discuss.channel"].create({
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId }],
Command.create({ partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId }),
],
channel_type: "chat",
});
@@ -8,6 +8,8 @@ import {
startServer,
waitUntil,
} from "@mail/../tests/helpers/test_utils";
import { Command } from "@mail/../tests/helpers/command";
import { makeFakeNotificationService } from "@web/../tests/helpers/mock_services";
import { patchWithCleanup, triggerHotkey } from "@web/../tests/helpers/utils";
import { patchBrowserNotification } from "@mail/../tests/helpers/patch_notifications";
@@ -317,8 +319,8 @@ QUnit.test("mark unread channel as read", async (assert) => {
const partnerId = pyEnv["res.partner"].create({ name: "Demo" });
const channelId = pyEnv["discuss.channel"].create({
channel_member_ids: [
[0, 0, { message_unread_counter: 1, partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId }],
Command.create({ message_unread_counter: 1, partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId }),
],
});
const [messagId_1] = pyEnv["mail.message"].create([
@@ -356,7 +358,7 @@ QUnit.test("mark failure as read", async (assert) => {
pyEnv["discuss.channel"].create({
message_ids: [messageId],
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId, seen_message_id: messageId }],
Command.create({ partner_id: pyEnv.currentPartnerId, seen_message_id: messageId }),
],
});
pyEnv["mail.notification"].create({
@@ -841,7 +843,7 @@ QUnit.test(
const channelId = pyEnv["discuss.channel"].create({
name: "Test",
channel_member_ids: [
[0, 0, { message_unread_counter: 2, partner_id: pyEnv.currentPartnerId }],
Command.create({ message_unread_counter: 2, partner_id: pyEnv.currentPartnerId }),
],
});
const messageId = pyEnv["mail.message"].create({
@@ -882,8 +884,8 @@ QUnit.test("chat should show unread counter on receiving new messages", async (a
const channelId = pyEnv["discuss.channel"].create({
channel_type: "chat",
channel_member_ids: [
[0, 0, { message_unread_counter: 0, partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId }],
Command.create({ message_unread_counter: 0, partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId }),
],
});
await start();
@@ -2,6 +2,8 @@
import { Composer } from "@mail/composer/composer";
import { click, insertText, start, startServer } from "@mail/../tests/helpers/test_utils";
import { Command } from "@mail/../tests/helpers/command";
import {
makeDeferred,
nextTick,
@@ -34,9 +36,9 @@ QUnit.test('display partner mention suggestions on typing "@"', async (assert) =
const channelId = pyEnv["discuss.channel"].create({
name: "general",
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId_1 }],
[0, 0, { partner_id: partnerId_2 }],
Command.create({ partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId_1 }),
Command.create({ partner_id: partnerId_2 }),
],
});
const { openDiscuss } = await start();
@@ -63,9 +65,9 @@ QUnit.test(
const channelId = pyEnv["discuss.channel"].create({
name: "general",
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId_1 }],
[0, 0, { partner_id: partnerId_2 }],
Command.create({ partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId_1 }),
Command.create({ partner_id: partnerId_2 }),
],
});
const { openDiscuss } = await start();
@@ -99,8 +101,8 @@ QUnit.test("show other channel member in @ mention", async (assert) => {
const channelId = pyEnv["discuss.channel"].create({
name: "general",
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId }],
Command.create({ partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId }),
],
});
const { openDiscuss } = await start();
@@ -118,8 +120,8 @@ QUnit.test("select @ mention insert mention text in composer", async (assert) =>
const channelId = pyEnv["discuss.channel"].create({
name: "general",
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId }],
Command.create({ partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId }),
],
});
const { openDiscuss } = await start();
+15 -14
View File
@@ -13,6 +13,7 @@ import {
startServer,
waitUntil,
} from "@mail/../tests/helpers/test_utils";
import { Command } from "@mail/../tests/helpers/command";
import {
makeDeferred,
@@ -240,8 +241,8 @@ QUnit.test(
const channelId = pyEnv["discuss.channel"].create({
name: "test",
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId }],
Command.create({ partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId }),
],
channel_type: "chat",
});
@@ -429,7 +430,7 @@ QUnit.test(
const pyEnv = await startServer();
const channelId = pyEnv["discuss.channel"].create({
channel_member_ids: [
[0, 0, { message_unread_counter: 0, partner_id: pyEnv.currentPartnerId }],
Command.create({ message_unread_counter: 0, partner_id: pyEnv.currentPartnerId }),
],
channel_type: "channel",
name: "General",
@@ -470,7 +471,7 @@ QUnit.test("new messages separator on receiving new message [REQUIRE FOCUS]", as
});
const channelId = pyEnv["discuss.channel"].create({
channel_member_ids: [
[0, 0, { message_unread_counter: 0, partner_id: pyEnv.currentPartnerId }],
Command.create({ message_unread_counter: 0, partner_id: pyEnv.currentPartnerId }),
],
channel_type: "channel",
name: "General",
@@ -513,7 +514,7 @@ QUnit.test("no new messages separator on posting message (no message history)",
const pyEnv = await startServer();
const channelId = pyEnv["discuss.channel"].create({
channel_member_ids: [
[0, 0, { message_unread_counter: 0, partner_id: pyEnv.currentPartnerId }],
Command.create({ message_unread_counter: 0, partner_id: pyEnv.currentPartnerId }),
],
channel_type: "channel",
name: "General",
@@ -538,8 +539,8 @@ QUnit.test("Mention a partner with special character (e.g. apostrophe ')", async
const channelId = pyEnv["discuss.channel"].create({
name: "test",
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId }],
Command.create({ partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId }),
],
});
const { openDiscuss } = await start();
@@ -569,9 +570,9 @@ QUnit.test("mention 2 different partners that have the same name", async (assert
const channelId = pyEnv["discuss.channel"].create({
name: "test",
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId_1 }],
[0, 0, { partner_id: partnerId_2 }],
Command.create({ partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId_1 }),
Command.create({ partner_id: partnerId_2 }),
],
});
const { openDiscuss } = await start();
@@ -669,8 +670,8 @@ QUnit.test(
const channelId = pyEnv["discuss.channel"].create({
name: "test",
channel_member_ids: [
[0, 0, { partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId }],
Command.create({ partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId }),
],
});
const { openDiscuss } = await start();
@@ -960,8 +961,8 @@ QUnit.test("can be marked as read while loading", async function (assert) {
const partnerId = pyEnv["res.partner"].create({ name: "Demo" });
const channelId = pyEnv["discuss.channel"].create({
channel_member_ids: [
[0, 0, { message_unread_counter: 1, partner_id: pyEnv.currentPartnerId }],
[0, 0, { partner_id: partnerId }],
Command.create({ message_unread_counter: 1, partner_id: pyEnv.currentPartnerId }),
Command.create({ partner_id: partnerId }),
],
channel_type: "chat",
});