mirror of
https://github.com/discourse/discourse.git
synced 2024-11-27 20:43:40 +08:00
2968fb6a5c
* Why was this change necessary? The current logic in the user.hbs template file does not render the trust level element for the user's info panel when the user is TL0, because 0 is treated as falsey in the `if` conditional block. Ref: https://meta.discourse.org/t/tl0-not-displayed-on-users-profile-pages/271779/10 * How does it address the problem? This PR adds a predicate helper method local to the user controller that includes an additional check which returns true if the trust_level of the user is 0 on top of the existing logic. This allows TL0 users to have their trust level rendered correctly in their profile's info panel.
41 lines
1.0 KiB
Ruby
41 lines
1.0 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
module PageObjects
|
|
module Pages
|
|
class User < PageObjects::Pages::Base
|
|
def visit(user)
|
|
page.visit("/u/#{user.username}")
|
|
self
|
|
end
|
|
|
|
def find(selector)
|
|
page.find(".new-user-wrapper #{selector}")
|
|
end
|
|
|
|
def active_user_primary_navigation
|
|
find(".user-navigation-primary li a.active")
|
|
end
|
|
|
|
def active_user_secondary_navigation
|
|
find(".user-navigation-secondary li a.active")
|
|
end
|
|
|
|
def has_warning_messages_path?(user)
|
|
page.has_current_path?("/u/#{user.username}/messages/warnings")
|
|
end
|
|
|
|
def click_staff_info_warnings_link(user, warnings_count: 0)
|
|
staff_counters = page.find(".staff-counters")
|
|
staff_counters.find("a[href='/u/#{user.username}/messages/warnings']").click
|
|
self
|
|
end
|
|
|
|
def expand_info_panel
|
|
button = page.find("button[aria-controls='collapsed-info-panel']")
|
|
button.click if button["aria-expanded"] == "false"
|
|
self
|
|
end
|
|
end
|
|
end
|
|
end
|