From 96debc07647889a80fd4490bc308c575cff05d4b Mon Sep 17 00:00:00 2001 From: Rahul Prajapati Date: Mon, 19 Feb 2024 18:16:32 +0530 Subject: [PATCH] [FIX] mail: squashed transient message has date MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before this commit: Squashed transient messages had date displayed in the sidebar of the message. This was introduced by this commit: 631ae1c After this commit: Squashed transient messages would not have date in the message sidebar. closes odoo/odoo#154594 Signed-off-by: Alexandre Kühn (aku) --- .../mail/static/src/core/common/message.xml | 2 +- .../static/src/core/common/thread_model.js | 2 +- .../static/tests/message/message_tests.js | 37 +++++++++++++++++++ 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/addons/mail/static/src/core/common/message.xml b/addons/mail/static/src/core/common/message.xml index ade64face50..86fa237e177 100644 --- a/addons/mail/static/src/core/common/message.xml +++ b/addons/mail/static/src/core/common/message.xml @@ -18,7 +18,7 @@
- + diff --git a/addons/mail/static/src/core/common/thread_model.js b/addons/mail/static/src/core/common/thread_model.js index ef368c0a41f..0a2f65ee90e 100644 --- a/addons/mail/static/src/core/common/thread_model.js +++ b/addons/mail/static/src/core/common/thread_model.js @@ -492,7 +492,7 @@ export class Thread extends Record { } get persistentMessages() { - return this.messages.filter((message) => !message.isTransient); + return this.messages.filter((message) => !message.is_transient); } get prefix() { diff --git a/addons/mail/static/tests/message/message_tests.js b/addons/mail/static/tests/message/message_tests.js index 4ec78263108..4555b9429e8 100644 --- a/addons/mail/static/tests/message/message_tests.js +++ b/addons/mail/static/tests/message/message_tests.js @@ -9,6 +9,8 @@ import { deserializeDateTime } from "@web/core/l10n/dates"; import { getOrigin } from "@web/core/utils/urls"; import { makeDeferred, + nextTick, + patchDate, patchTimeZone, patchWithCleanup, triggerHotkey, @@ -672,6 +674,41 @@ QUnit.test("should not be able to reply to temporary/transient messages", async await contains(".o-mail-Message [title='Reply']", { count: 0 }); }); +QUnit.test("squashed transient message should not have date in the sidebar", async () => { + patchDate(2024, 2, 26, 10, 0, 0); + const pyEnv = await startServer(); + const channelId = pyEnv["discuss.channel"].create({ name: "Channel 1" }); + pyEnv["mail.message"].create([ + { + body: "Hello world 1", + model: "discuss.channel", + res_id: channelId, + }, + { + body: "Hello world 2", + model: "discuss.channel", + res_id: channelId, + }, + ]); + const { openDiscuss } = await start(); + await openDiscuss(channelId); + await click(".o-mail-Message.o-squashed"); + await contains(".o-mail-Message.o-squashed .o-mail-Message-sidebar", { + text: "10:00", + }); + await insertText(".o-mail-Composer-input", "/who"); + await click(".o-mail-Composer-send:enabled"); + await contains(".o-mail-Message", { text: "You are alone in this channel." }); + await insertText(".o-mail-Composer-input", "/who"); + await click(".o-mail-Composer-send:enabled"); + await click(":nth-child(2 of .o-mail-Message.o-squashed"); + await nextTick(); + await contains(":nth-child(2 of .o-mail-Message.o-squashed) .o-mail-Message-sidebar", { + text: "10:00", + count: 0, + }); +}); + QUnit.test("message comment of same author within 1min. should be squashed", async () => { // messages are squashed when "close", e.g. less than 1 minute has elapsed // from messages of same author and same thread. Note that this should