From 68539f60845e48a6332afb2c71f7498aab697fef Mon Sep 17 00:00:00 2001 From: Jan Cernik <66427541+jancernik@users.noreply.github.com> Date: Tue, 22 Oct 2024 14:53:42 -0300 Subject: [PATCH] DEV: More specs for chat excerpts (#29344) --- plugins/chat/spec/system/chat_channel_spec.rb | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/plugins/chat/spec/system/chat_channel_spec.rb b/plugins/chat/spec/system/chat_channel_spec.rb index 64040cc1005..253143146af 100644 --- a/plugins/chat/spec/system/chat_channel_spec.rb +++ b/plugins/chat/spec/system/chat_channel_spec.rb @@ -286,6 +286,20 @@ RSpec.describe "Chat channel", type: :system do Fabricate(:chat_message, user: other_user, chat_channel: channel_1) Fabricate(:chat_message, in_reply_to: message_2, user: current_user, chat_channel: channel_1) channel_1.add(other_user) + + stub_request(:get, "https://foo.com/").with(headers: { "Accept" => "*/*" }).to_return( + status: 200, + body: "", + headers: { + }, + ) + + stub_request(:head, "https://foo.com/").with(headers: { "Host" => "foo.com" }).to_return( + status: 200, + body: "", + headers: { + }, + ) end it "renders text in the reply-to" do @@ -305,6 +319,20 @@ RSpec.describe "Chat channel", type: :system do ) end + it "limits excerpt length" do + update_message!(message_2, user: other_user, text: ("a" * 160)) + chat_page.visit_channel(channel_1) + + expect(find(".chat-reply .chat-reply__excerpt")["innerHTML"].strip).to eq("a" * 150 + "…") + end + + it "renders urls correclty in excerpts" do + update_message!(message_2, user: other_user, text: "https://foo.com") + chat_page.visit_channel(channel_1) + + expect(find(".chat-reply .chat-reply__excerpt")["innerHTML"].strip).to eq("https://foo.com") + end + it "renders safe HTML like mentions (which are just links) in the reply-to" do update_message!( message_2,