2023-09-01 20:10:58 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module PageObjects
|
|
|
|
module Components
|
2024-11-27 15:21:03 -05:00
|
|
|
class AiSuggestionDropdown < PageObjects::Components::Base
|
2023-09-06 15:20:08 -04:00
|
|
|
SUGGESTION_BUTTON_SELECTOR = ".suggestion-button"
|
|
|
|
TITLE_BUTTON_SELECTOR = "#{SUGGESTION_BUTTON_SELECTOR}.suggest-titles-button"
|
|
|
|
CATEGORY_BUTTON_SELECTOR = "#{SUGGESTION_BUTTON_SELECTOR}.suggest-category-button"
|
|
|
|
TAG_BUTTON_SELECTOR = "#{SUGGESTION_BUTTON_SELECTOR}.suggest-tags-button"
|
2023-09-01 20:10:58 -04:00
|
|
|
MENU_SELECTOR = ".ai-suggestions-menu"
|
|
|
|
|
|
|
|
def click_suggest_titles_button
|
2023-09-06 15:20:08 -04:00
|
|
|
page.find(TITLE_BUTTON_SELECTOR, visible: :all).click
|
2023-09-01 20:10:58 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def click_suggest_category_button
|
|
|
|
find(CATEGORY_BUTTON_SELECTOR, visible: :all).click
|
|
|
|
end
|
|
|
|
|
|
|
|
def click_suggest_tags_button
|
|
|
|
find(TAG_BUTTON_SELECTOR, visible: :all).click
|
|
|
|
end
|
|
|
|
|
2023-09-05 12:56:12 -04:00
|
|
|
def select_suggestion_by_value(index)
|
2024-11-27 15:21:03 -05:00
|
|
|
find("#{MENU_SELECTOR} button[data-value=\"#{index}\"]").click
|
2023-09-01 20:10:58 -04:00
|
|
|
end
|
|
|
|
|
2023-09-05 12:56:12 -04:00
|
|
|
def select_suggestion_by_name(name)
|
2024-11-27 15:21:03 -05:00
|
|
|
find("#{MENU_SELECTOR} button[data-name=\"#{name}\"]").click
|
2023-09-05 12:56:12 -04:00
|
|
|
end
|
|
|
|
|
2023-09-01 20:10:58 -04:00
|
|
|
def suggestion_name(index)
|
2024-11-27 15:21:03 -05:00
|
|
|
suggestion = find("#{MENU_SELECTOR} button[data-value=\"#{index}\"]")
|
2023-09-01 20:10:58 -04:00
|
|
|
suggestion["data-name"]
|
|
|
|
end
|
|
|
|
|
|
|
|
def has_dropdown?
|
|
|
|
has_css?(MENU_SELECTOR)
|
|
|
|
end
|
|
|
|
|
|
|
|
def has_no_dropdown?
|
|
|
|
has_no_css?(MENU_SELECTOR)
|
|
|
|
end
|
2023-09-06 15:20:08 -04:00
|
|
|
|
|
|
|
def has_suggestion_button?
|
|
|
|
has_css?(SUGGESTION_BUTTON_SELECTOR)
|
|
|
|
end
|
|
|
|
|
|
|
|
def has_no_suggestion_button?
|
|
|
|
has_no_css?(SUGGESTION_BUTTON_SELECTOR)
|
|
|
|
end
|
2023-09-01 20:10:58 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|