Skip to content

A platform for community discussion. Free, open, simple.

FIX: Mention with a status should open the user card (#33979)

Osama Sayegh99abfb21f0ee
diff --git a/app/assets/javascripts/discourse/app/components/card-contents-base.js b/app/assets/javascripts/discourse/app/components/card-contents-base.js
index e90fd98c4df..84d3616d93d 100644
--- a/app/assets/javascripts/discourse/app/components/card-contents-base.js
+++ b/app/assets/javascripts/discourse/app/components/card-contents-base.js
@@ -146,7 +146,7 @@ export default class CardContentsBase extends Component {
// Mention click
this._showCardOnClick(event, this.mentionSelector, (el) =>
- el.innerText.replace(/^@/, "")
+ el.innerText.trim().replace(/^@/, "")
);
}
diff --git a/spec/system/page_objects/components/post.rb b/spec/system/page_objects/components/post.rb
index 749703ef6bd..d3e6b4c13de 100644
--- a/spec/system/page_objects/components/post.rb
+++ b/spec/system/page_objects/components/post.rb
@@ -69,6 +69,10 @@ module PageObjects
post.find(".post-info.edits").click
end
+ def mentions_of(user)
+ post.all("a.mention[href='/u/#{user.username}']")
+ end
+
private
def post_id
diff --git a/spec/system/page_objects/components/user_card.rb b/spec/system/page_objects/components/user_card.rb
new file mode 100644
index 00000000000..eed09830eea
--- /dev/null
+++ b/spec/system/page_objects/components/user_card.rb
@@ -0,0 +1,15 @@
+# frozen_string_literal: true
+
+module PageObjects
+ module Components
+ class UserCard < PageObjects::Components::Base
+ def visible?
+ has_css?("#user-card")
+ end
+
+ def showing_user?(username)
+ has_css?("#user-card.user-card-#{username}")
+ end
+ end
+ end
+end
diff --git a/spec/system/user_card_spec.rb b/spec/system/user_card_spec.rb
new file mode 100644
index 00000000000..ff0b1393bba
--- /dev/null
+++ b/spec/system/user_card_spec.rb
@@ -0,0 +1,34 @@
+# frozen_string_literal: true
+
+describe "User Card", type: :system do
+ fab!(:current_user, :admin)
+ fab!(:topic) { Fabricate(:post).topic }
+ fab!(:user)
+ let(:mention) { "@#{user.username}" }
+ let!(:post_with_mention) do
+ PostCreator.create!(current_user, topic_id: topic.id, raw: "Hello #{mention}")
+ end
+ let(:topic_page) { PageObjects::Pages::Topic.new }
+ let(:user_card) { PageObjects::Components::UserCard.new }
+ let(:mention_post) { PageObjects::Components::Post.new(post_with_mention.post_number) }
+
+ before { sign_in(current_user) }
+
+ context "when the mentioned user has set a status" do
+ fab!(:user_status) { Fabricate(:user_status, user: user) }
+
+ before { SiteSetting.enable_user_status = true }
+
+ it "is still possible to view the user card via a mention even there's a status next to the mention" do
+ topic_page.visit_topic(topic)
+
+ mention_anchors = mention_post.mentions_of(user)
+ expect(mention_anchors.size).to eq(1)
+
+ mention_anchors.first.click
+
+ expect(user_card).to be_visible
+ expect(user_card).to be_showing_user(user.username)
+ end
+ end
+end