diff options
| author | Xavier Dubuc <xdu@odoo.com> | 2020-11-02 11:31:13 +0000 |
|---|---|---|
| committer | Sébastien Theys <seb@odoo.com> | 2020-11-02 11:31:13 +0000 |
| commit | 03481fd3df9bc53a17ba884ad4029ae46d7e54bf (patch) | |
| tree | 4e374aad0a7a6c845ee605b77cbe4e282efb7391 /addons/mail/static/src/components/thread_needaction_preview | |
| parent | b3e31f2680534382b048324cfcb8a6f6c457553f (diff) | |
[FIX] mail: handle transient messages with (un)seen notions
task-2343887
closes odoo/odoo#60906
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Diffstat (limited to 'addons/mail/static/src/components/thread_needaction_preview')
2 files changed, 55 insertions, 2 deletions
diff --git a/addons/mail/static/src/components/thread_needaction_preview/thread_needaction_preview.xml b/addons/mail/static/src/components/thread_needaction_preview/thread_needaction_preview.xml index b6a5c896174..3047003f292 100644 --- a/addons/mail/static/src/components/thread_needaction_preview/thread_needaction_preview.xml +++ b/addons/mail/static/src/components/thread_needaction_preview/thread_needaction_preview.xml @@ -39,9 +39,9 @@ </div> <div class="o_ThreadNeedactionPreview_core"> <span class="o_ThreadNeedactionPreview_coreItem o_ThreadNeedactionPreview_inlineText" t-att-class="{ 'o-empty': inlineLastNeedactionMessageBody.length === 0 }"> - <t t-if="thread.lastMessage and thread.lastMessage.author"> + <t t-if="thread.lastNeedactionMessage and thread.lastNeedactionMessage.author"> <MessageAuthorPrefix - messageLocalId="thread.lastMessage.localId" + messageLocalId="thread.lastNeedactionMessage.localId" threadLocalId="thread.localId" /> </t> diff --git a/addons/mail/static/src/components/thread_needaction_preview/thread_needaction_preview_tests.js b/addons/mail/static/src/components/thread_needaction_preview/thread_needaction_preview_tests.js index 9e2f19ffbaf..fe01b8f7c7d 100644 --- a/addons/mail/static/src/components/thread_needaction_preview/thread_needaction_preview_tests.js +++ b/addons/mail/static/src/components/thread_needaction_preview/thread_needaction_preview_tests.js @@ -292,6 +292,59 @@ QUnit.test('[technical] opening a non-channel chat window should not call channe ); }); +QUnit.test('preview should display last needaction message preview even if there is a more recent message that is not needaction in the thread', async function (assert) { + assert.expect(2); + + this.data['res.partner'].records.push({ + id: 11, + name: "Stranger", + }); + this.data['mail.message'].records.push({ + author_id: 11, + body: "I am the oldest but needaction", + id: 21, + model: 'res.partner', + needaction: true, + needaction_partner_ids: [this.data.currentPartnerId], + res_id: 11, + }); + this.data['mail.message'].records.push({ + author_id: this.data.currentPartnerId, + body: "I am more recent", + id: 22, + model: 'res.partner', + res_id: 11, + }); + this.data['mail.notification'].records.push({ + mail_message_id: 21, + notification_status: 'sent', + notification_type: 'inbox', + res_partner_id: this.data.currentPartnerId, + }); + await this.start({ + hasChatWindow: true, + hasMessagingMenu: true, + }); + await afterNextRender(() => this.afterEvent({ + eventName: 'o-thread-cache-loaded-messages', + func: () => document.querySelector('.o_MessagingMenu_toggler').click(), + message: "should wait until inbox loaded initial needaction messages", + predicate: ({ threadCache }) => { + return threadCache.thread.model === 'mail.box' && threadCache.thread.id === 'inbox'; + }, + })); + assert.containsOnce( + document.body, + '.o_ThreadNeedactionPreview_inlineText', + "should have a preview from the last message" + ); + assert.strictEqual( + document.querySelector('.o_ThreadNeedactionPreview_inlineText').textContent, + 'Stranger: I am the oldest but needaction', + "the displayed message should be the one that needs action even if there is a more recent message that is not needaction on the thread" + ); +}); + }); }); }); |
