discourse/plugins/chat/spec/system/message_errors_spec.rb
Joffrey JAFFEUX 0b65aa8b77
DEV: ensures we have error message before message check (#24647)
Previously the spec could be flakey as the long message could show on the screen while we await for processing. Now we will first check to have the error message on screen, at this point the erroneous message should never be visible.
2023-11-30 10:55:05 +01:00

27 lines
826 B
Ruby

# frozen_string_literal: true
RSpec.describe "Message errors", type: :system do
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) }
before { channel.add(current_user) }
it "only shows the error, not the message" do
sign_in(current_user)
chat_page.visit_channel(channel)
channel_page.send_message("atoolongmessage" + "a" * max_length)
expect(page).to have_content(I18n.t("chat.errors.message_too_long", count: max_length))
expect(page).to have_no_content("atoolongmessage")
end
end
end