-
+
diff --git a/addons/mail/static/tests/discuss_tests.js b/addons/mail/static/tests/discuss_tests.js
index 9949af7c28c..990f321a39d 100644
--- a/addons/mail/static/tests/discuss_tests.js
+++ b/addons/mail/static/tests/discuss_tests.js
@@ -1119,6 +1119,53 @@ QUnit.test('drag and drop file in composer [REQUIRE NON-INCOGNITO WINDOW]', asyn
discuss.destroy();
});
+QUnit.test('non-deletable message attachments', async function (assert) {
+ assert.expect(2);
+
+ this.data['mail.message'].records = [{
+ attachment_ids: [{
+ filename: "text.txt",
+ id: 250,
+ mimetype: 'text/plain',
+ name: "text.txt",
+ }, {
+ filename: "image.png",
+ id: 251,
+ mimetype: 'image/png',
+ name: "image.png",
+ }],
+ author_id: [5, "Demo User"],
+ body: "
test
",
+ id: 1,
+ needaction: true,
+ needaction_partner_ids: [3],
+ model: 'some.document',
+ record_name: "SomeDocument",
+ res_id: 100,
+ }];
+
+ const discuss = await createDiscuss({
+ context: {},
+ data: this.data,
+ params: {},
+ services: this.services,
+ session: {
+ partner_id: 3,
+ },
+ });
+ assert.containsN(
+ discuss,
+ '.o_attachment',
+ 2,
+ "should display 2 attachments");
+ assert.containsNone(
+ discuss.$('.o_attachment'),
+ 'o_attachment_delete_cross',
+ "attachments should not be deletable");
+
+ discuss.destroy();
+});
+
QUnit.test('reply to message from inbox', async function (assert) {
assert.expect(11);
diff --git a/addons/mail/static/tests/thread_window/basic_thread_window_tests.js b/addons/mail/static/tests/thread_window/basic_thread_window_tests.js
index 3200ae38d85..3dc8ac0336d 100644
--- a/addons/mail/static/tests/thread_window/basic_thread_window_tests.js
+++ b/addons/mail/static/tests/thread_window/basic_thread_window_tests.js
@@ -850,6 +850,59 @@ QUnit.test('receive 2 new DM messages in quick succession (no chat window initia
parent.destroy();
});
+QUnit.test('non-deletable message attachments', async function (assert) {
+ assert.expect(3);
+
+ this.data['mail.channel'].records = [{
+ id: 1,
+ name: "General",
+ channel_type: 'channel',
+ }];
+ this.data['mail.message'].records = [{
+ attachment_ids: [{
+ filename: "text.txt",
+ id: 250,
+ mimetype: 'text/plain',
+ name: "text.txt",
+ }, {
+ filename: "image.png",
+ id: 251,
+ mimetype: 'image/png',
+ name: "image.png",
+ }],
+ author_id: [5, "Demo User"],
+ body: "
test
",
+ channel_ids: [1],
+ id: 100,
+ model: 'mail.channel',
+ record_name: "general",
+ res_id: 1,
+ }];
+ const parent = this.createParent({
+ data: this.data,
+ services: this.services,
+ });
+ await testUtils.nextTick();
+ const channel = parent.call('mail_service', 'getChannel', 1);
+ channel.detach();
+ await testUtils.nextTick();
+ assert.containsOnce(
+ $,
+ '.o_thread_window',
+ "a thread window should be open");
+ assert.containsN(
+ $('.o_thread_window'),
+ '.o_attachment',
+ 2,
+ "thread window should have 2 attachments");
+ assert.containsNone(
+ $('.o_thread_window .o_attachment'),
+ 'o_attachment_delete_cross',
+ "attachments should not be deletable");
+
+ parent.destroy();
+});
+
});
});
});