DEV: Allow typed objects theme settings to be saved via settings editor (#26100)

Why this change?

On the `/admin/customize/themes/<:id>` route, we allow admins to edit
all settings via a settings editor. Prior to this change, trying to edit
and save a typed objects theme settings will result in an error on the
server.
This commit is contained in:
Alan Guo Xiang Tan
2024-03-11 08:42:12 +08:00
committed by GitHub
parent 17a60be189
commit 8d4f405da4
11 changed files with 171 additions and 34 deletions

View File

@@ -9,6 +9,9 @@ module PageObjects
end
def fill_input(content)
# Clear the input before filling it in because capybara's fill_in method doesn't seem to replace existing content
# unless the content is a blank string.
editor_input.fill_in(with: "")
editor_input.fill_in(with: content)
self
end
@@ -18,7 +21,10 @@ module PageObjects
end
def editor_input
find(".ace-wrapper .ace_text-input", visible: false)
find(".ace-wrapper .ace:not(.hidden)", visible: true).find(
".ace_text-input",
visible: false,
)
end
end
end

View File

@@ -0,0 +1,23 @@
# frozen_string_literal: true
module PageObjects
module Components
class AdminThemeSettingsEditor < Base
def fill_in(settings)
editor.fill_input(settings)
self
end
def save
click_button(I18n.t("admin_js.admin.customize.theme.save"))
self
end
private
def editor
@editor ||= within(".settings-editor") { AceEditor.new }
end
end
end
end

View File

@@ -42,6 +42,11 @@ module PageObjects
def click_edit_objects_theme_setting_button(setting_name)
find(".theme-setting[data-setting=\"#{setting_name}\"] .setting-value-edit-button").click
end
def click_theme_settings_editor_button
click_button(I18n.t("admin_js.admin.customize.theme.settings_editor"))
PageObjects::Components::AdminThemeSettingsEditor.new
end
end
end
end