2022-12-16 18:25:31 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module PageObjects
|
|
|
|
module Components
|
|
|
|
class Composer < PageObjects::Components::Base
|
2023-02-23 15:01:39 +08:00
|
|
|
COMPOSER_ID = "#reply-control"
|
2023-04-13 15:38:54 +08:00
|
|
|
AUTOCOMPLETE_MENU = ".autocomplete.ac-emoji"
|
2023-02-23 15:01:39 +08:00
|
|
|
|
|
|
|
def opened?
|
|
|
|
page.has_css?("#{COMPOSER_ID}.open")
|
|
|
|
end
|
|
|
|
|
2022-12-16 18:25:31 +08:00
|
|
|
def open_composer_actions
|
|
|
|
find(".composer-action-title .btn").click
|
|
|
|
self
|
|
|
|
end
|
|
|
|
|
2023-04-21 08:55:05 +08:00
|
|
|
def click_toolbar_button(button_class)
|
|
|
|
find(".d-editor-button-bar button.#{button_class}").click
|
2023-04-13 15:38:54 +08:00
|
|
|
self
|
|
|
|
end
|
|
|
|
|
2022-12-16 18:25:31 +08:00
|
|
|
def fill_title(title)
|
2023-02-23 15:01:39 +08:00
|
|
|
find("#{COMPOSER_ID} #reply-title").fill_in(with: title)
|
2022-12-16 18:25:31 +08:00
|
|
|
self
|
|
|
|
end
|
|
|
|
|
|
|
|
def fill_content(content)
|
2023-01-12 11:54:26 +08:00
|
|
|
composer_input.fill_in(with: content)
|
|
|
|
self
|
|
|
|
end
|
|
|
|
|
|
|
|
def type_content(content)
|
|
|
|
composer_input.send_keys(content)
|
2022-12-16 18:25:31 +08:00
|
|
|
self
|
|
|
|
end
|
|
|
|
|
2023-01-12 11:54:26 +08:00
|
|
|
def clear_content
|
|
|
|
fill_content("")
|
|
|
|
end
|
|
|
|
|
|
|
|
def has_content?(content)
|
|
|
|
composer_input.value == content
|
|
|
|
end
|
|
|
|
|
2023-04-20 15:49:35 +08:00
|
|
|
def has_popup_content?(content)
|
|
|
|
composer_popup.has_content?(content)
|
|
|
|
end
|
|
|
|
|
2022-12-16 18:25:31 +08:00
|
|
|
def select_action(action)
|
|
|
|
find(action(action)).click
|
|
|
|
self
|
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
2023-02-23 15:01:39 +08:00
|
|
|
find("#{COMPOSER_ID} .btn-primary").click
|
2022-12-16 18:25:31 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def action(action_title)
|
|
|
|
".composer-action-title .select-kit-collection li[title='#{action_title}']"
|
|
|
|
end
|
|
|
|
|
|
|
|
def button_label
|
2023-02-23 15:01:39 +08:00
|
|
|
find("#{COMPOSER_ID} .btn-primary .d-button-label")
|
2022-12-16 18:25:31 +08:00
|
|
|
end
|
2023-01-12 11:54:26 +08:00
|
|
|
|
2023-04-13 15:38:54 +08:00
|
|
|
def emoji_picker
|
|
|
|
find("#{COMPOSER_ID} .emoji-picker")
|
|
|
|
end
|
|
|
|
|
|
|
|
def emoji_autocomplete
|
|
|
|
find(AUTOCOMPLETE_MENU)
|
|
|
|
end
|
|
|
|
|
2023-05-30 05:47:18 +08:00
|
|
|
def switch_category(category_name)
|
|
|
|
find(".category-chooser").click
|
|
|
|
find(".category-row[data-name='#{category_name}']").click
|
|
|
|
end
|
|
|
|
|
2023-04-13 15:38:54 +08:00
|
|
|
def has_emoji_autocomplete?
|
|
|
|
has_css?(AUTOCOMPLETE_MENU)
|
|
|
|
end
|
|
|
|
|
2023-05-05 07:45:53 +08:00
|
|
|
def has_no_emoji_autocomplete?
|
|
|
|
has_no_css?(AUTOCOMPLETE_MENU)
|
|
|
|
end
|
|
|
|
|
|
|
|
EMOJI_SUGGESTION_SELECTOR = "#{AUTOCOMPLETE_MENU} .emoji-shortname"
|
|
|
|
|
2023-04-13 15:38:54 +08:00
|
|
|
def has_emoji_suggestion?(emoji)
|
2023-05-05 07:45:53 +08:00
|
|
|
has_css?(EMOJI_SUGGESTION_SELECTOR, text: emoji)
|
|
|
|
end
|
|
|
|
|
|
|
|
def has_no_emoji_suggestion?(emoji)
|
|
|
|
has_no_css?(EMOJI_SUGGESTION_SELECTOR, text: emoji)
|
2023-04-13 15:38:54 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def has_emoji_preview?(emoji)
|
2023-05-05 07:45:53 +08:00
|
|
|
page.has_css?(emoji_preview_selector(emoji))
|
|
|
|
end
|
|
|
|
|
|
|
|
def has_no_emoji_preview?(emoji)
|
|
|
|
page.has_no_css?(emoji_preview_selector(emoji))
|
2023-04-13 15:38:54 +08:00
|
|
|
end
|
|
|
|
|
2023-05-30 05:47:18 +08:00
|
|
|
def has_composer_input?
|
|
|
|
page.has_css?("#{COMPOSER_ID} .d-editor .d-editor-input")
|
|
|
|
end
|
|
|
|
|
|
|
|
def has_form_template?
|
|
|
|
page.has_css?(".form-template-form__wrapper")
|
|
|
|
end
|
|
|
|
|
|
|
|
def has_form_template_field?(field)
|
|
|
|
page.has_css?(".form-template-field[data-field-type='#{field}']")
|
|
|
|
end
|
|
|
|
|
|
|
|
def has_form_template_chooser?
|
|
|
|
page.has_css?(".composer-select-form-template")
|
|
|
|
end
|
|
|
|
|
2023-01-12 11:54:26 +08:00
|
|
|
def composer_input
|
2023-02-23 15:01:39 +08:00
|
|
|
find("#{COMPOSER_ID} .d-editor .d-editor-input")
|
2023-01-12 11:54:26 +08:00
|
|
|
end
|
2023-04-20 15:49:35 +08:00
|
|
|
|
|
|
|
def composer_popup
|
|
|
|
find("#{COMPOSER_ID} .composer-popup")
|
|
|
|
end
|
2023-05-05 07:45:53 +08:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def emoji_preview_selector(emoji)
|
|
|
|
".d-editor-preview .emoji[title=':#{emoji}:']"
|
|
|
|
end
|
2022-12-16 18:25:31 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|