mirror of
https://github.com/discourse/discourse.git
synced 2025-06-02 16:29:32 +08:00

Doing a full page load in system test is expensive and takes about 1 second on average. Since this shared example is being run across 70 official plugins, the additional time to execute these full page loads adds up. Therefore, we are trading off some readability here for CI runtime. Before: ``` Randomized with seed 7202 .................. Finished in 21.26 seconds (files took 1.72 seconds to load) 18 examples, 0 failures ``` After: ``` Randomized with seed 7202 ........ Finished in 14.28 seconds (files took 1.74 seconds to load) 8 examples, 0 failures ```
77 lines
2.3 KiB
Ruby
77 lines
2.3 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) { Fabricate(:user) }
|
|
fab!(:second_reply_user) { Fabricate(: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
|
|
end
|