2022-11-11 17:44:40 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module PageObjects
|
|
|
|
module Pages
|
2024-06-19 14:01:24 +08:00
|
|
|
class AdminSiteSettings < PageObjects::Pages::Base
|
2022-11-11 17:44:40 +08:00
|
|
|
def visit_filtered_plugin_setting(filter)
|
2023-10-28 05:42:57 +08:00
|
|
|
page.visit("/admin/site_settings/category/plugins?filter=#{filter}")
|
|
|
|
self
|
|
|
|
end
|
|
|
|
|
2024-06-19 14:01:24 +08:00
|
|
|
def visit(filter = nil)
|
|
|
|
if filter.present?
|
|
|
|
page.visit("/admin/site_settings?filter=#{filter}")
|
|
|
|
else
|
|
|
|
page.visit("/admin/site_settings")
|
|
|
|
end
|
2022-11-11 17:44:40 +08:00
|
|
|
self
|
|
|
|
end
|
|
|
|
|
2023-04-13 15:38:54 +08:00
|
|
|
def visit_category(category)
|
|
|
|
page.visit("/admin/site_settings/category/#{category}")
|
|
|
|
self
|
|
|
|
end
|
|
|
|
|
2024-07-09 10:05:31 +08:00
|
|
|
def find_setting(setting_name, overridden: false)
|
|
|
|
find(
|
|
|
|
".admin-detail .row.setting[data-setting='#{setting_name}']#{overridden ? ".overridden" : ""}",
|
|
|
|
)
|
2024-06-19 14:01:24 +08:00
|
|
|
end
|
|
|
|
|
2022-11-11 17:44:40 +08:00
|
|
|
def toggle_setting(setting_name, text = "")
|
2024-06-19 14:01:24 +08:00
|
|
|
setting = find_setting(setting_name)
|
2022-11-11 17:44:40 +08:00
|
|
|
setting.find(".setting-value span", text: text).click
|
2024-06-19 14:01:24 +08:00
|
|
|
save_setting(setting)
|
|
|
|
end
|
|
|
|
|
|
|
|
def change_number_setting(setting_name, value, save_changes = true)
|
|
|
|
setting = find_setting(setting_name)
|
|
|
|
setting.fill_in(with: value)
|
|
|
|
save_setting(setting) if save_changes
|
2022-11-11 17:44:40 +08:00
|
|
|
end
|
2023-04-13 15:38:54 +08:00
|
|
|
|
|
|
|
def select_from_emoji_list(setting_name, text = "", save_changes = true)
|
|
|
|
setting = find(".admin-detail .row.setting[data-setting='#{setting_name}']")
|
|
|
|
setting.find(".setting-value .value-list > .value button").click
|
|
|
|
setting.find(".setting-value .emoji-picker .emoji[title='#{text}']").click
|
2024-06-19 14:01:24 +08:00
|
|
|
save_setting(setting) if save_changes
|
|
|
|
end
|
|
|
|
|
|
|
|
def save_setting(setting_element)
|
|
|
|
setting_element.find(".setting-controls button.ok").click
|
2023-04-13 15:38:54 +08:00
|
|
|
end
|
|
|
|
|
2024-07-09 10:05:31 +08:00
|
|
|
def has_overridden_setting?(setting_name)
|
|
|
|
find_setting(setting_name, overridden: true)
|
|
|
|
end
|
|
|
|
|
2023-04-13 15:38:54 +08:00
|
|
|
def values_in_list(setting_name)
|
|
|
|
vals = []
|
|
|
|
setting = find(".admin-detail .row.setting[data-setting='#{setting_name}']")
|
|
|
|
setting
|
|
|
|
.all(:css, ".setting-value .values .value .value-input span")
|
|
|
|
.map { |e| vals << e.text }
|
|
|
|
vals
|
|
|
|
end
|
2023-10-28 05:42:57 +08:00
|
|
|
|
|
|
|
def type_in_search(input)
|
|
|
|
find("input#setting-filter").send_keys(input)
|
|
|
|
self
|
|
|
|
end
|
|
|
|
|
2024-03-18 06:50:39 +08:00
|
|
|
def clear_search
|
|
|
|
find("#setting-filter").click
|
|
|
|
self
|
|
|
|
end
|
|
|
|
|
|
|
|
def toggle_only_show_overridden
|
|
|
|
find("#setting-filter-toggle-overridden").click
|
|
|
|
self
|
|
|
|
end
|
|
|
|
|
2023-10-28 05:42:57 +08:00
|
|
|
def has_search_result?(setting)
|
2024-03-18 06:50:39 +08:00
|
|
|
has_css?("div[data-setting='#{setting}']")
|
|
|
|
end
|
|
|
|
|
|
|
|
def has_n_results?(count)
|
|
|
|
has_css?(".admin-detail .row.setting", count: count)
|
|
|
|
end
|
|
|
|
|
|
|
|
def has_greater_than_n_results?(count)
|
|
|
|
assert_selector(".admin-detail .row.setting", minimum: count)
|
2023-10-28 05:42:57 +08:00
|
|
|
end
|
2022-11-11 17:44:40 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|