Files
odoo_source/addons/mail/static/tests/message/message_reply_tests.js
T
tsm-odoo 1c1604466f [IMP] mail, im_livechat: add pin messages feature to channels
With this commit, messages can be pinned on a channel and
chat conversation. There's a new menu listing all pinned
messages on a conversation, and we can jump to these messages
in the current conversation.

As this feature incentives to see older messages, this commit
also adds a "Jump to Present" button when looking at old messages.

closes odoo/odoo#116666

Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
2023-04-13 04:08:11 +02:00

65 lines
2.2 KiB
JavaScript

/** @odoo-module **/
import { click, start, startServer } from "@mail/../tests/helpers/test_utils";
import { nextTick, patchWithCleanup } from "@web/../tests/helpers/utils";
QUnit.module("message reply");
QUnit.test("click on message in reply to highlight the parent message", async (assert) => {
const pyEnv = await startServer();
const channelId = pyEnv["mail.channel"].create({ name: "general" });
const messageId = pyEnv["mail.message"].create({
body: "Hey lol",
message_type: "comment",
model: "mail.channel",
res_id: channelId,
});
pyEnv["mail.message"].create({
body: "Reply to Hey",
message_type: "comment",
model: "mail.channel",
parent_id: messageId,
res_id: channelId,
});
const { openDiscuss } = await start();
await openDiscuss(channelId);
await click(".o-mail-Message:contains(Reply to Hey) .o-mail-MessageInReply-message");
assert.containsOnce($, ".o-mail-Message:contains(Hey lol).o-highlighted");
});
QUnit.test("click on message in reply to scroll to the parent message", async (assert) => {
// make scroll behavior instantaneous.
patchWithCleanup(Element.prototype, {
scrollIntoView() {
return this._super(true);
},
});
const pyEnv = await startServer();
const channelId = pyEnv["mail.channel"].create({ name: "general" });
const [oldestMessageId] = pyEnv["mail.message"].create(
Array(20)
.fill(0)
.map(() => ({
body: "Non Empty Body ".repeat(25),
message_type: "comment",
model: "mail.channel",
res_id: channelId,
}))
);
pyEnv["mail.message"].create({
body: "Response to first message",
message_type: "comment",
model: "mail.channel",
parent_id: oldestMessageId,
res_id: channelId,
});
const { openDiscuss } = await start();
await openDiscuss(channelId);
await click(
".o-mail-Message:contains(Response to first message) .o-mail-MessageInReply-message"
);
await nextTick();
assert.isVisible($(".o-mail-Message:eq(0)"));
});