diff --git a/addons/mail/static/src/core/common/thread_service.js b/addons/mail/static/src/core/common/thread_service.js index a41172d0b26..45f4676c56d 100644 --- a/addons/mail/static/src/core/common/thread_service.js +++ b/addons/mail/static/src/core/common/thread_service.js @@ -316,12 +316,15 @@ export class ThreadService { ...this.getFetchParams(thread), around: messageId, }); - thread.messages = messages.reverse().map((message) => - this.messageService.insert({ + thread.messages = messages.reverse().map((message) => { + if (message.parentMessage?.body) { + message.parentMessage.body = markup(message.parentMessage.body); + } + return this.messageService.insert({ ...message, body: message.body ? markup(message.body) : message.body, - }) - ); + }); + }); thread.loadNewer = messageId ? true : false; thread.loadOlder = true; if (messages.length < FETCH_LIMIT) { diff --git a/addons/mail/static/tests/discuss_app/jump_to_present_tests.js b/addons/mail/static/tests/discuss_app/jump_to_present_tests.js index 7a830a088c1..7d38f6e4ef0 100644 --- a/addons/mail/static/tests/discuss_app/jump_to_present_tests.js +++ b/addons/mail/static/tests/discuss_app/jump_to_present_tests.js @@ -62,15 +62,22 @@ QUnit.test("Jump to old reply should prompt jump to presence", async (assert) => const pyEnv = await startServer(); const channelId = pyEnv["discuss.channel"].create({ name: "General" }); const oldestMessageId = pyEnv["mail.message"].create({ - body: "Hello world!", + body: "
Hello world!
", model: "discuss.channel", res_id: channelId, }); for (let i = 0; i < 100; i++) { pyEnv["mail.message"].create({ - body: "Non Empty Body ".repeat(100), + body: "Non Empty Body
".repeat(100), message_type: "comment", model: "discuss.channel", + /** + * The first message following the oldest message should have it as its parent message + * so that the oldest message is inserted through the parent field during "load around" + * to have the coverage of this part of the code (in particular having parent message + * body being inserted with markup). + */ + parent_id: i === 0 ? oldestMessageId : undefined, res_id: channelId, }); } @@ -84,6 +91,11 @@ QUnit.test("Jump to old reply should prompt jump to presence", async (assert) => await openDiscuss(channelId); await click(".o-mail-MessageInReply .cursor-pointer"); assert.isVisible($(".o-mail-Message:contains(Hello world!):eq(0)")[0]); + assert.strictEqual( + $(".o-mail-Message-body:contains(Hello world!):eq(0)").text(), + "Hello world!", + "should correctly execute HTML tags in parent message when using 'load around' feature" + ); assert.containsOnce($, ".o-mail-Thread:contains(You're viewing older messagesJump to Present)"); await click(".o-mail-Thread-jumpPresent"); await nextAnimationFrame();