discourse/spec/system/page_objects/pages/user_preferences_interface.rb
Alan Guo Xiang Tan 7d9a823a55
DEV: Fix flaky user preferences interface system test (#21800)
Why is this change required?

The flaky system test was due to the fact that we had to poll for the
user preferences interface page to reload after saving. However, this
turns out to be a bug on the user perferences interface page because the
page should only reload if the user has selected a new theme that is
different from the site's default but we were reloading the page for
users that did not have any user theme selected. Therefore there was an
unnecessary reload happening when saving other fields on the user
preferences interface page.
2023-05-29 11:56:21 +08:00

31 lines
794 B
Ruby

# frozen_string_literal: true
module PageObjects
module Pages
class UserPreferencesInterface < PageObjects::Pages::Base
def visit(user)
page.visit("/u/#{user.username}/preferences/interface")
self
end
def has_bookmark_after_notification_mode?(value)
page.has_css?(
"#bookmark-after-notification-mode .select-kit-header[data-value=\"#{value}\"]",
)
end
def select_bookmark_after_notification_mode(value)
page.find("#bookmark-after-notification-mode").click
page.find(".select-kit-row[data-value=\"#{value}\"]").click
self
end
def save_changes
click_button "Save Changes"
expect(page).to have_content(I18n.t("js.saved"))
self
end
end
end
end