mirror of
https://github.com/discourse/discourse.git
synced 2025-03-14 10:33:43 +00:00
DEV: Fix flaky system test (#31820)
The "Admin editing objects type theme setting when editing a theme setting of objects type allows an admin to edit a theme setting of objects type via the settings editor" system test was flaky because of the way we were filling in content into AceEditor. It is not a normal input and does not seem to function like a normal input. Using Capybara's `fill_in` method was not reliable so we will just use AceEditor's API directly to update its input.
This commit is contained in:
committed by
GitHub
parent
3165992a90
commit
dd015af0b8
@ -9,10 +9,10 @@ module PageObjects
|
|||||||
end
|
end
|
||||||
|
|
||||||
def fill_input(content)
|
def fill_input(content)
|
||||||
# Clear the input before filling it in because capybara's fill_in method doesn't seem to replace existing content
|
# Can't rely on capybara here because ace editor is not a normal input.
|
||||||
# unless the content is a blank string.
|
page.evaluate_script(
|
||||||
editor_input.fill_in(with: "")
|
"ace.edit(document.getElementsByClassName('ace')[0]).setValue(#{content.to_json})",
|
||||||
editor_input.fill_in(with: content)
|
)
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -3,6 +3,11 @@
|
|||||||
module PageObjects
|
module PageObjects
|
||||||
module Components
|
module Components
|
||||||
class AdminThemeSettingsEditor < Base
|
class AdminThemeSettingsEditor < Base
|
||||||
|
def opened?
|
||||||
|
page.has_css?(".ace_editor")
|
||||||
|
self
|
||||||
|
end
|
||||||
|
|
||||||
def fill_in(settings)
|
def fill_in(settings)
|
||||||
editor.fill_input(settings)
|
editor.fill_input(settings)
|
||||||
self
|
self
|
||||||
|
@ -90,7 +90,7 @@ module PageObjects
|
|||||||
|
|
||||||
def click_theme_settings_editor_button
|
def click_theme_settings_editor_button
|
||||||
click_button(I18n.t("admin_js.admin.customize.theme.settings_editor"))
|
click_button(I18n.t("admin_js.admin.customize.theme.settings_editor"))
|
||||||
PageObjects::Components::AdminThemeSettingsEditor.new
|
PageObjects::Components::AdminThemeSettingsEditor.new.opened?
|
||||||
end
|
end
|
||||||
|
|
||||||
def switch_to_components
|
def switch_to_components
|
||||||
|
Reference in New Issue
Block a user