summaryrefslogtreecommitdiff
path: root/addons/mail/static/src/components/attachment_box/attachment_box_tests.js
diff options
context:
space:
mode:
authorXavier Dubuc <xdu@odoo.com>2020-10-09 15:11:41 +0000
committerSébastien Theys <seb@odoo.com>2020-10-09 16:45:35 +0000
commit336d3a428129857e39d98075ca8e95003c09b01e (patch)
treea4e7fb6c3ccba614251dde9f8540fa76ea3aec67 /addons/mail/static/src/components/attachment_box/attachment_box_tests.js
parent76c2f412c09ef1169b5cf936f0770cd4200f29e2 (diff)
[FIX] mail: ask for confirmation before attachment deletion
also hide all messages with empty body and no attachments task-2282322 closes odoo/odoo#59672 X-original-commit: 60ae42dcda777cd66e4e421dbc02f9ef12a430ef Related: odoo/enterprise#13971 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com> Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
Diffstat (limited to 'addons/mail/static/src/components/attachment_box/attachment_box_tests.js')
-rw-r--r--addons/mail/static/src/components/attachment_box/attachment_box_tests.js48
1 files changed, 48 insertions, 0 deletions
diff --git a/addons/mail/static/src/components/attachment_box/attachment_box_tests.js b/addons/mail/static/src/components/attachment_box/attachment_box_tests.js
index 9330a8c955b..6f217c2b5d7 100644
--- a/addons/mail/static/src/components/attachment_box/attachment_box_tests.js
+++ b/addons/mail/static/src/components/attachment_box/attachment_box_tests.js
@@ -284,6 +284,54 @@ QUnit.test('view attachments', async function (assert) {
);
});
+QUnit.test('remove attachment should ask for confirmation', async function (assert) {
+ assert.expect(5);
+
+ await this.start();
+ const thread = this.env.models['mail.thread'].create({
+ attachments: [
+ ['insert', {
+ id: 143,
+ mimetype: 'text/plain',
+ name: 'Blah.txt'
+ }],
+ ],
+ id: 100,
+ model: 'res.partner',
+ });
+ await this.createAttachmentBoxComponent(thread);
+ assert.containsOnce(
+ document.body,
+ '.o_Attachment',
+ "should have an attachment",
+ );
+ assert.containsOnce(
+ document.body,
+ '.o_Attachment_actionUnlink',
+ "attachment should have a delete button"
+ );
+
+ await afterNextRender(() => document.querySelector('.o_Attachment_actionUnlink').click());
+ assert.containsOnce(
+ document.body,
+ '.o_AttachmentDeleteConfirmDialog',
+ "A confirmation dialog should have been opened"
+ );
+ assert.strictEqual(
+ document.querySelector('.o_AttachmentDeleteConfirmDialog_mainText').textContent,
+ `Do you really want to delete "Blah.txt"?`,
+ "Confirmation dialog should contain the attachment delete confirmation text"
+ );
+
+ // Confirm the deletion
+ await afterNextRender(() => document.querySelector('.o_AttachmentDeleteConfirmDialog_confirmButton').click());
+ assert.containsNone(
+ document.body,
+ '.o_Attachment',
+ "should no longer have an attachment",
+ );
+});
+
});
});
});