discourse/spec/system/page_objects/pages/user_preferences_interface.rb
Osama Sayegh c6bbbd0608
FIX: Set the correct state of the dark mode checkbox user preference (#31214)
This commit fixes a bug in the "Dark Mode" checkbox in the interface user
preferences where the checkbox state doesn't appear in the disabled
state if the user disables dark mode.

This happens because when rendering the checkbox, we check the relevant
user options field within the controller's `init` method, but at that
point in the controller's life cycle, the `user_option` object isn't
available. What we should do instead is move this check to the route's
`setupController` method where the `user_option` object is available and
we can set the correct state on the controller.

https://meta.discourse.org/t/-/349976 (private topic)
2025-02-06 20:31:37 +03:00

35 lines
889 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 dark_mode_checkbox
page.find('.dark-mode input[type="checkbox"]')
end
def save_changes
click_button "Save Changes"
expect(page).to have_content(I18n.t("js.saved"))
self
end
end
end
end