2023-02-01 10:42:39 -05:00
|
|
|
# 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) }
|
2023-05-03 21:20:52 -04:00
|
|
|
fab!(:user) { with_search_indexer_enabled { Fabricate(:user, username: "someone") } }
|
2023-05-03 20:24:50 -04:00
|
|
|
|
2023-02-01 10:42:39 -05:00
|
|
|
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
|
2023-05-03 20:24:50 -04:00
|
|
|
find(".d-editor-input").fill_in(with: "Hello @som")
|
2023-02-01 10:42:39 -05:00
|
|
|
|
|
|
|
within(".autocomplete.ac-user") do |el|
|
2023-05-03 20:24:50 -04:00
|
|
|
expect(el).to have_selector(".selected .avatar[title=someone]")
|
|
|
|
expect(el.find(".selected .username")).to have_content("someone")
|
2023-02-01 10:42:39 -05:00
|
|
|
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
|