FIX: properly respects chat_minimum_message_length (#21256)

Before this fix we were only considering `>` and not `>=`, this also adds two tests.
This commit is contained in:
Joffrey JAFFEUX
2023-04-26 17:35:35 +02:00
committed by GitHub
parent 731282c2ec
commit 6487c8ef24
2 changed files with 33 additions and 2 deletions

View File

@ -293,4 +293,35 @@ RSpec.describe "Chat composer", type: :system, js: true do
expect(find(".chat-composer__input").value).to eq("[discourse](https://www.discourse.org)")
end
end
context "when posting a message with length equal to minimum length" do
before do
SiteSetting.chat_minimum_message_length = 1
channel_1.add(current_user)
sign_in(current_user)
end
it "works" do
chat.visit_channel(channel_1)
find("body").send_keys("1")
channel.click_send_message
expect(channel).to have_message(text: "1")
end
end
context "when posting a message with length superior to minimum length" do
before do
SiteSetting.chat_minimum_message_length = 2
channel_1.add(current_user)
sign_in(current_user)
end
it "doesn’t allow to send" do
chat.visit_channel(channel_1)
find("body").send_keys("1")
expect(page).to have_css(".chat-composer--send-disabled")
end
end
end