mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 23:38:29 +08:00
DEV: DRY up PageObject::Topic and PageObject::Components::Composer (#19841)
The latter can be called directly from the Topic page object, so we can remove some duplication between the two. There are levels of page objects (e.g. entire page, component, complete flow) and its perfectly valid to call one from another.
This commit is contained in:
@ -4,13 +4,7 @@ module PageObjects
|
||||
module Pages
|
||||
class Topic < PageObjects::Pages::Base
|
||||
def initialize
|
||||
setup_component_classes!(
|
||||
post_show_more_actions: ".show-more-actions",
|
||||
post_action_button_bookmark: ".bookmark.with-reminder",
|
||||
reply_button: ".topic-footer-main-buttons > .create",
|
||||
composer: "#reply-control",
|
||||
composer_textarea: "#reply-control .d-editor .d-editor-input",
|
||||
)
|
||||
@composer_component = PageObjects::Components::Composer.new
|
||||
end
|
||||
|
||||
def visit_topic(topic)
|
||||
@ -18,6 +12,17 @@ module PageObjects
|
||||
self
|
||||
end
|
||||
|
||||
def open_new_topic
|
||||
page.visit "/"
|
||||
find("button#create-topic").click
|
||||
self
|
||||
end
|
||||
|
||||
def open_new_message
|
||||
page.visit "/new-message"
|
||||
self
|
||||
end
|
||||
|
||||
def visit_topic_and_open_composer(topic)
|
||||
visit_topic(topic)
|
||||
click_reply_button
|
||||
@ -85,24 +90,20 @@ module PageObjects
|
||||
has_css?("#reply-control.open")
|
||||
end
|
||||
|
||||
def find_composer
|
||||
find("#reply-control .d-editor .d-editor-input")
|
||||
end
|
||||
|
||||
def type_in_composer(input)
|
||||
find_composer.send_keys(input)
|
||||
@composer_component.type_content(input)
|
||||
end
|
||||
|
||||
def fill_in_composer(input)
|
||||
find_composer.fill_in(with: input)
|
||||
@composer_component.fill_content(input)
|
||||
end
|
||||
|
||||
def clear_composer
|
||||
fill_in_composer("")
|
||||
@composer_component.clear_content
|
||||
end
|
||||
|
||||
def has_composer_content?(content)
|
||||
find_composer.value == content
|
||||
@composer_component.has_content?(content)
|
||||
end
|
||||
|
||||
def send_reply
|
||||
@ -110,7 +111,7 @@ module PageObjects
|
||||
end
|
||||
|
||||
def fill_in_composer_title(title)
|
||||
find("#reply-title").fill_in(with: title)
|
||||
@composer_component.fill_title(title)
|
||||
end
|
||||
|
||||
private
|
||||
|
Reference in New Issue
Block a user