mirror of
https://github.com/discourse/discourse.git
synced 2025-01-31 02:49:29 +08:00
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:
parent
731282c2ec
commit
6487c8ef24
|
@ -103,9 +103,9 @@ export default class ChatComposer extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
get hasContent() {
|
get hasContent() {
|
||||||
const minLength = this.siteSettings.chat_minimum_message_length || 0;
|
const minLength = this.siteSettings.chat_minimum_message_length || 1;
|
||||||
return (
|
return (
|
||||||
this.currentMessage?.message?.length > minLength ||
|
this.currentMessage?.message?.length >= minLength ||
|
||||||
(this.canAttachUploads && this.currentMessage?.uploads?.length > 0)
|
(this.canAttachUploads && this.currentMessage?.uploads?.length > 0)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)")
|
expect(find(".chat-composer__input").value).to eq("[discourse](https://www.discourse.org)")
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user