2023-04-07 01:32:21 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2023-06-07 09:26:58 +08:00
|
|
|
RSpec.describe "Message errors", type: :system do
|
2023-04-07 01:32:21 +08:00
|
|
|
fab!(:current_user) { Fabricate(:admin) }
|
|
|
|
let(:chat_page) { PageObjects::Pages::Chat.new }
|
|
|
|
let(:channel_page) { PageObjects::Pages::ChatChannel.new }
|
|
|
|
let(:max_length) { SiteSetting.chat_maximum_message_length }
|
|
|
|
|
|
|
|
before { chat_system_bootstrap }
|
|
|
|
|
|
|
|
context "when message is too long" do
|
|
|
|
fab!(:channel) { Fabricate(:chat_channel) }
|
|
|
|
|
2023-11-06 22:45:30 +08:00
|
|
|
before { channel.add(current_user) }
|
|
|
|
|
2023-04-07 01:32:21 +08:00
|
|
|
it "only shows the error, not the message" do
|
|
|
|
sign_in(current_user)
|
|
|
|
chat_page.visit_channel(channel)
|
|
|
|
|
2023-06-02 06:35:42 +08:00
|
|
|
channel_page.send_message("atoolongmessage" + "a" * max_length)
|
2023-04-07 01:32:21 +08:00
|
|
|
|
|
|
|
expect(page).to have_no_content("atoolongmessage")
|
|
|
|
expect(page).to have_content(I18n.t("chat.errors.message_too_long", count: max_length))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|