mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 01:27:15 +08:00
FIX: instantly removes group message when leaving (#25961)
Prior to this fix clicking <kbd>x</kdb> on a channel row would effectively leave the channel on server side, but it wouldn't disappear from the screen before a page refresh.
This commit is contained in:
@ -0,0 +1,53 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module PageObjects
|
||||
module Components
|
||||
module Chat
|
||||
class ChannelRow < PageObjects::Components::Base
|
||||
SELECTOR = ".chat-channel-row"
|
||||
|
||||
attr_reader :id
|
||||
|
||||
def initialize(id)
|
||||
@id = id
|
||||
end
|
||||
|
||||
def non_existent?(**args)
|
||||
exists?(**args, does_not_exist: true)
|
||||
end
|
||||
|
||||
def exists?(**args)
|
||||
selector = build_selector(**args)
|
||||
selector_method = args[:does_not_exist] ? :has_no_selector? : :has_selector?
|
||||
page.send(selector_method, selector)
|
||||
end
|
||||
|
||||
def leave
|
||||
component(class: ".can-leave").hover
|
||||
btn = component.find(".chat-channel-leave-btn", visible: :all)
|
||||
# style manipulation is necessary to have it working with @media(hover: hover) on CI
|
||||
page.execute_script(
|
||||
"document.querySelector('#{build_selector} .chat-channel-leave-btn').style.display = 'block';",
|
||||
)
|
||||
btn.click
|
||||
page.execute_script(
|
||||
"document.querySelector('#{build_selector} .chat-channel-leave-btn').style.display = '';",
|
||||
)
|
||||
end
|
||||
|
||||
def component(**args)
|
||||
find(build_selector(**args))
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def build_selector(**args)
|
||||
selector = SELECTOR
|
||||
selector += args[:class] if args[:class]
|
||||
selector += "[data-chat-channel-id=\"#{self.id}\"]" if self.id
|
||||
selector
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -24,6 +24,16 @@ module PageObjects
|
||||
find("#{VISIBLE_DRAWER} .c-navbar__back-button").click
|
||||
end
|
||||
|
||||
def visit_index
|
||||
visit("/")
|
||||
PageObjects::Pages::Chat.new.open_from_header
|
||||
end
|
||||
|
||||
def visit_channel(channel)
|
||||
visit_index
|
||||
open_channel(channel)
|
||||
end
|
||||
|
||||
def open_channel(channel)
|
||||
channel_index.open_channel(channel)
|
||||
has_no_css?(".chat-skeleton")
|
||||
|
Reference in New Issue
Block a user