summaryrefslogtreecommitdiff
path: root/addons/mail/static/tests
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2019-07-29 14:10:30 +0200
committerChristophe Simonis <chs@odoo.com>2019-07-29 14:10:30 +0200
commitd5e1fd16b4fd796cc25b2b2d694dadb375110ce7 (patch)
tree35d130b4161985cd9ca3071a59980b52e8401be5 /addons/mail/static/tests
parentae71f95371b4a5c99c10a23e3553c5badc45a1ac (diff)
parentcda4f3c308ca233aead81f5ae97d250b5b7bf82f (diff)
[MERGE] forward port branch saas-12.4 up to cda4f3c308c
Diffstat (limited to 'addons/mail/static/tests')
-rw-r--r--addons/mail/static/tests/chatter_tests.js69
-rw-r--r--addons/mail/static/tests/document_thread_window_tests.js2
-rw-r--r--addons/mail/static/tests/thread_window/basic_thread_window_tests.js113
3 files changed, 183 insertions, 1 deletions
diff --git a/addons/mail/static/tests/chatter_tests.js b/addons/mail/static/tests/chatter_tests.js
index 354cff95a75..bb569645c4d 100644
--- a/addons/mail/static/tests/chatter_tests.js
+++ b/addons/mail/static/tests/chatter_tests.js
@@ -7,6 +7,7 @@ var core = require('web.core');
var FormView = require('web.FormView');
var KanbanView = require('web.KanbanView');
var testUtils = require('web.test_utils');
+var concurrency = require('web.concurrency');
var createView = testUtils.createView;
@@ -1858,6 +1859,74 @@ QUnit.test('form activity widget: schedule next activity', async function (asser
form.destroy();
});
+QUnit.test('form activity widget: do not close activity popover on click', async function (assert) {
+ assert.expect(3);
+ this.data.partner.records[0].activity_ids = [1];
+ this.data.partner.records[0].activity_state = 'today';
+ this.data['mail.activity'].records = [{
+ id: 1,
+ display_name: "An activity",
+ date_deadline: moment().format("YYYY-MM-DD"), // now
+ can_write: true,
+ state: "today",
+ user_id: 2,
+ create_user_id: 2,
+ activity_type_id: 2,
+ }];
+
+ const 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"/>
+ <field name="activity_ids" widget="mail_activity"/>
+ </div>
+ </form>`,
+ res_id: 2,
+ mockRPC(route, args) {
+ if (route === '/web/dataset/call_kw/mail.activity/action_feedback_schedule_next') {
+ return Promise.resolve();
+ }
+ return this._super.apply(this, arguments);
+ },
+ intercepts: {
+ do_action(ev) {
+ ev.data.options.on_close();
+ },
+ },
+ });
+
+ //Schedule next activity
+ await testUtils.dom.click(form.$('.o_mail_activity .o_mark_as_done[data-activity-id=1]'));
+
+ for (let i = 0; i < 2; i++) {
+ // click twice in feedback area
+ await testUtils.dom.click(form.$('.o_mail_activity_feedback.popover textarea'));
+ const $popover = form.$('.o_mail_activity_feedback.popover');
+ const $PopoverInDom = form.$(`#${$popover.attr('id')}`);
+ assert.isVisible(
+ $PopoverInDom,
+ "the feedback popover should still be visible on click");
+ }
+ await concurrency.delay(250); // wait for popover transition
+ const $popover = form.$('.o_mail_activity_feedback.popover');
+ if (!$popover) {
+ throw new Error("popover should be in DOM");
+ }
+ const $PopoverInDom = form.$(`#${$popover.attr('id')}`);
+ assert.isVisible(
+ $PopoverInDom,
+ "the feedback popover should still be visible on click");
+
+ form.destroy();
+});
+
QUnit.test('form activity widget: edit next activity', async function (assert) {
assert.expect(3);
diff --git a/addons/mail/static/tests/document_thread_window_tests.js b/addons/mail/static/tests/document_thread_window_tests.js
index 51daf3a23b1..86d06ba36c4 100644
--- a/addons/mail/static/tests/document_thread_window_tests.js
+++ b/addons/mail/static/tests/document_thread_window_tests.js
@@ -48,7 +48,7 @@ QUnit.module('Document Thread', {
},
records: [{
id: 1,
- author_id: [1, 'Me'],
+ author_id: [partnerID, 'Me'],
body: '<p>Some Message on a document</p>',
channel_ids: [],
model: 'some.res.model',
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 d5af9cf5357..7c3cfbdc793 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
@@ -726,6 +726,119 @@ QUnit.test('no out-of-office status in thread window', async function (assert) {
parent.destroy();
});
+QUnit.test('auto-update out-of-office info on im_status change', async function (assert) {
+ assert.expect(5);
+
+ var imStatusDefs = [testUtils.makeTestPromise(), testUtils.makeTestPromise()];
+ var channelInfoDefs = [testUtils.makeTestPromise(), testUtils.makeTestPromise()];
+ var timeoutMock = mailTestUtils.patchMailTimeouts();
+ var step = 0;
+
+ this.data = {
+ 'mail.message': {
+ fields: {},
+ records: [],
+ },
+ initMessaging: {
+ channel_slots: {
+ channel_channel: [{
+ id: 1,
+ name: "DM",
+ channel_type: "chat",
+ message_unread_counter: 0,
+ direct_partner: [{
+ id: 666,
+ name: 'DemoUser1',
+ im_status: 'online',
+ }],
+ }],
+ },
+ },
+ };
+
+ var parent = this.createParent({
+ data: this.data,
+ services: this.services,
+ mockRPC: function (route, args) {
+ if (route === '/longpolling/im_status') {
+ step++;
+ if (step === 1) {
+ imStatusDefs[0].resolve();
+ return Promise.resolve([
+ {
+ id: 666,
+ im_status: 'leave',
+ },
+ ]);
+ } else if (step === 2) {
+ imStatusDefs[1].resolve();
+ return Promise.resolve([
+ {
+ id: 666,
+ im_status: 'online',
+ },
+ ]);
+ }
+ }
+ if (args.method === 'channel_info') {
+ if (step === 1) {
+ channelInfoDefs[0].resolve();
+ return Promise.resolve([{
+ id: 1,
+ direct_partner: [{
+ out_of_office_message: "Leave me alone",
+ out_of_office_date_end: false,
+ }],
+ }]);
+ }
+ else if (step === 2) {
+ channelInfoDefs[1].resolve();
+ return Promise.resolve([{
+ id: 1,
+ direct_partner: [{
+ out_of_office_message: false,
+ out_of_office_date_end: false,
+ }],
+ }]);
+ }
+ }
+ return this._super.apply(this, arguments);
+ },
+ });
+ await testUtils.nextTick();
+
+ // detach channel 1, so that it opens corresponding thread window.
+ parent.call('mail_service', 'getChannel', 1).detach();
+ await testUtils.nextTick();
+
+ assert.containsNone($, '.o_out_of_office',
+ "should contain no out of office section on chat window initially");
+
+ timeoutMock.addTime(51*1000); // wait for next im status fetch
+
+ await Promise.all([imStatusDefs[0], channelInfoDefs[0]]);
+ await testUtils.nextTick();
+ assert.containsOnce($, '.o_out_of_office',
+ "should contain out of office section on chat window");
+ assert.containsOnce($, '.o_out_of_office > .o_out_of_office_text',
+ "should contain out of office text on chat window");
+ assert.ok(
+ $('.o_out_of_office > .o_out_of_office_text')
+ .text()
+ .replace(/\s/g, "")
+ .indexOf("Leavemealone") !== -1,
+ "should contain out of office text on chat window");
+ timeoutMock.addTime(51*1000); // wait for next im status fetch
+
+ await Promise.all([imStatusDefs[1], channelInfoDefs[1]]);
+ await testUtils.nextTick();
+ assert.containsNone($, '.o_out_of_office',
+ "should no longer contain out of office section on chat window");
+
+ timeoutMock.runPendingTimeouts();
+ parent.destroy();
+});
+
});
});
});