mirror of
https://github.com/discourse/discourse.git
synced 2024-12-02 02:53:42 +08:00
f0a46f8b6f
For performance reasons we don't automatically add fabricated users to trust level auto-groups. However, when explicitly passing a trust level to the fabricator, in 99% of cases it means that trust level is relevant for the test, and we need the groups. This change makes it so that when a trust level is explicitly passed to the fabricator, the auto-groups are refreshed. There's no longer a need to also pass refresh_auto_groups: true, which means clearer tests, fewer mistakes, and less confusion.
72 lines
2.3 KiB
Ruby
72 lines
2.3 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
describe "Composer Post Validations", type: :system do
|
|
fab!(:tl0_user) { Fabricate(:user, trust_level: TrustLevel[0]) }
|
|
fab!(:tl1_user) { Fabricate(:user, trust_level: TrustLevel[1]) }
|
|
fab!(:tl2_user) { Fabricate(:user, trust_level: TrustLevel[2]) }
|
|
fab!(:topic)
|
|
fab!(:post) { Fabricate(:post, topic: topic) }
|
|
|
|
let(:composer) { PageObjects::Components::Composer.new }
|
|
let(:topic_page) { PageObjects::Pages::Topic.new }
|
|
|
|
shared_examples "post length validation" do
|
|
context "when creating a topic" do
|
|
it "shows an error when post length is insufficient" do
|
|
visit("/latest")
|
|
page.find("#create-topic").click
|
|
composer.fill_content("abc")
|
|
composer.create
|
|
composer.have_post_error(I18n.t("js.composer.error.post_length"))
|
|
end
|
|
end
|
|
|
|
context "when replying to a topic" do
|
|
it "shows an error to like instead when post length is insufficient" do
|
|
topic_page.visit_topic_and_open_composer(topic)
|
|
composer.fill_content("abc")
|
|
composer.create
|
|
composer.have_post_error(
|
|
"#{I18n.t("js.composer.error.post_length")} #{I18n.t("js.composer.error.try_like")}",
|
|
)
|
|
end
|
|
end
|
|
end
|
|
|
|
describe "trust level 0 user" do
|
|
before { sign_in(tl0_user) }
|
|
include_examples "post length validation"
|
|
end
|
|
|
|
describe "trust level 1 user" do
|
|
before { sign_in(tl1_user) }
|
|
include_examples "post length validation"
|
|
end
|
|
|
|
describe "trust level 2 user" do
|
|
before { sign_in(tl2_user) }
|
|
|
|
context "when creating a topic" do
|
|
it "shows an error when post length is insufficient" do
|
|
visit("/latest")
|
|
page.find("#create-topic").click
|
|
composer.fill_content("abc")
|
|
composer.create
|
|
composer.have_post_error(I18n.t("js.composer.error.post_length"))
|
|
end
|
|
end
|
|
|
|
context "when replying to a topic" do
|
|
it "does not show an error to like when post length is insufficient" do
|
|
topic_page.visit_topic_and_open_composer(topic)
|
|
composer.fill_content("abc")
|
|
composer.create
|
|
composer.have_post_error("#{I18n.t("js.composer.error.post_length")}")
|
|
composer.have_no_post_error(
|
|
"#{I18n.t("js.composer.error.post_length")} #{I18n.t("js.composer.error.try_like")}",
|
|
)
|
|
end
|
|
end
|
|
end
|
|
end
|