discourse/spec/system/page_objects/pages/admin_settings.rb
Blake Erickson 1a78e8ec1b
FEATURE: Add keywords support for site_settings search (#24146)
* FEATURE: Add keywords support for site_settings search

This change allows for a new `keywords` field that can be added to site
settings in order to help with searching. Keywords are not visible in
the UI, but site settings matching one of the contained keywords will
appear when searching for that keyword.

Keywords can be added for site settings inside of the
`config/locales/server.en.yml` file under the new `keywords` key.

```
site_settings
  example_1: "fancy description"
  example_2: "another description"

  keywords:
    example_1: "capybara"
```

* Add keywords entry for a recently changed site setting and add system specs

* Use page.visit now that we have our own visit
2023-10-27 15:42:57 -06:00

54 lines
1.6 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 has_search_result?(setting)
page.has_selector?("div[data-setting='#{setting}']")
end
end
end
end