FIX: corrects a regression hiding avatar in user selector (#20107)

Due to the way templates work, the incorrect variable (user instead of item) was not causing any error, and just failing silently to display the avatar.

This commit is also providing a basic spec for completion of users and groups.
This commit is contained in:
Joffrey JAFFEUX 2023-02-01 16:42:39 +01:00 committed by GitHub
parent 5c699e4384
commit df50df041a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 39 additions and 1 deletions

View File

@ -4,7 +4,7 @@
{{#if item.isUser}}
<li>
<a href title="{{item.name}}" class="{{item.cssClasses}}">
{{avatar user imageSize="tiny"}}
{{avatar item imageSize="tiny"}}
<span class='username'>{{format-username item.username}}</span>
{{#if item.name}}
<span class='name'>{{item.name}}</span>

View File

@ -0,0 +1,38 @@
# frozen_string_literal: true
describe "User selector", type: :system, js: true do
fab!(:topic) { Fabricate(:topic) }
fab!(:post) { Fabricate(:post, topic: topic) }
fab!(:current_user) { Fabricate(:admin) }
before do
current_user.activate
sign_in(current_user)
end
context "when autocompleting a username" do
it "correctly shows the user" do
visit("/t/-/#{topic.id}")
find(".btn-primary.create").click
find(".d-editor-input").fill_in(with: "Hello @dis")
within(".autocomplete.ac-user") do |el|
expect(el).to have_selector(".selected .avatar[title=discobot]")
expect(el.find(".selected .username")).to have_content("discobot")
end
end
end
context "when autocompleting a group" do
it "correctly shows the user" do
visit("/t/-/#{topic.id}")
find(".btn-primary.create").click
find(".d-editor-input").fill_in(with: "Hello @adm")
within(".autocomplete.ac-user") do |el|
expect(el).to have_selector(".selected .d-icon-users")
expect(el.find(".selected .username")).to have_content("admins")
end
end
end
end