mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 16:34:31 +08:00
DEV: implements initial messages component (#21727)
This should also make `message_notifications_with_sidebar_spec.rb` more resilient as we are now checking for `is-persisted` class instead of checking for the absence of `is-staged`.
This commit is contained in:
@ -17,8 +17,8 @@ module PageObjects
|
||||
visit("/chat")
|
||||
end
|
||||
|
||||
def visit_channel(channel)
|
||||
visit(channel.url)
|
||||
def visit_channel(channel, message_id: nil)
|
||||
visit(channel.url + (message_id ? "/#{message_id}" : ""))
|
||||
has_no_css?(".chat-channel--not-loaded-once")
|
||||
has_no_css?(".chat-skeleton")
|
||||
end
|
||||
|
@ -7,6 +7,10 @@ module PageObjects
|
||||
@composer ||= PageObjects::Components::Chat::Composer.new(".chat-channel")
|
||||
end
|
||||
|
||||
def messages
|
||||
@messages ||= PageObjects::Components::Chat::Messages.new(".chat-channel")
|
||||
end
|
||||
|
||||
def replying_to?(message)
|
||||
find(".chat-channel .chat-reply", text: message.message)
|
||||
end
|
||||
@ -115,10 +119,12 @@ module PageObjects
|
||||
end
|
||||
|
||||
def send_message(text = nil)
|
||||
text ||= Faker::Lorem.characters(number: SiteSetting.chat_minimum_message_length)
|
||||
text = text.chomp if text.present? # having \n on the end of the string counts as an Enter keypress
|
||||
fill_composer(text)
|
||||
click_send_message
|
||||
click_composer
|
||||
has_no_loading_skeleton?
|
||||
end
|
||||
|
||||
def reply_to(message)
|
||||
|
@ -12,6 +12,10 @@ module PageObjects
|
||||
PageObjects::Components::Chat::ComposerMessageDetails.new(".chat-thread")
|
||||
end
|
||||
|
||||
def messages
|
||||
@messages ||= PageObjects::Components::Chat::Messages.new(".chat-thread")
|
||||
end
|
||||
|
||||
def header
|
||||
find(".chat-thread__header")
|
||||
end
|
||||
@ -47,6 +51,7 @@ module PageObjects
|
||||
end
|
||||
|
||||
def send_message(text = nil)
|
||||
text ||= Faker::Lorem.characters(number: SiteSetting.chat_minimum_message_length)
|
||||
text = text.chomp if text.present? # having \n on the end of the string counts as an Enter keypress
|
||||
fill_composer(text)
|
||||
click_send_message
|
||||
|
@ -0,0 +1,30 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module PageObjects
|
||||
module Components
|
||||
module Chat
|
||||
class Message < PageObjects::Components::Base
|
||||
attr_reader :context
|
||||
|
||||
SELECTOR = ".chat-message-container"
|
||||
|
||||
def initialize(context)
|
||||
@context = context
|
||||
end
|
||||
|
||||
def exists?(**args)
|
||||
selectors = SELECTOR
|
||||
selectors += "[data-id=\"#{args[:id]}\"]" if args[:id]
|
||||
selectors += ".is-persisted" if args[:persisted]
|
||||
selectors += ".is-staged" if args[:staged]
|
||||
|
||||
if args[:text]
|
||||
find(context).has_selector?(selectors + " " + ".chat-message-text", text: args[:text])
|
||||
else
|
||||
find(context).has_selector?(selectors)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,25 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module PageObjects
|
||||
module Components
|
||||
module Chat
|
||||
class Messages < PageObjects::Components::Base
|
||||
attr_reader :context
|
||||
|
||||
SELECTOR = ".chat-message-container"
|
||||
|
||||
def initialize(context)
|
||||
@context = context
|
||||
end
|
||||
|
||||
def has_message?(**args)
|
||||
PageObjects::Components::Chat::Message.new(".chat-channel").exists?(**args)
|
||||
end
|
||||
|
||||
def has_no_message?(**args)
|
||||
!has_message?(**args)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user