discourse/spec/system/page_objects/pages/admin_site_texts.rb
Martin Brennan a16faa27cd
FEATURE: Allow showing site text search in selected locale (#28453)
When searching for site texts for admin using the english
version of the text, previously we would show the english
version in the results _even if_ there was another locale
translated version available when a locale was selected
from the dropdown.

This commit adds a "Only show results in selected locale"
checkbox option which will instead make it so the results
shown are in the target locale, making it easier for translators
to tell when there is actually translations vs. missing tranlsations.
2024-08-26 11:25:36 +10:00

54 lines
1.3 KiB
Ruby

# frozen_string_literal: true
module PageObjects
module Pages
class AdminSiteTexts < PageObjects::Pages::Base
def visit
page.visit("/admin/customize/site_texts")
self
end
def search(text)
find(".site-text-search").fill_in(with: text)
page.send_keys(:escape)
end
def has_translation_key?(key)
has_css?(".site-text-id", text: key)
end
def has_translation_value?(value)
has_css?(".site-text-value", text: value)
end
def select_locale(locale_short_name)
locale_selector = PageObjects::Components::SelectKit.new(".locale-search")
locale_selector.expand
locale_selector.select_row_by_value(locale_short_name)
locale_selector.collapse
end
def toggle_only_show_overridden
find("#toggle-overridden").click
end
def toggle_only_show_outdated
find("#toggle-outdated").click
end
def toggle_only_show_results_in_selected_locale
find("#toggle-only-locale").click
end
def edit_translation(key)
find(".site-text[data-site-text-id='#{key}']").find(".site-text-edit").click
end
def override_translation(value)
find(".site-text-value").fill_in(with: value)
find(".save-changes").click
end
end
end
end