FIX: Invalid route path for staff info warnings link (#19461)

This regressed in 4da2e3fef4
This commit is contained in:
Alan Guo Xiang Tan 2022-12-14 07:14:01 +08:00 committed by GitHub
parent 618fb5b34d
commit 5d2e2677c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 41 additions and 2 deletions

View File

@ -39,8 +39,8 @@
{{/if}}
{{#if this.model.warnings_received_count}}
<div>
<LinkTo @route="userPrivateMessages.warnings" @model={{this.model}}>
<span class="warnings-received">{{this.model.warnings_received_count}}</span>{{i18n "user.staff_counters.warnings_received"}}
<LinkTo @route="userPrivateMessages.user.warnings" @model={{this.model}}>
<span class="warnings-received">{{this.model.warnings_received_count}}</span> {{i18n "user.staff_counters.warnings_received"}}
</LinkTo>
</div>
{{/if}}

View File

@ -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

View File

@ -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