[FIX] mail: no crash on grouped inbox messages previews
Revision on https://github.com/odoo/odoo/commit/5f8d3c61bee40d027efc5041cdc4bca5e67c42d7 Before this commit, there was a traceback when you had two needaction notifications related to the same document. This is caused by a typo in the commit above: the object `similarItem` has a property `messageIDs`, but the code wrongly access the property `messagesIDs` (see the extra "s"). Steps to reproduce: - Set notification management to 'Handle with Odoo' for Admin - Demo mention Admin twice on a specific project task - Admin opens messaging menu Display error `Cannot read property 'concat' of undefined` Issue reported on this PR comment: https://github.com/odoo/odoo/pull/28462#pullrequestreview-175001349 Task-ID 1909521 closes odoo/odoo#28703
This commit is contained in:
@@ -82,7 +82,7 @@ var Mailbox = SearchableThread.extend({
|
||||
});
|
||||
if (similarItem) {
|
||||
unreadCounter = similarItem.unreadCounter + 1;
|
||||
messageIDs = similarItem.messagesIDs.concat(messageIDs);
|
||||
messageIDs = similarItem.messageIDs.concat(messageIDs);
|
||||
var index = _.findIndex(items, similarItem);
|
||||
items[index] = {
|
||||
unreadCounter: unreadCounter,
|
||||
|
||||
@@ -523,5 +523,68 @@ QUnit.test('preview of inbox message not linked to document + mark as read', fun
|
||||
messagingMenu.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('grouped preview for needaction messages linked to same document', function (assert) {
|
||||
assert.expect(5);
|
||||
|
||||
// simulate two (read) needaction (mention) messages in channel 'general'
|
||||
var needactionMessage1 = {
|
||||
author_id: [1, "Demo"],
|
||||
body: "<p>@Administrator: ping</p>",
|
||||
channel_ids: [1],
|
||||
id: 3,
|
||||
model: 'mail.channel',
|
||||
needaction: true,
|
||||
needaction_partner_ids: [44],
|
||||
record_name: 'general',
|
||||
res_id: 1,
|
||||
};
|
||||
var needactionMessage2 = {
|
||||
author_id: [2, "Other"],
|
||||
body: "<p>@Administrator: pong</p>",
|
||||
channel_ids: [1],
|
||||
id: 4,
|
||||
model: 'mail.channel',
|
||||
needaction: true,
|
||||
needaction_partner_ids: [44],
|
||||
record_name: 'general',
|
||||
res_id: 1,
|
||||
};
|
||||
this.data['mail.message'].records = [needactionMessage1, needactionMessage2];
|
||||
this.data.initMessaging.channel_slots.channel_channel[0].message_unread_counter = 0;
|
||||
this.data.initMessaging.needaction_inbox_counter = 2;
|
||||
|
||||
var messagingMenu = new MessagingMenu();
|
||||
testUtils.addMockEnvironment(messagingMenu, {
|
||||
services: this.services,
|
||||
data: this.data,
|
||||
session: {
|
||||
partner_id: 44,
|
||||
},
|
||||
});
|
||||
messagingMenu.appendTo($('#qunit-fixture'));
|
||||
|
||||
messagingMenu.$('.dropdown-toggle').click();
|
||||
var $previews = messagingMenu.$('.o_mail_preview');
|
||||
|
||||
assert.strictEqual($previews.length, 2,
|
||||
"should display two previews (one for needaction, one for channel)");
|
||||
|
||||
var $needactionPreview = $previews.eq(0);
|
||||
var $channelPreview = $previews.eq(1);
|
||||
|
||||
assert.strictEqual($needactionPreview.find('.o_preview_counter').text().trim(), "(2)",
|
||||
"should show two needaction messages in the needaction preview");
|
||||
assert.strictEqual($needactionPreview.find('.o_last_message_preview').text().replace(/\s/g, ""),
|
||||
"Other:@Administrator:pong",
|
||||
"should display last needaction message on needaction preview");
|
||||
assert.strictEqual($channelPreview.find('.o_preview_counter').text().trim(), "",
|
||||
"should show no unread messages in the channel preview");
|
||||
assert.strictEqual($channelPreview.find('.o_last_message_preview').text().replace(/\s/g, ""),
|
||||
"Other:@Administrator:pong",
|
||||
"should display last needaction message on channel preview");
|
||||
|
||||
messagingMenu.destroy();
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user