diff options
| author | Sébastien Theys <seb@odoo.com> | 2020-08-05 14:03:05 +0000 |
|---|---|---|
| committer | Sébastien Theys <seb@odoo.com> | 2020-08-05 15:09:34 +0000 |
| commit | 9216bdcb6f0bbb20900a33bbf7283e6e4fda1b2c (patch) | |
| tree | ce2c02403afc038f552436997fb3ba9f3ab1c1ac /addons/mail/static/src/components | |
| parent | 9432d547053605a0807e82499123c0deede23d6b (diff) | |
[FIX] mail: clean up JS relations by storing records
Remove the support and the conversion from record to localId and back from
localId to record.
Part of task-2308312
closes odoo/odoo#55481
X-original-commit: fc5e8be4e65518770a281f0dffae07854d20073a
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Diffstat (limited to 'addons/mail/static/src/components')
6 files changed, 26 insertions, 6 deletions
diff --git a/addons/mail/static/src/components/chat_window_manager/chat_window_manager_tests.js b/addons/mail/static/src/components/chat_window_manager/chat_window_manager_tests.js index fb4c92d70c7..6e284a7156c 100644 --- a/addons/mail/static/src/components/chat_window_manager/chat_window_manager_tests.js +++ b/addons/mail/static/src/components/chat_window_manager/chat_window_manager_tests.js @@ -750,7 +750,7 @@ QUnit.test('focus next visible chat window when closing current chat window with QUnit.test('[technical] chat window: composer state conservation on toggle home menu', async function (assert) { // technical as show/hide home menu simulation are involved and home menu implementation // have side-effects on DOM that may make chat window components not work - assert.expect(6); + assert.expect(7); Object.assign(this.data.initMessaging, { channel_slots: { @@ -775,6 +775,11 @@ QUnit.test('[technical] chat window: composer state conservation on toggle home document.querySelector(`.o_ComposerTextInput_textarea`).focus(); document.execCommand('insertText', false, 'XDU for the win !'); }); + assert.containsNone( + document.body, + '.o_Composer .o_Attachment', + "composer should have no attachment initially" + ); // Set attachments of the composer const files = [ await createFile({ @@ -803,7 +808,7 @@ QUnit.test('[technical] chat window: composer state conservation on toggle home document.body, '.o_Composer .o_Attachment', 2, - "verify chat window composer initial attachment count" + "composer should have 2 total attachments after adding 2 attachments" ); await this.hideHomeMenu(); diff --git a/addons/mail/static/src/components/chatter/chatter_tests.js b/addons/mail/static/src/components/chatter/chatter_tests.js index 36b87b65f5d..0b25b9f3d4e 100644 --- a/addons/mail/static/src/components/chatter/chatter_tests.js +++ b/addons/mail/static/src/components/chatter/chatter_tests.js @@ -55,6 +55,7 @@ QUnit.module('chatter_tests.js', { QUnit.test('base rendering when chatter has no attachment', async function (assert) { assert.expect(6); + this.data['res.partner'].records.push({ id: 100 }); const messages = [...Array(60).keys()].map(id => { return { author_id: [10, "Demo User"], @@ -157,6 +158,7 @@ QUnit.test('base rendering when chatter has no record', async function (assert) QUnit.test('base rendering when chatter has attachments', async function (assert) { assert.expect(3); + this.data['res.partner'].records.push({ id: 100 }); await this.start({ async mockRPC(route, args) { if (route.includes('ir.attachment/search_read')) { @@ -200,6 +202,7 @@ QUnit.test('base rendering when chatter has attachments', async function (assert QUnit.test('show attachment box', async function (assert) { assert.expect(6); + this.data['res.partner'].records.push({ id: 100 }); await this.start({ async mockRPC(route, args) { if (route.includes('ir.attachment/search_read')) { @@ -262,6 +265,7 @@ QUnit.test('show attachment box', async function (assert) { QUnit.test('composer show/hide on log note/send message', async function (assert) { assert.expect(10); + this.data['res.partner'].records.push({ id: 100 }); await this.start(); const chatter = this.env.models['mail.chatter'].create({ threadId: 100, @@ -343,6 +347,7 @@ QUnit.test('composer show/hide on log note/send message', async function (assert QUnit.test('should not display user notification messages in chatter', async function (assert) { assert.expect(1); + this.data['res.partner'].records.push({ id: 100 }); this.data['mail.message'].records = [{ author_id: [7, "Demo"], body: "<p>User notification</p>", diff --git a/addons/mail/static/src/components/chatter_topbar/chatter_topbar_tests.js b/addons/mail/static/src/components/chatter_topbar/chatter_topbar_tests.js index 352566423f5..36e34d6056f 100644 --- a/addons/mail/static/src/components/chatter_topbar/chatter_topbar_tests.js +++ b/addons/mail/static/src/components/chatter_topbar/chatter_topbar_tests.js @@ -57,6 +57,7 @@ QUnit.module('chatter_topbar_tests.js', { QUnit.test('base rendering', async function (assert) { assert.expect(8); + this.data['res.partner'].records.push({ id: 100 }); await this.start(); const chatter = this.env.models['mail.chatter'].create({ threadId: 100, @@ -155,6 +156,7 @@ QUnit.test('base disabled rendering', async function (assert) { QUnit.test('attachment loading is delayed', async function (assert) { assert.expect(4); + this.data['res.partner'].records.push({ id: 100 }); await this.start({ hasTimeControl: true, loadingBaseDelayDuration: 100, @@ -198,6 +200,7 @@ QUnit.test('attachment loading is delayed', async function (assert) { QUnit.test('attachment counter while loading attachments', async function (assert) { assert.expect(4); + this.data['res.partner'].records.push({ id: 100 }); await this.start({ async mockRPC(route) { if (route.includes('ir.attachment/search_read')) { @@ -237,6 +240,7 @@ QUnit.test('attachment counter while loading attachments', async function (asser QUnit.test('attachment counter transition when attachments become loaded)', async function (assert) { assert.expect(7); + this.data['res.partner'].records.push({ id: 100 }); const attachmentPromise = makeTestPromise(); await this.start({ async mockRPC(route) { @@ -295,6 +299,7 @@ QUnit.test('attachment counter transition when attachments become loaded)', asyn QUnit.test('attachment counter without attachments', async function (assert) { assert.expect(4); + this.data['res.partner'].records.push({ id: 100 }); await this.start(); const chatter = this.env.models['mail.chatter'].create({ threadId: 100, @@ -327,6 +332,7 @@ QUnit.test('attachment counter without attachments', async function (assert) { QUnit.test('attachment counter with attachments', async function (assert) { assert.expect(4); + this.data['res.partner'].records.push({ id: 100 }); await this.start({ async mockRPC(route) { if (route.includes('ir.attachment/search_read')) { @@ -376,6 +382,7 @@ QUnit.test('attachment counter with attachments', async function (assert) { QUnit.test('composer state conserved when clicking on another topbar button', async function (assert) { assert.expect(8); + this.data['res.partner'].records.push({ id: 100 }); await this.start(); const chatter = this.env.models['mail.chatter'].create({ threadId: 100, @@ -586,6 +593,7 @@ QUnit.test('rendering with multiple channel followers', async function (assert) QUnit.test('log note/send message switching', async function (assert) { assert.expect(8); + this.data['res.partner'].records.push({ id: 100 }); await this.start(); const chatter = this.env.models['mail.chatter'].create({ threadId: 100, @@ -645,6 +653,7 @@ QUnit.test('log note/send message switching', async function (assert) { QUnit.test('log note toggling', async function (assert) { assert.expect(4); + this.data['res.partner'].records.push({ id: 100 }); await this.start(); const chatter = this.env.models['mail.chatter'].create({ threadId: 100, @@ -684,6 +693,7 @@ QUnit.test('log note toggling', async function (assert) { QUnit.test('send message toggling', async function (assert) { assert.expect(4); + this.data['res.partner'].records.push({ id: 100 }); await this.start(); const chatter = this.env.models['mail.chatter'].create({ threadId: 100, diff --git a/addons/mail/static/src/components/dialog/dialog.js b/addons/mail/static/src/components/dialog/dialog.js index ae6aace8e03..a71be619456 100644 --- a/addons/mail/static/src/components/dialog/dialog.js +++ b/addons/mail/static/src/components/dialog/dialog.js @@ -82,7 +82,7 @@ class Dialog extends Component { ) { return; } - this.dialog.close(); + this.dialog.delete(); } /** @@ -91,7 +91,7 @@ class Dialog extends Component { */ _onKeydownDocument(ev) { if (ev.key === 'Escape') { - this.dialog.close(); + this.dialog.delete(); } } diff --git a/addons/mail/static/src/components/dialog_manager/dialog_manager.xml b/addons/mail/static/src/components/dialog_manager/dialog_manager.xml index 994d7d9c9d7..35d39773cd3 100644 --- a/addons/mail/static/src/components/dialog_manager/dialog_manager.xml +++ b/addons/mail/static/src/components/dialog_manager/dialog_manager.xml @@ -3,7 +3,7 @@ <t t-name="mail.DialogManager" owl="1"> <div class="o_DialogManager"> - <t t-foreach="env.messaging.dialogManager.allOrdered" t-as="dialog" t-key="dialog.localId"> + <t t-foreach="env.messaging.dialogManager.dialogs" t-as="dialog" t-key="dialog.localId"> <Dialog class="o_DialogManager_dialog" dialogLocalId="dialog.localId" diff --git a/addons/mail/static/src/components/message_seen_indicator/message_seen_indicator_tests.js b/addons/mail/static/src/components/message_seen_indicator/message_seen_indicator_tests.js index 3f95a1d5407..b61d6721c0e 100644 --- a/addons/mail/static/src/components/message_seen_indicator/message_seen_indicator_tests.js +++ b/addons/mail/static/src/components/message_seen_indicator/message_seen_indicator_tests.js @@ -175,7 +175,7 @@ QUnit.test('rendering when just one has seen the message', async function (asser author: [['insert', { id: this.env.session.partner_id, display_name: "Demo User" }]], body: "<p>Test</p>", id: 100, - originThread: [['link', thread.main]], + originThread: [['link', thread]], }); await this.createMessageSeenIndicatorComponent({ message, thread }); assert.containsOnce( |
