diff --git a/app/assets/javascripts/discourse/app/templates/user.hbs b/app/assets/javascripts/discourse/app/templates/user.hbs
index 80b308b0132..47c2ecaa401 100644
--- a/app/assets/javascripts/discourse/app/templates/user.hbs
+++ b/app/assets/javascripts/discourse/app/templates/user.hbs
@@ -39,8 +39,8 @@
{{/if}}
{{#if this.model.warnings_received_count}}
-
- {{this.model.warnings_received_count}}{{i18n "user.staff_counters.warnings_received"}}
+
+ {{this.model.warnings_received_count}} {{i18n "user.staff_counters.warnings_received"}}
{{/if}}
diff --git a/spec/system/page_objects/pages/user.rb b/spec/system/page_objects/pages/user.rb
index 82115d893b9..a5062bafe5f 100644
--- a/spec/system/page_objects/pages/user.rb
+++ b/spec/system/page_objects/pages/user.rb
@@ -3,6 +3,11 @@
module PageObjects
module Pages
class User < PageObjects::Pages::Base
+ def visit(user)
+ page.visit("/u/#{user.username}")
+ self
+ end
+
def find(selector)
page.find(".user-content-wrapper #{selector}")
end
@@ -14,6 +19,16 @@ module PageObjects
def active_user_secondary_navigation
find(".user-secondary-navigation 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(warnings_count: 0)
+ staff_counters = page.find(".staff-counters")
+ staff_counters.click_link("#{warnings_count} #{I18n.t("js.user.staff_counters.warnings_received")}")
+ self
+ end
end
end
end
diff --git a/spec/system/user_page/staff_info_spec.rb b/spec/system/user_page/staff_info_spec.rb
new file mode 100644
index 00000000000..ef58f4adf14
--- /dev/null
+++ b/spec/system/user_page/staff_info_spec.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+describe 'Viewing user staff info as an admin', type: :system, js: true do
+ fab!(:user) { Fabricate(:user) }
+ fab!(:admin) { Fabricate(:admin) }
+ let(:user_page) { PageObjects::Pages::User.new }
+
+ before do
+ sign_in(admin)
+ end
+
+ context 'for warnings' do
+ fab!(:topic) { Fabricate(:private_message_topic, user: admin, recipient: user) }
+ fab!(:user_warning) { UserWarning.create!(user: user, created_by: admin, topic: topic) }
+
+ it "should display the right link to user's warnings with the right count in text" do
+ user_page
+ .visit(user)
+ .click_staff_info_warnings_link(warnings_count: 1)
+
+ expect(user_page).to have_warning_messages_path(user)
+ end
+ end
+end