DEV: More specs for chat excerpts (#29344)

This commit is contained in:
Jan Cernik 2024-10-22 14:53:42 -03:00 committed by GitHub
parent cbdab52056
commit 68539f6084
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 28 additions and 0 deletions

View File

@ -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,