2022-12-16 05:25:31 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module PageObjects
|
|
|
|
module Components
|
|
|
|
class TopicList < PageObjects::Components::Base
|
2023-03-05 21:13:10 -05:00
|
|
|
TOPIC_LIST_BODY_SELECTOR = ".topic-list-body"
|
|
|
|
TOPIC_LIST_ITEM_SELECTOR = "#{TOPIC_LIST_BODY_SELECTOR} .topic-list-item"
|
2023-03-02 20:46:21 -05:00
|
|
|
|
2022-12-16 05:25:31 -05:00
|
|
|
def topic_list
|
2023-03-05 21:13:10 -05:00
|
|
|
TOPIC_LIST_BODY_SELECTOR
|
|
|
|
end
|
|
|
|
|
|
|
|
def has_topics?(count:)
|
|
|
|
page.has_css?(TOPIC_LIST_ITEM_SELECTOR, count: count)
|
2023-03-02 20:46:21 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def has_topic?(topic)
|
|
|
|
page.has_css?(topic_list_item_class(topic))
|
|
|
|
end
|
|
|
|
|
|
|
|
def has_no_topic?(topic)
|
|
|
|
page.has_no_css?(topic_list_item_class(topic))
|
2022-12-16 05:25:31 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def visit_topic_with_title(title)
|
2023-03-05 21:13:10 -05:00
|
|
|
find("#{TOPIC_LIST_BODY_SELECTOR} a", text: title).click
|
2022-12-16 05:25:31 -05:00
|
|
|
end
|
2023-03-02 20:46:21 -05:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def topic_list_item_class(topic)
|
2023-03-05 21:13:10 -05:00
|
|
|
"#{TOPIC_LIST_ITEM_SELECTOR}[data-topic-id='#{topic.id}']"
|
2023-03-02 20:46:21 -05:00
|
|
|
end
|
2022-12-16 05:25:31 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|