summaryrefslogtreecommitdiff
path: root/addons/mail/static/tests/chatter_tests.js
diff options
context:
space:
mode:
Diffstat (limited to 'addons/mail/static/tests/chatter_tests.js')
-rw-r--r--addons/mail/static/tests/chatter_tests.js65
1 files changed, 65 insertions, 0 deletions
diff --git a/addons/mail/static/tests/chatter_tests.js b/addons/mail/static/tests/chatter_tests.js
index f0f3394c1e1..fd59686aeb5 100644
--- a/addons/mail/static/tests/chatter_tests.js
+++ b/addons/mail/static/tests/chatter_tests.js
@@ -1233,6 +1233,71 @@ QUnit.test('chatter: access document with some notifs', async function (assert)
form.destroy();
});
+QUnit.test('chatter: new message notification from document', async function (assert) {
+ // when receiving new messages from a document that is open, it should
+ // not mark the messages are read
+ assert.expect(4);
+
+ var form = await createView({
+ View: FormView,
+ model: 'partner',
+ data: this.data,
+ services: this.services,
+ arch: '<form string="Partners">' +
+ '<sheet>' +
+ '<field name="foo"/>' +
+ '</sheet>' +
+ '<div class="oe_chatter">' +
+ '<field name="message_ids" widget="mail_thread"/>' +
+ '</div>' +
+ '</form>',
+ res_id: 2,
+ session: {
+ partner_id: 3,
+ },
+ mockRPC: function (route, args) {
+ if (args.method === 'set_message_done') {
+ throw new Error("should not mark message as read");
+ }
+ return this._super.apply(this, arguments);
+ },
+ });
+
+ var thread = form.call('mail_service', 'getDocumentThread', 'partner', 2);
+ assert.strictEqual(
+ thread.getUnreadCounter(),
+ 0,
+ "document thread should have no unread messages initially");
+ assert.containsNone(
+ form,
+ '.o_thread_message',
+ "should have no message in the chatter");
+
+ // Simulate received needaction`` message on this document
+ var message = {
+ author_id: [1, "Me"],
+ body: '<p>test</p>',
+ channel_ids: [],
+ id: 2,
+ model: 'partner',
+ needaction_partner_ids: [3],
+ res_id: 2,
+ };
+ const notifications = [ [['myDB', 'ir.needaction'], message] ];
+ form.call('bus_service', 'trigger', 'notification', notifications);
+ await testUtils.nextTick();
+ assert.strictEqual(
+ thread.getUnreadCounter(),
+ 1,
+ "document thread should have one unread message (not marked as read)");
+ assert.containsOnce(
+ form,
+ '.o_thread_message',
+ "should have one message in the chatter");
+
+ form.destroy();
+});
+
QUnit.test('chatter: post a message and switch in edit mode', async function (assert) {
assert.expect(5);