mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-03 08:18:42 +08:00
We've had the new floatkit-based autocomplete live in various parts of Discourse for about a month now, and it's stable enough for us to remove the site setting letting admins revert to the jquery-based autocomplete library which is now deprecated.
93 lines
2.7 KiB
Ruby
93 lines
2.7 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
describe "Composer", type: :system do
|
|
fab!(:user) { Fabricate(:user, refresh_auto_groups: true) }
|
|
let(:composer) { PageObjects::Components::Composer.new }
|
|
|
|
before { sign_in(user) }
|
|
|
|
it "displays user cards in preview" do
|
|
page.visit "/new-topic"
|
|
|
|
expect(composer).to be_opened
|
|
|
|
composer.fill_content("@#{user.username}")
|
|
composer.preview.find("a.mention").click
|
|
|
|
page.has_css?("#user-card")
|
|
end
|
|
|
|
context "in a topic, the autocomplete prioritizes" do
|
|
fab!(:topic_user, :user)
|
|
fab!(:second_reply_user, :user)
|
|
|
|
fab!(:topic) { Fabricate(:topic, user: topic_user) }
|
|
fab!(:op) { Fabricate(:post, topic: topic, user: topic_user) }
|
|
let!(:op_post) { PageObjects::Components::Post.new(op.post_number) }
|
|
|
|
fab!(:second_reply) { Fabricate(:post, topic: topic, user: second_reply_user) }
|
|
let!(:second_reply_post) { PageObjects::Components::Post.new(second_reply.post_number) }
|
|
|
|
before { SiteSetting.enable_names = false }
|
|
|
|
it "the topic owner if replying to topic" do
|
|
page.visit "/t/#{topic.id}"
|
|
|
|
op_post.reply
|
|
expect(composer).to be_opened
|
|
composer.type_content("@")
|
|
|
|
expect(composer.mention_menu_autocomplete_username_list).to eq(
|
|
[op.username, second_reply_user.username], # must be first the topic owner
|
|
)
|
|
end
|
|
|
|
it "the recipient of the reply when replying" do
|
|
page.visit "/t/#{topic.id}"
|
|
|
|
second_reply_post.reply
|
|
expect(composer).to be_opened
|
|
composer.type_content("@")
|
|
|
|
expect(composer.mention_menu_autocomplete_username_list).to eq(
|
|
[second_reply_user.username, topic_user.username], # must be first the reply user
|
|
)
|
|
end
|
|
|
|
it "the recipient of the reply when editing a reply" do
|
|
admin = Fabricate(:admin, refresh_auto_groups: true)
|
|
reply_to_second_post =
|
|
Fabricate(:post, topic: topic, user: user, reply_to_post_number: second_reply.post_number)
|
|
reply_post = PageObjects::Components::Post.new(reply_to_second_post.post_number)
|
|
|
|
sign_in(admin)
|
|
page.visit "/t/#{topic.id}"
|
|
reply_post.edit
|
|
|
|
expect(composer).to be_opened
|
|
|
|
composer.type_content(" @")
|
|
|
|
expect(composer.mention_menu_autocomplete_username_list).to eq(
|
|
[second_reply_user.username, user.username, topic_user.username],
|
|
)
|
|
end
|
|
end
|
|
|
|
it "focuses the reply button when tabbing out of both editor modes" do
|
|
page.visit "/new-topic"
|
|
expect(composer).to be_opened
|
|
composer.focus
|
|
|
|
page.send_keys(:tab)
|
|
|
|
expect(composer.reply_button_focused?).to eq(true)
|
|
|
|
composer.toggle_rich_editor
|
|
composer.focus
|
|
|
|
page.send_keys(:tab)
|
|
|
|
expect(composer.reply_button_focused?).to eq(true)
|
|
end
|
|
end
|