DEV: Fix admin confirmation flaky spec (#29456)

This commit is contained in:
Martin Brennan 2024-10-30 04:59:51 +10:00 committed by GitHub
parent 9a80d71882
commit c3f99c8634
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 5 deletions

View File

@ -26,8 +26,7 @@ describe "Admin Site Setting Requires Confirmation", type: :system do
)
dialog.click_yes
expect(dialog).to be_closed
expect(settings_page).to have_overridden_setting("min_password_length")
expect(SiteSetting.min_password_length).to eq(12)
expect(settings_page).to have_overridden_setting("min_password_length", value: 12)
end
it "does not save the new setting value if the admin cancels confirmation" do
@ -36,6 +35,6 @@ describe "Admin Site Setting Requires Confirmation", type: :system do
expect(dialog).to be_open
dialog.click_no
expect(dialog).to be_closed
expect(SiteSetting.min_password_length).to eq(10)
expect(settings_page).to have_no_overridden_setting("min_password_length")
end
end

View File

@ -59,8 +59,14 @@ module PageObjects
setting_element.find(".setting-controls button.ok").click
end
def has_overridden_setting?(setting_name)
find_setting(setting_name, overridden: true)
def has_overridden_setting?(setting_name, value: nil)
setting_field = find_setting(setting_name, overridden: true)
return setting_field.find(".setting-value input").value == value.to_s if value
true
end
def has_no_overridden_setting?(setting_name)
find_setting(setting_name, overridden: false)
end
def values_in_list(setting_name)