mirror of
https://github.com/discourse/discourse.git
synced 2025-05-21 18:12:32 +08:00
REFACTOR: composer/thread (#21910)
This commit contains multiple changes to improve the composer behavior especially in the context of a thread: - Generally rename anything of the form `chatChannelThread...` to `chatThread...`` - Moves the textarea interactor instance inside the composer server - Improves the focus state and closing of panel related to the use of the Escape shortcut - Creates `Chat::ThreadList` as a component instead of having `Chat::Thread::ListItem` and others which could imply they were children of a the `Chat::Thread` component
This commit is contained in:
@ -122,7 +122,7 @@ module PageObjects
|
||||
|
||||
def edit_message(message, text = nil)
|
||||
open_edit_message(message)
|
||||
send_message(text) if text
|
||||
send_message(message.message + text) if text
|
||||
end
|
||||
|
||||
def send_message(text = nil)
|
||||
|
@ -122,6 +122,17 @@ module PageObjects
|
||||
text: I18n.t("js.chat.deleted", count: count),
|
||||
)
|
||||
end
|
||||
|
||||
def open_edit_message(message)
|
||||
hover_message(message)
|
||||
click_more_button
|
||||
find("[data-value='edit']").click
|
||||
end
|
||||
|
||||
def edit_message(message, text = nil)
|
||||
open_edit_message(message)
|
||||
send_message(message.message + text) if text
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -58,6 +58,10 @@ module PageObjects
|
||||
input.send_keys([MODIFIER, "i"])
|
||||
end
|
||||
|
||||
def cancel_shortcut
|
||||
input.send_keys(:escape)
|
||||
end
|
||||
|
||||
def indented_text_shortcut
|
||||
input.send_keys([MODIFIER, "e"])
|
||||
end
|
||||
@ -70,9 +74,25 @@ module PageObjects
|
||||
find(context).find(SELECTOR).find(".chat-composer-button.-emoji").click
|
||||
end
|
||||
|
||||
def cancel_editing
|
||||
component.click_button(class: "cancel-message-action")
|
||||
end
|
||||
|
||||
def editing_message?(message)
|
||||
value == message.message && message_details.editing?(message)
|
||||
end
|
||||
|
||||
def editing_no_message?
|
||||
value == "" && message_details.has_no_message?
|
||||
end
|
||||
|
||||
def focus
|
||||
component.click
|
||||
end
|
||||
|
||||
def focused?
|
||||
component.has_css?(".chat-composer.is-focused")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -21,8 +21,17 @@ module PageObjects
|
||||
selectors += "[data-id=\"#{args[:id]}\"]" if args[:id]
|
||||
selectors += "[data-action=\"#{args[:action]}\"]" if args[:action]
|
||||
selector_method = args[:does_not_exist] ? :has_no_selector? : :has_selector?
|
||||
predicate = component.send(selector_method, selectors)
|
||||
|
||||
component.send(selector_method, selectors)
|
||||
text_options = {}
|
||||
text_options[:text] = args[:text] if args[:text]
|
||||
text_options[:exact_text] = args[:exact_text] if args[:exact_text]
|
||||
if text_options.present?
|
||||
predicate &&=
|
||||
component.send(selector_method, "#{selectors} .chat-reply__excerpt", **text_options)
|
||||
end
|
||||
|
||||
predicate
|
||||
end
|
||||
|
||||
def has_no_message?(**args)
|
||||
|
Reference in New Issue
Block a user