mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 13:07:54 +08:00
FEATURE: add new hidden site setting to show full names in user card
adds a hidden site setting, "prioritize_full_names_in_ux", whose effect is to prefer full names in user-menu notifications Co-authored-by: Mark VanLandingham <markvanlan@gmail.com> Co-authored-by: Alan Guo Xiang Tan <gxtan1990@gmail.com>
This commit is contained in:
@ -51,6 +51,30 @@ module PageObjects
|
||||
)
|
||||
end
|
||||
|
||||
def has_user_full_name_mentioned_notification?(topic, user_that_mentioned)
|
||||
expect(find("#quick-access-replies .mentioned").text).to eq(
|
||||
"#{user_that_mentioned.name} #{topic.title}",
|
||||
)
|
||||
end
|
||||
|
||||
def has_user_full_name_messaged_notification?(post, user)
|
||||
expect(find("#quick-access-all-notifications .private-message").text).to eq(
|
||||
"#{user.name} #{post.topic.title}",
|
||||
)
|
||||
end
|
||||
|
||||
def has_user_full_name_bookmarked_notification?(post, user)
|
||||
expect(find("#quick-access-bookmarks .bookmark").text).to eq(
|
||||
"#{user.name} #{post.topic.title}",
|
||||
)
|
||||
end
|
||||
|
||||
def has_user_username_mentioned_notification?(topic, user_that_mentioned)
|
||||
expect(find("#quick-access-replies .mentioned").text).to eq(
|
||||
"#{user_that_mentioned.username} #{topic.title}",
|
||||
)
|
||||
end
|
||||
|
||||
def has_right_replies_button_count?(count)
|
||||
expect(find("#user-menu-button-replies").text).to eq(count.to_s)
|
||||
end
|
||||
|
@ -48,5 +48,100 @@ RSpec.describe "Viewing User Menu", system: true do
|
||||
|
||||
expect(user_menu).to have_group_mentioned_notification(topic, user, mentionable_group)
|
||||
end
|
||||
|
||||
context "with SiteSetting.prioritize_full_name_in_ux=true" do
|
||||
before { SiteSetting.prioritize_full_name_in_ux = true }
|
||||
|
||||
it "should display user full name in mention notifications" do
|
||||
Jobs.run_immediately!
|
||||
|
||||
user = Fabricate(:user)
|
||||
user2 = Fabricate(:user, name: "John Doe")
|
||||
PostCreator.create!(user, topic_id: topic.id, raw: "Hello @#{user2.username}")
|
||||
|
||||
sign_in(user2)
|
||||
|
||||
visit("/latest")
|
||||
|
||||
user_menu.open
|
||||
|
||||
expect(user_menu).to have_right_replies_button_count(1)
|
||||
|
||||
user_menu.click_replies_notifications_tab
|
||||
|
||||
expect(user_menu).to have_user_full_name_mentioned_notification(topic, user)
|
||||
end
|
||||
|
||||
it "should display user full name in message notification" do
|
||||
Jobs.run_immediately!
|
||||
|
||||
user = Fabricate(:moderator)
|
||||
user2 = Fabricate(:user, name: "John Doe")
|
||||
post =
|
||||
PostCreator.create!(
|
||||
user,
|
||||
title: "message",
|
||||
raw: "private message",
|
||||
archetype: Archetype.private_message,
|
||||
target_usernames: [user2.username],
|
||||
)
|
||||
|
||||
sign_in(user2)
|
||||
|
||||
visit("/latest")
|
||||
user_menu.open
|
||||
|
||||
expect(user_menu).to have_user_full_name_messaged_notification(post, user)
|
||||
end
|
||||
|
||||
it "should display user full name in bookmark notification" do
|
||||
Jobs.run_immediately!
|
||||
|
||||
user = Fabricate(:moderator)
|
||||
user2 = Fabricate(:user, name: "John Doe")
|
||||
post =
|
||||
PostCreator.create!(
|
||||
user,
|
||||
title: "message in a bottle",
|
||||
raw: "private message",
|
||||
archetype: Archetype.private_message,
|
||||
target_usernames: [user2.username],
|
||||
)
|
||||
Bookmark.create!(bookmarkable: post, user: user2)
|
||||
sign_in(user2)
|
||||
|
||||
visit("/latest")
|
||||
user_menu.open
|
||||
user_menu.click_bookmarks_tab
|
||||
expect(user_menu).to have_user_full_name_bookmarked_notification(post, user)
|
||||
end
|
||||
end
|
||||
|
||||
context "with SiteSetting.prioritize_full_name_in_ux=false" do
|
||||
before { SiteSetting.prioritize_full_name_in_ux = false }
|
||||
|
||||
it "should display only username in mention notifications" do
|
||||
Jobs.run_immediately!
|
||||
|
||||
SiteSetting.prioritize_username_in_ux = true
|
||||
|
||||
user = Fabricate(:user)
|
||||
user2 = Fabricate(:user, name: "John Doe")
|
||||
|
||||
PostCreator.create!(user, topic_id: topic.id, raw: "Hello @#{user2.username}")
|
||||
|
||||
sign_in(user2)
|
||||
|
||||
visit("/latest")
|
||||
|
||||
user_menu.open
|
||||
|
||||
expect(user_menu).to have_right_replies_button_count(1)
|
||||
|
||||
user_menu.click_replies_notifications_tab
|
||||
|
||||
expect(user_menu).to have_user_username_mentioned_notification(topic, user)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user