mirror of
https://github.com/discourse/discourse.git
synced 2024-12-02 15:05:37 +08:00
78bafb331a
This commit makes it so the site settings filter controls and the list of settings input editors themselves can be used elsewhere in the admin UI outside of /admin/site_settings This allows us to provide more targeted groups of settings in different UI areas where it makes sense to provide them, such as on plugin pages. You could open a single page for a plugin where you can see information about that plugin, change settings, and configure it with custom UIs in the one place. In future we will do this in "config areas" for other parts of the admin UI.
72 lines
2.0 KiB
Ruby
72 lines
2.0 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
module PageObjects
|
|
module Pages
|
|
class AdminSettings < PageObjects::Pages::Base
|
|
def visit_filtered_plugin_setting(filter)
|
|
page.visit("/admin/site_settings/category/plugins?filter=#{filter}")
|
|
self
|
|
end
|
|
|
|
def visit
|
|
page.visit("/admin/site_settings")
|
|
self
|
|
end
|
|
|
|
def visit_category(category)
|
|
page.visit("/admin/site_settings/category/#{category}")
|
|
self
|
|
end
|
|
|
|
def toggle_setting(setting_name, text = "")
|
|
setting = find(".admin-detail .row.setting[data-setting='#{setting_name}']")
|
|
setting.find(".setting-value span", text: text).click
|
|
setting.find(".setting-controls button.ok").click
|
|
end
|
|
|
|
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
|
|
setting.find(".setting-controls button.ok").click if save_changes
|
|
end
|
|
|
|
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
|
|
|
|
def type_in_search(input)
|
|
find("input#setting-filter").send_keys(input)
|
|
self
|
|
end
|
|
|
|
def clear_search
|
|
find("#setting-filter").click
|
|
self
|
|
end
|
|
|
|
def toggle_only_show_overridden
|
|
find("#setting-filter-toggle-overridden").click
|
|
self
|
|
end
|
|
|
|
def has_search_result?(setting)
|
|
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)
|
|
end
|
|
end
|
|
end
|
|
end
|