FIX: correctly makes dm creator to follow channel (#22470)

In previous changes we prevented creating a channel to also make users follow the channel. We were forcing recipients to follow the channel on message sent but this was not including the creator of the message itself.

This commit fixes it and also write an end-to-end system spec to cover these cases. The message creator service is currently being rewritten and should correctly test and ensure this logic is present.

This commit also makes changes on the frontend to instantly follow a DM when you open it, this change prevents a green dot to appear for a split second when you send a message in a channel you were previously not following. Only recipients will see the green dot.
This commit is contained in:
Joffrey JAFFEUX
2023-07-06 21:42:19 +02:00
committed by GitHub
parent 3fd327c458
commit c0808b2537
12 changed files with 199 additions and 69 deletions
@@ -7,6 +7,10 @@ module PageObjects
@message_creator ||= PageObjects::Components::Chat::MessageCreator.new
end
def sidebar
@sidebar ||= PageObjects::Components::Chat::Sidebar.new
end
def prefers_full_page
page.execute_script(
"window.localStorage.setItem('discourse_chat_preferred_mode', '\"FULL_PAGE_CHAT\"');",
@@ -49,26 +49,32 @@ module PageObjects
end
def reply_to_last_message_shortcut
input.click
input.send_keys(%i[shift arrow_up])
end
def edit_last_message_shortcut
input.click
input.send_keys(%i[arrow_up])
end
def emphasized_text_shortcut
input.click
input.send_keys([PLATFORM_KEY_MODIFIER, "i"])
end
def cancel_shortcut
input.click
input.send_keys(:escape)
end
def indented_text_shortcut
input.click
input.send_keys([PLATFORM_KEY_MODIFIER, "e"])
end
def bold_text_shortcut
input.click
input.send_keys([PLATFORM_KEY_MODIFIER, "b"])
end
@@ -0,0 +1,43 @@
# frozen_string_literal: true
module PageObjects
module Components
module Chat
class Sidebar < PageObjects::Components::Base
attr_reader :context
SELECTOR = "#d-sidebar"
def component
page.find(SELECTOR)
end
def has_direct_message_channel?(channel, **args)
channel_selector = direct_message_channel_selector(channel, **args)
predicate = component.has_css?(channel_selector)
if args[:unread]
predicate &&
component.has_css?("#{channel_selector} .sidebar-section-link-suffix.icon.unread")
elsif args[:mention]
predicate &&
component.has_css?("#{channel_selector} .sidebar-section-link-suffix.icon.urgent")
else
predicate &&
component.has_no_css?("#{channel_selector} .sidebar-section-link-suffix.icon")
end
end
def has_no_direct_message_channel?(channel, **args)
component.has_no_css?(direct_message_channel_selector(channel, **args))
end
def direct_message_channel_selector(channel, **args)
selector = "#sidebar-section-content-chat-dms"
selector += " .sidebar-section-link.channel-#{channel.id}"
selector
end
end
end
end
end