diff options
| author | Xavier Dubuc <xdu@odoo.com> | 2021-03-10 16:45:49 +0000 |
|---|---|---|
| committer | Sébastien Theys <seb@odoo.com> | 2021-03-10 16:48:19 +0000 |
| commit | fbdec5fe29827b88ec0d1421f68716e1febefd89 (patch) | |
| tree | afbbc6fd6da16ace2af4c2992678657b814d0197 /addons/mail/static/src/components/composer | |
| parent | f326ba2d14e4fdd811426c6381b7e5bc3c1d657b (diff) | |
[FIX] mail; hr: restore faster and more accurate mention suggestions
The code from v13 used to look for partners in JS before making the RPC, which
was much faster, and also gave better results by returning partners that were
already known and therefore more likely to be selected.
The same logic is reintroduced here, and further improved to take into account
all known partners and sort them according to the likeliness they will be
selected based on various criteria.
task-2413776
closes odoo/odoo#64161
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Co-authored-by: Sébastien Theys <seb@odoo.com>
Diffstat (limited to 'addons/mail/static/src/components/composer')
| -rw-r--r-- | addons/mail/static/src/components/composer/composer_tests.js | 79 |
1 files changed, 3 insertions, 76 deletions
diff --git a/addons/mail/static/src/components/composer/composer_tests.js b/addons/mail/static/src/components/composer/composer_tests.js index 98f969438eb..77a4f2adb4c 100644 --- a/addons/mail/static/src/components/composer/composer_tests.js +++ b/addons/mail/static/src/components/composer/composer_tests.js @@ -333,8 +333,6 @@ QUnit.test('use a canned response', async function (assert) { await afterNextRender(() => { document.querySelector(`.o_ComposerTextInput_textarea`).focus(); document.execCommand('insertText', false, ":"); - }); - await afterNextRender(() => { document.querySelector(`.o_ComposerTextInput_textarea`) .dispatchEvent(new window.KeyboardEvent('keydown')); document.querySelector(`.o_ComposerTextInput_textarea`) @@ -387,10 +385,8 @@ QUnit.test('use a canned response some text', async function (assert) { "bluhbluh ", "text content of composer should have content" ); - await afterNextRender(() => - document.execCommand('insertText', false, ":") - ); await afterNextRender(() => { + document.execCommand('insertText', false, ":"); document.querySelector(`.o_ComposerTextInput_textarea`) .dispatchEvent(new window.KeyboardEvent('keydown')); document.querySelector(`.o_ComposerTextInput_textarea`) @@ -437,8 +433,6 @@ QUnit.test('add an emoji after a canned response', async function (assert) { await afterNextRender(() => { document.querySelector(`.o_ComposerTextInput_textarea`).focus(); document.execCommand('insertText', false, ":"); - }); - await afterNextRender(() => { document.querySelector(`.o_ComposerTextInput_textarea`) .dispatchEvent(new window.KeyboardEvent('keydown')); document.querySelector(`.o_ComposerTextInput_textarea`) @@ -531,8 +525,6 @@ QUnit.test('mention a channel', async function (assert) { await afterNextRender(() => { document.querySelector(`.o_ComposerTextInput_textarea`).focus(); document.execCommand('insertText', false, "#"); - }); - await afterNextRender(() => { document.querySelector(`.o_ComposerTextInput_textarea`) .dispatchEvent(new window.KeyboardEvent('keydown')); document.querySelector(`.o_ComposerTextInput_textarea`) @@ -584,10 +576,8 @@ QUnit.test('mention a channel after some text', async function (assert) { "bluhbluh ", "text content of composer should have content" ); - await afterNextRender(() => - document.execCommand('insertText', false, "#") - ); await afterNextRender(() => { + document.execCommand('insertText', false, "#"); document.querySelector(`.o_ComposerTextInput_textarea`) .dispatchEvent(new window.KeyboardEvent('keydown')); document.querySelector(`.o_ComposerTextInput_textarea`) @@ -633,8 +623,6 @@ QUnit.test('add an emoji after a channel mention', async function (assert) { await afterNextRender(() => { document.querySelector(`.o_ComposerTextInput_textarea`).focus(); document.execCommand('insertText', false, "#"); - }); - await afterNextRender(() => { document.querySelector(`.o_ComposerTextInput_textarea`) .dispatchEvent(new window.KeyboardEvent('keydown')); document.querySelector(`.o_ComposerTextInput_textarea`) @@ -739,8 +727,6 @@ QUnit.test('use a command for a specific channel type', async function (assert) await afterNextRender(() => { document.querySelector(`.o_ComposerTextInput_textarea`).focus(); document.execCommand('insertText', false, "/"); - }); - await afterNextRender(() => { document.querySelector(`.o_ComposerTextInput_textarea`) .dispatchEvent(new window.KeyboardEvent('keydown')); document.querySelector(`.o_ComposerTextInput_textarea`) @@ -828,10 +814,8 @@ QUnit.test('use a command after some text', async function (assert) { "bluhbluh ", "text content of composer should have content" ); - await afterNextRender(() => - document.execCommand('insertText', false, "/") - ); await afterNextRender(() => { + document.execCommand('insertText', false, "/"); document.querySelector(`.o_ComposerTextInput_textarea`) .dispatchEvent(new window.KeyboardEvent('keydown')); document.querySelector(`.o_ComposerTextInput_textarea`) @@ -883,8 +867,6 @@ QUnit.test('add an emoji after a command', async function (assert) { await afterNextRender(() => { document.querySelector(`.o_ComposerTextInput_textarea`).focus(); document.execCommand('insertText', false, "/"); - }); - await afterNextRender(() => { document.querySelector(`.o_ComposerTextInput_textarea`) .dispatchEvent(new window.KeyboardEvent('keydown')); document.querySelector(`.o_ComposerTextInput_textarea`) @@ -2041,61 +2023,6 @@ QUnit.test('send message only once when enter is pressed twice quickly', async f ); }); -QUnit.test("mentioned partners should not be notified if they are not member of current channel", async function (assert) { - assert.expect(4); - - this.data['res.partner'].records.push({ - email: "testpartner@example.com", - name: "TestPartner", - }); - this.data['mail.channel'].records.push({ - id: 10, - members: [this.data.currentPartnerId], - }); - await this.start({ - async mockRPC(route, args) { - if (args.model === 'mail.channel' && args.method === 'message_post') { - assert.step('message_post'); - assert.strictEqual( - args.kwargs.partner_ids.length, - 0, - "message_post should not contain mentioned partners that are not members of channel" - ); - } - return this._super(...arguments); - }, - }); - const thread = this.env.models['mail.thread'].findFromIdentifyingData({ - id: 10, - model: 'mail.channel', - }); - await this.createComposerComponent(thread.composer); - await afterNextRender(() => { - document.querySelector(`.o_ComposerTextInput_textarea`).focus(); - document.execCommand('insertText', false, "@"); - document.querySelector(`.o_ComposerTextInput_textarea`) - .dispatchEvent(new window.KeyboardEvent('keydown')); - document.querySelector(`.o_ComposerTextInput_textarea`) - .dispatchEvent(new window.KeyboardEvent('keyup')); - }); - await afterNextRender(() => { - document.querySelector(`.o_ComposerTextInput_textarea`).focus(); - document.execCommand('insertText', false, "Test"); - document.querySelector(`.o_ComposerTextInput_textarea`) - .dispatchEvent(new window.KeyboardEvent('keydown')); - document.querySelector(`.o_ComposerTextInput_textarea`) - .dispatchEvent(new window.KeyboardEvent('keyup')); - }); - await afterNextRender(() => document.querySelector('.o_ComposerSuggestion').click()); - assert.strictEqual( - document.querySelector(`.o_ComposerTextInput_textarea`).value.replace(/\s/, " "), - "@TestPartner ", - "text content of composer should have mentioned partner + additional whitespace afterwards" - ); - await afterNextRender(() => document.querySelector('.o_Composer_buttonSend').click()); - assert.verifySteps(['message_post'], "the message should be posted"); -}); - QUnit.test('[technical] does not crash when an attachment is removed before its upload starts', async function (assert) { // Uploading multiple files uploads attachments one at a time, this test // ensures that there is no crash when an attachment is destroyed before its |
