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:
Martin Brennan
2023-01-12 13:54:26 +10:00
committed by GitHub
parent 1f59a8299d
commit 2ed75dbaf6
3 changed files with 35 additions and 27 deletions

View File

@ -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