From b33883db2cbdbdc8996b9a89bb442d377fe30cec Mon Sep 17 00:00:00 2001 From: Martin Brennan Date: Thu, 9 Feb 2023 15:11:00 +1000 Subject: [PATCH] DEV: Spec for opening thread on mobile --- .../components/chat-message-actions-desktop.hbs | 2 +- .../javascripts/discourse/components/chat-message.js | 12 ++++++++++-- .../spec/system/page_objects/chat/chat_channel.rb | 9 +++++++++ plugins/chat/spec/system/single_thread_spec.rb | 9 +++++++++ plugins/chat/spec/system/transcript_spec.rb | 2 +- 5 files changed, 30 insertions(+), 4 deletions(-) diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-message-actions-desktop.hbs b/plugins/chat/assets/javascripts/discourse/components/chat-message-actions-desktop.hbs index 07d9d99fa3..cc0a38248a 100644 --- a/plugins/chat/assets/javascripts/discourse/components/chat-message-actions-desktop.hbs +++ b/plugins/chat/assets/javascripts/discourse/components/chat-message-actions-desktop.hbs @@ -40,7 +40,7 @@ {{#if this.messageCapabilities.hasThread}} diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-message.js b/plugins/chat/assets/javascripts/discourse/components/chat-message.js index 1549a80551..de90bced35 100644 --- a/plugins/chat/assets/javascripts/discourse/components/chat-message.js +++ b/plugins/chat/assets/javascripts/discourse/components/chat-message.js @@ -238,6 +238,14 @@ export default Component.extend({ }); } + if (this.openThread) { + buttons.push({ + id: "openThread", + name: I18n.t("chat.threads.open"), + icon: "puzzle-piece", + }); + } + return buttons; }, @@ -253,7 +261,7 @@ export default Component.extend({ restore: this.restore, rebakeMessage: this.rebakeMessage, toggleBookmark: this.toggleBookmark, - showThread: this.showThread, + openThread: this.openThread, startReactionForMessageActions: this.startReactionForMessageActions, }; }, @@ -732,7 +740,7 @@ export default Component.extend({ }, @action - showThread() { + openThread() { this.router.transitionTo("chat.channel.thread", this.message.thread_id); }, diff --git a/plugins/chat/spec/system/page_objects/chat/chat_channel.rb b/plugins/chat/spec/system/page_objects/chat/chat_channel.rb index ad7d3bb043..1263b86dcf 100644 --- a/plugins/chat/spec/system/page_objects/chat/chat_channel.rb +++ b/plugins/chat/spec/system/page_objects/chat/chat_channel.rb @@ -32,6 +32,10 @@ module PageObjects click_more_buttons(message) end + def expand_message_actions_mobile(message, delay: 1) + message_by_id(message.id).click(delay: delay) + end + def hover_message(message) message_by_id(message.id).hover end @@ -56,6 +60,11 @@ module PageObjects find(".chat-message-thread-btn").click end + def open_message_thread_mobile(message) + expand_message_actions_mobile(message) + find(".chat-message-action-item[data-id=\"openThread\"]").click + end + def select_message(message) hover_message(message) click_more_buttons(message) diff --git a/plugins/chat/spec/system/single_thread_spec.rb b/plugins/chat/spec/system/single_thread_spec.rb index 67aebaaa07..ebbf8e1f68 100644 --- a/plugins/chat/spec/system/single_thread_spec.rb +++ b/plugins/chat/spec/system/single_thread_spec.rb @@ -67,5 +67,14 @@ describe "Single thread in side panel", type: :system, js: true do expect(open_thread.op).to have_css(".chat-user-avatar img.avatar") expect(open_thread.op).to have_content(thread.original_message_user.username) end + + context "when using mobile" do + it "opens the side panel for a single thread from the mobile message actions menu", + mobile: true do + chat_page.visit_channel(channel) + channel_page.open_message_thread_mobile(thread.chat_messages.last) + expect(side_panel).to have_open_thread(thread) + end + end end end diff --git a/plugins/chat/spec/system/transcript_spec.rb b/plugins/chat/spec/system/transcript_spec.rb index 08809cec57..a7790b8447 100644 --- a/plugins/chat/spec/system/transcript_spec.rb +++ b/plugins/chat/spec/system/transcript_spec.rb @@ -28,7 +28,7 @@ RSpec.describe "Quoting chat message transcripts", type: :system, js: true do def select_message_mobile(message) i = 0.5 try_until_success(timeout: 20) do - chat_channel_page.message_by_id(message.id).click(delay: i) + chat_channel_page.expand_message_actions_mobile(message, delay: 1) first(".chat-message-action-item[data-id=\"selectMessage\"]") end find(".chat-message-action-item[data-id=\"selectMessage\"] button").click