summaryrefslogtreecommitdiff
path: root/addons/mail/static/src/components/thread_view/thread_view_tests.js
diff options
context:
space:
mode:
authorXavier Dubuc <xdu@odoo.com>2020-09-03 16:24:19 +0000
committerSébastien Theys <seb@odoo.com>2020-09-04 14:59:01 +0000
commit8d3413ff647de8d98c6858062dd07dde4160af95 (patch)
tree3dc134e83c874d5c7f7bf739f13a88ab986ddb1b /addons/mail/static/src/components/thread_view/thread_view_tests.js
parenta5ab687be4e7890262ce9429e18dd011021513d5 (diff)
[FIX] mail, sms, snailmail: prevent message_fetch for hidden threads
Automatically load messages from a thread cache only if the thread cache is used in at least one thread view. Ensure thread viewer don't keep thread view records alive when they are not displayed. This change is particularly important for performance, to avoid spamming RPC at init if many threads are opened in chat windows. task-2310623 closes odoo/odoo#57061 X-original-commit: dd6981c7812134e0588f80a157eaba45512cd68e Related: odoo/enterprise#12936 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Diffstat (limited to 'addons/mail/static/src/components/thread_view/thread_view_tests.js')
-rw-r--r--addons/mail/static/src/components/thread_view/thread_view_tests.js43
1 files changed, 30 insertions, 13 deletions
diff --git a/addons/mail/static/src/components/thread_view/thread_view_tests.js b/addons/mail/static/src/components/thread_view/thread_view_tests.js
index c8f41632ae3..2d0b3207ae1 100644
--- a/addons/mail/static/src/components/thread_view/thread_view_tests.js
+++ b/addons/mail/static/src/components/thread_view/thread_view_tests.js
@@ -81,8 +81,11 @@ QUnit.test('dragover files on thread with composer', async function (assert) {
name: "General",
public: 'public',
});
- const threadView = this.env.models['mail.thread_view'].create({ thread: [['link', thread]] });
- await this.createThreadViewComponent(threadView, { hasComposer: true });
+ const threadViewer = this.env.models['mail.thread_viewer'].create({
+ hasThreadView: true,
+ thread: [['link', thread]],
+ });
+ await this.createThreadViewComponent(threadViewer.threadView, { hasComposer: true });
await afterNextRender(() =>
dragenterFiles(document.querySelector('.o_ThreadView'))
);
@@ -122,8 +125,11 @@ QUnit.test('message list desc order', async function (assert) {
name: "General",
public: 'public',
});
- const threadView = this.env.models['mail.thread_view'].create({ thread: [['link', thread]] });
- await this.createThreadViewComponent(threadView, { order: 'desc' }, { isFixedSize: true });
+ const threadViewer = this.env.models['mail.thread_viewer'].create({
+ hasThreadView: true,
+ thread: [['link', thread]],
+ });
+ await this.createThreadViewComponent(threadViewer.threadView, { order: 'desc' }, { isFixedSize: true });
const messageItems = document.querySelectorAll(`.o_MessageList_item`);
assert.notOk(
messageItems[0].classList.contains("o_MessageList_loadMore"),
@@ -190,8 +196,11 @@ QUnit.test('message list asc order', async function (assert) {
name: "General",
public: 'public',
});
- const threadView = this.env.models['mail.thread_view'].create({ thread: [['link', thread]] });
- await this.createThreadViewComponent(threadView, { order: 'asc' }, { isFixedSize: true });
+ const threadViewer = this.env.models['mail.thread_viewer'].create({
+ hasThreadView: true,
+ thread: [['link', thread]],
+ });
+ await this.createThreadViewComponent(threadViewer.threadView, { order: 'asc' }, { isFixedSize: true });
const messageItems = document.querySelectorAll(`.o_MessageList_item`);
assert.notOk(
messageItems[messageItems.length - 1].classList.contains("o_MessageList_loadMore"),
@@ -283,8 +292,11 @@ QUnit.test('mark channel as fetched when a new message is loaded and as seen whe
model: 'mail.channel',
});
- const threadView = this.env.models['mail.thread_view'].create({ thread: [['link', thread]] });
- await this.createThreadViewComponent(threadView, { hasComposer: true });
+ const threadViewer = this.env.models['mail.thread_viewer'].create({
+ hasThreadView: true,
+ thread: [['link', thread]],
+ });
+ await this.createThreadViewComponent(threadViewer.threadView, { hasComposer: true });
const notifications = [
[['myDB', 'mail.channel', 100], {
channelId: 100,
@@ -353,9 +365,11 @@ QUnit.test('mark channel as fetched and seen when a new message is loaded if com
model: 'mail.channel',
});
- const threadView = this.env.models['mail.thread_view'].create({ thread: [['link', thread]] });
- await this.createThreadViewComponent(threadView, { hasComposer: true });
-
+ const threadViewer = this.env.models['mail.thread_viewer'].create({
+ hasThreadView: true,
+ thread: [['link', thread]],
+ });
+ await this.createThreadViewComponent(threadViewer.threadView, { hasComposer: true });
document.querySelector('.o_ComposerTextInput_textarea').focus();
const notifications = [
[['myDB', 'mail.channel', 100], {
@@ -394,8 +408,11 @@ QUnit.test('show message subject if thread is mailing channel', async function (
name: "General",
public: 'public',
});
- const threadView = this.env.models['mail.thread_view'].create({ thread: [['link', thread]] });
- await this.createThreadViewComponent(threadView);
+ const threadViewer = this.env.models['mail.thread_viewer'].create({
+ hasThreadView: true,
+ thread: [['link', thread]],
+ });
+ await this.createThreadViewComponent(threadViewer.threadView);
assert.containsOnce(
document.body,