diff options
| author | Sébastien Theys <seb@odoo.com> | 2020-09-29 18:50:23 +0000 |
|---|---|---|
| committer | Sébastien Theys <seb@odoo.com> | 2020-09-29 19:47:12 +0000 |
| commit | fb9b1c8a169840951925fa810f71e865a54e3a31 (patch) | |
| tree | 591c34b02dfdde95ebaf296db7abfee5614e22ea /addons/mail/static/src/components/discuss/tests | |
| parent | b4783500db5b7c645859227e8be5cd55025b2882 (diff) | |
[FIX] mail: reintroduce auto scroll on receiving message
task-2336251
closes odoo/odoo#58867
X-original-commit: f732980b2e5e83bcf2fdc8d3ce756f256cacbd4f
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
Diffstat (limited to 'addons/mail/static/src/components/discuss/tests')
| -rw-r--r-- | addons/mail/static/src/components/discuss/tests/discuss_tests.js | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/addons/mail/static/src/components/discuss/tests/discuss_tests.js b/addons/mail/static/src/components/discuss/tests/discuss_tests.js index cbd7c8136a1..67d52c33c88 100644 --- a/addons/mail/static/src/components/discuss/tests/discuss_tests.js +++ b/addons/mail/static/src/components/discuss/tests/discuss_tests.js @@ -1809,7 +1809,20 @@ QUnit.test('new messages separator [REQUIRE FOCUS]', async function (assert) { "should not display 'new messages' separator" ); // scroll to top - document.querySelector(`.o_Discuss_thread .o_ThreadView_messageList`).scrollTop = 0; + await this.afterEvent({ + eventName: 'o-component-message-list-scrolled', + func: () => { + document.querySelector(`.o_Discuss_thread .o_ThreadView_messageList`).scrollTop = 0; + }, + message: "should wait until channel scrolled to top", + predicate: ({ scrollTop, threadViewer }) => { + return ( + threadViewer.thread.model === 'mail.channel' && + threadViewer.thread.id === 20 && + scrollTop === 0 + ); + }, + }); // composer is focused by default, we remove that focus document.querySelector('.o_ComposerTextInput_textarea').blur(); // simulate receiving a message @@ -1835,9 +1848,21 @@ QUnit.test('new messages separator [REQUIRE FOCUS]', async function (assert) { '.o_MessageList_separatorNewMessages', "should display 'new messages' separator" ); - await afterNextRender(() => { - document.querySelector(`.o_Discuss_thread .o_ThreadView_messageList`).scrollTop = - document.querySelector(`.o_Discuss_thread .o_ThreadView_messageList`).scrollHeight; + await this.afterEvent({ + eventName: 'o-component-message-list-scrolled', + func: () => { + const messageList = document.querySelector(`.o_Discuss_thread .o_ThreadView_messageList`); + messageList.scrollTop = messageList.scrollHeight - messageList.clientHeight; + }, + message: "should wait until channel scrolled to bottom", + predicate: ({ scrollTop, threadViewer }) => { + const messageList = document.querySelector(`.o_Discuss_thread .o_ThreadView_messageList`); + return ( + threadViewer.thread.model === 'mail.channel' && + threadViewer.thread.id === 20 && + scrollTop === messageList.scrollHeight - messageList.clientHeight + ); + }, }); assert.containsOnce( document.body, |
