summaryrefslogtreecommitdiff
path: root/addons/mail/static/src/models/message/message_tests.js
diff options
context:
space:
mode:
authorSébastien Theys <seb@odoo.com>2021-01-26 14:03:11 +0000
committerSébastien Theys <seb@odoo.com>2021-01-26 14:03:11 +0000
commit8668b3ff8da395738c030e45ff1787efd8b45df3 (patch)
tree52f7b732363ffc71afec22afec4ffb4b486bf22d /addons/mail/static/src/models/message/message_tests.js
parent63e36a9254c20726b57160b0bd08bc3aa292a063 (diff)
[FIX] mail: avoid hiding non-text messages that are not empty
task-2447695 closes odoo/odoo#65061 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Diffstat (limited to 'addons/mail/static/src/models/message/message_tests.js')
-rw-r--r--addons/mail/static/src/models/message/message_tests.js70
1 files changed, 70 insertions, 0 deletions
diff --git a/addons/mail/static/src/models/message/message_tests.js b/addons/mail/static/src/models/message/message_tests.js
index bc3cf58ef46..054e82049ac 100644
--- a/addons/mail/static/src/models/message/message_tests.js
+++ b/addons/mail/static/src/models/message/message_tests.js
@@ -110,6 +110,76 @@ QUnit.test('create', async function (assert) {
assert.strictEqual(partner.id, 5);
});
+QUnit.test('message without body should be considered empty', async function (assert) {
+ assert.expect(1);
+ await this.start();
+ const message = this.env.models['mail.message'].create({ id: 11 });
+ assert.ok(message.isEmpty);
+});
+
+QUnit.test('message with body "" should be considered empty', async function (assert) {
+ assert.expect(1);
+ await this.start();
+ const message = this.env.models['mail.message'].create({ body: "", id: 11 });
+ assert.ok(message.isEmpty);
+});
+
+QUnit.test('message with body "<p></p>" should be considered empty', async function (assert) {
+ assert.expect(1);
+ await this.start();
+ const message = this.env.models['mail.message'].create({ body: "<p></p>", id: 11 });
+ assert.ok(message.isEmpty);
+});
+
+QUnit.test('message with body "<p><br></p>" should be considered empty', async function (assert) {
+ assert.expect(1);
+ await this.start();
+ const message = this.env.models['mail.message'].create({ body: "<p><br></p>", id: 11 });
+ assert.ok(message.isEmpty);
+});
+
+QUnit.test('message with body "<p><br/></p>" should be considered empty', async function (assert) {
+ assert.expect(1);
+ await this.start();
+ const message = this.env.models['mail.message'].create({ body: "<p><br/></p>", id: 11 });
+ assert.ok(message.isEmpty);
+});
+
+QUnit.test(String.raw`message with body "<p>\n</p>" should be considered empty`, async function (assert) {
+ assert.expect(1);
+ await this.start();
+ const message = this.env.models['mail.message'].create({ body: "<p>\n</p>", id: 11 });
+ assert.ok(message.isEmpty);
+});
+
+QUnit.test(String.raw`message with body "<p>\r\n\r\n</p>" should be considered empty`, async function (assert) {
+ assert.expect(1);
+ await this.start();
+ const message = this.env.models['mail.message'].create({ body: "<p>\r\n\r\n</p>", id: 11 });
+ assert.ok(message.isEmpty);
+});
+
+QUnit.test('message with body "<p> </p> " should be considered empty', async function (assert) {
+ assert.expect(1);
+ await this.start();
+ const message = this.env.models['mail.message'].create({ body: "<p> </p> ", id: 11 });
+ assert.ok(message.isEmpty);
+});
+
+QUnit.test(`message with body "<img src=''>" should not be considered empty`, async function (assert) {
+ assert.expect(1);
+ await this.start();
+ const message = this.env.models['mail.message'].create({ body: "<img src=''>", id: 11 });
+ assert.notOk(message.isEmpty);
+});
+
+QUnit.test('message with body "test" should not be considered empty', async function (assert) {
+ assert.expect(1);
+ await this.start();
+ const message = this.env.models['mail.message'].create({ body: "test", id: 11 });
+ assert.notOk(message.isEmpty);
+});
+
});
});
});