summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Dubuc <xdu@odoo.com>2020-08-06 09:35:18 +0000
committerAlexandre Kühn <aku@odoo.com>2020-08-06 21:27:15 +0000
commitc9e25aab343bd01eb988b2228ce4e2ddb7939af0 (patch)
treec1b2ea01c5f66e6a6923310d73416e5e9a438b12
parent9637de2f9e5e61236bf9b96c4924dda6f7b5aa44 (diff)
[FIX] mail: allow folded chat windows to be shifted
task-2313414 closes odoo/odoo#55593 X-original-commit: 609dab84c6085af1ab27ee142c6ee674d7d321e9 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com> Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
-rw-r--r--addons/mail/static/src/components/chat_window/chat_window.js3
-rw-r--r--addons/mail/static/src/components/chat_window_manager/chat_window_manager_tests.js138
2 files changed, 140 insertions, 1 deletions
diff --git a/addons/mail/static/src/components/chat_window/chat_window.js b/addons/mail/static/src/components/chat_window/chat_window.js
index 76114f7e831..7424e32ec08 100644
--- a/addons/mail/static/src/components/chat_window/chat_window.js
+++ b/addons/mail/static/src/components/chat_window/chat_window.js
@@ -115,6 +115,9 @@ class ChatWindow extends Component {
isDoFocus: false,
isFocused: true,
});
+ if (this.chatWindow.isFolded) {
+ return;
+ }
if (!this.chatWindow.thread) {
this._inputRef.comp.focus();
} else {
diff --git a/addons/mail/static/src/components/chat_window_manager/chat_window_manager_tests.js b/addons/mail/static/src/components/chat_window_manager/chat_window_manager_tests.js
index 6e284a7156c..23a8c42dea1 100644
--- a/addons/mail/static/src/components/chat_window_manager/chat_window_manager_tests.js
+++ b/addons/mail/static/src/components/chat_window_manager/chat_window_manager_tests.js
@@ -746,7 +746,6 @@ QUnit.test('focus next visible chat window when closing current chat window with
);
});
-
QUnit.test('[technical] chat window: composer state conservation on toggle home menu', async function (assert) {
// technical as show/hide home menu simulation are involved and home menu implementation
// have side-effects on DOM that may make chat window components not work
@@ -1179,6 +1178,143 @@ QUnit.test('open 2 chat windows: check shift operations are available', async fu
);
});
+QUnit.test('open 2 folded chat windows: check shift operations are available', async function (assert) {
+ /**
+ * computation uses following info:
+ * ([mocked] global window width: 900px)
+ * (others: @see `mail/static/src/models/chat_window_manager/chat_window_manager.js:visual`)
+ *
+ * - chat window width: 325px
+ * - start/end/between gap width: 10px/10px/5px
+ * - global width: 900px
+ *
+ * 2 visible chat windows + hidden menu:
+ * 10 + 325 + 5 + 325 + 10 = 675 < 900
+ */
+ assert.expect(13);
+
+ const channel = {
+ channel_type: "channel",
+ id: 20,
+ is_minimized: true,
+ is_pinned: true,
+ name: "General",
+ state: 'folded',
+ };
+ const chat = {
+ channel_type: "chat",
+ direct_partner: [{
+ id: 7,
+ name: "Demo",
+ }],
+ id: 10,
+ is_minimized: true,
+ is_pinned: true,
+ state: 'folded',
+ };
+ this.data['mail.channel'].records = [channel, chat];
+ Object.assign(this.data.initMessaging, {
+ channel_slots: {
+ channel_channel: [channel],
+ channel_direct_message: [chat],
+ },
+ });
+ await this.start({
+ env: {
+ browser: {
+ innerWidth: 900,
+ },
+ },
+ });
+
+ assert.containsN(
+ document.body,
+ '.o_ChatWindow',
+ 2,
+ "should have opened 2 chat windows initially"
+ );
+ assert.hasClass(
+ document.querySelector('.o_ChatWindow[data-visible-index="0"]'),
+ 'o-folded',
+ "first chat window should be folded"
+ );
+ assert.hasClass(
+ document.querySelector('.o_ChatWindow[data-visible-index="1"]'),
+ 'o-folded',
+ "second chat window should be folded"
+ );
+ assert.containsOnce(
+ document.body,
+ '.o_ChatWindow .o_ChatWindowHeader_commandShiftLeft',
+ "there should be only one chat window allowed to shift left even if folded"
+ );
+ assert.containsOnce(
+ document.body,
+ '.o_ChatWindow .o_ChatWindowHeader_commandShiftRight',
+ "there should be only one chat window allowed to shift right even if folded"
+ );
+
+ const initialFirstChatWindowThreadLocalId =
+ document.querySelector('.o_ChatWindow[data-visible-index="0"]').dataset.threadLocalId;
+ const initialSecondChatWindowThreadLocalId =
+ document.querySelector('.o_ChatWindow[data-visible-index="1"]').dataset.threadLocalId;
+ await afterNextRender(() =>
+ document.querySelector('.o_ChatWindowHeader_commandShiftLeft').click()
+ );
+ assert.strictEqual(
+ document.querySelector('.o_ChatWindow[data-visible-index="0"]').dataset.threadLocalId,
+ initialSecondChatWindowThreadLocalId,
+ "First chat window should be second after it has been shift left"
+ );
+ assert.strictEqual(
+ document.querySelector('.o_ChatWindow[data-visible-index="1"]').dataset.threadLocalId,
+ initialFirstChatWindowThreadLocalId,
+ "Second chat window should be first after the first has been shifted left"
+ );
+
+ await afterNextRender(() =>
+ document.querySelector('.o_ChatWindowHeader_commandShiftLeft').click()
+ );
+ assert.strictEqual(
+ document.querySelector('.o_ChatWindow[data-visible-index="0"]').dataset.threadLocalId,
+ initialFirstChatWindowThreadLocalId,
+ "First chat window should be back at first place"
+ );
+ assert.strictEqual(
+ document.querySelector('.o_ChatWindow[data-visible-index="1"]').dataset.threadLocalId,
+ initialSecondChatWindowThreadLocalId,
+ "Second chat window should be back at second place"
+ );
+
+ await afterNextRender(() =>
+ document.querySelector('.o_ChatWindowHeader_commandShiftRight').click()
+ );
+ assert.strictEqual(
+ document.querySelector('.o_ChatWindow[data-visible-index="0"]').dataset.threadLocalId,
+ initialSecondChatWindowThreadLocalId,
+ "First chat window should be second after it has been shift right"
+ );
+ assert.strictEqual(
+ document.querySelector('.o_ChatWindow[data-visible-index="1"]').dataset.threadLocalId,
+ initialFirstChatWindowThreadLocalId,
+ "Second chat window should be first after the first has been shifted right"
+ );
+
+ await afterNextRender(() =>
+ document.querySelector('.o_ChatWindowHeader_commandShiftRight').click()
+ );
+ assert.strictEqual(
+ document.querySelector('.o_ChatWindow[data-visible-index="0"]').dataset.threadLocalId,
+ initialFirstChatWindowThreadLocalId,
+ "First chat window should be back at first place"
+ );
+ assert.strictEqual(
+ document.querySelector('.o_ChatWindow[data-visible-index="1"]').dataset.threadLocalId,
+ initialSecondChatWindowThreadLocalId,
+ "Second chat window should be back at second place"
+ );
+});
+
QUnit.test('open 3 different chat windows: not enough screen width', async function (assert) {
/**
* computation uses following info: