diff options
| author | Thanh Dodeur <tso@odoo.com> | 2020-10-30 07:19:29 +0000 |
|---|---|---|
| committer | Thanh Dodeur <tso@odoo.com> | 2020-12-10 13:44:05 +0000 |
| commit | 528adfb313ab3c8d4aeb3309aa7371301ab8085e (patch) | |
| tree | 4d9f74dc37c03267dff7cd39287634704bbe9d40 /addons/mail/static/src/components/attachment/attachment_tests.js | |
| parent | e702399ceb9b84ad1ce82371eeaeddb492907eda (diff) | |
[FIX] mail: handles unlink button spam on attachments
Before this commit, attempting to delete attachments multiple times
could result in errors, especially on slow networks.
This commit fixes this issue.
task-2363522
closes odoo/odoo#61017
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
Diffstat (limited to 'addons/mail/static/src/components/attachment/attachment_tests.js')
| -rw-r--r-- | addons/mail/static/src/components/attachment/attachment_tests.js | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/addons/mail/static/src/components/attachment/attachment_tests.js b/addons/mail/static/src/components/attachment/attachment_tests.js index b698c042825..2eb43d96f82 100644 --- a/addons/mail/static/src/components/attachment/attachment_tests.js +++ b/addons/mail/static/src/components/attachment/attachment_tests.js @@ -595,6 +595,41 @@ QUnit.test('close attachment viewer', async function (assert) { ); }); +QUnit.test('clicking on the delete attachment button multiple times should do the rpc only once', async function (assert) { + assert.expect(2); + await this.start({ + async mockRPC(route, args) { + if (args.method === "unlink" && args.model === "ir.attachment") { + assert.step('attachment_unlink'); + return; + } + return this._super(...arguments); + }, + }); + const attachment = this.env.models['mail.attachment'].create({ + filename: "test.txt", + id: 750, + mimetype: 'text/plain', + name: "test.txt", + }); + await this.createAttachmentComponent(attachment, { + detailsMode: 'hover', + }); + await afterNextRender(() => { + document.querySelector('.o_Attachment_actionUnlink').click(); + }); + + await afterNextRender(() => { + document.querySelector('.o_AttachmentDeleteConfirmDialog_confirmButton').click(); + document.querySelector('.o_AttachmentDeleteConfirmDialog_confirmButton').click(); + document.querySelector('.o_AttachmentDeleteConfirmDialog_confirmButton').click(); + }); + assert.verifySteps( + ['attachment_unlink'], + "The unlink method must be called once" + ); +}); + }); }); }); |
