summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandre Kühn <aku@odoo.com>2018-11-14 20:19:59 +0000
committerAlexandre Kühn <aku@odoo.com>2018-11-14 20:29:29 +0000
commit2b245ebb436a6880f05e25c65470bd48c3eea4a5 (patch)
treed3068786ef73cf5a8eb290fe8657b30f08467d01
parent774991946e491ee1c7fdf772405bc0e2c111fdaa (diff)
[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
-rw-r--r--addons/mail/static/src/js/models/threads/mailbox.js2
-rw-r--r--addons/mail/static/tests/systray/systray_messaging_menu_tests.js63
2 files changed, 64 insertions, 1 deletions
diff --git a/addons/mail/static/src/js/models/threads/mailbox.js b/addons/mail/static/src/js/models/threads/mailbox.js
index 8d49d84d777..82d65bdd6cc 100644
--- a/addons/mail/static/src/js/models/threads/mailbox.js
+++ b/addons/mail/static/src/js/models/threads/mailbox.js
@@ -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,
diff --git a/addons/mail/static/tests/systray/systray_messaging_menu_tests.js b/addons/mail/static/tests/systray/systray_messaging_menu_tests.js
index 30447b714b1..1b608f5c37b 100644
--- a/addons/mail/static/tests/systray/systray_messaging_menu_tests.js
+++ b/addons/mail/static/tests/systray/systray_messaging_menu_tests.js
@@ -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();
+});
+
});
});