Skip to content

A platform for community discussion. Free, open, simple.

DEV: correctly tests text is rendered in replies (#20845)

Joffrey JAFFEUX05174a6abd39
diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-composer-message-details.hbs b/plugins/chat/assets/javascripts/discourse/components/chat-composer-message-details.hbs
index fcc65c8c996..37763906d32 100644
--- a/plugins/chat/assets/javascripts/discourse/components/chat-composer-message-details.hbs
+++ b/plugins/chat/assets/javascripts/discourse/components/chat-composer-message-details.hbs
@@ -3,9 +3,9 @@
{{d-icon this.icon}}
<ChatUserAvatar @user={{this.message.user}} />
<span class="chat-reply__username">{{this.message.user.username}}</span>
- <span class="chat-reply__excerpt">{{replace-emoji
- this.message.excerpt
- }}</span>
+ <span class="chat-reply__excerpt">
+ {{replace-emoji this.message.excerpt}}
+ </span>
</div>
<FlatButton
diff --git a/plugins/chat/spec/system/chat_channel_spec.rb b/plugins/chat/spec/system/chat_channel_spec.rb
index c61d8c16291..970ad56bf30 100644
--- a/plugins/chat/spec/system/chat_channel_spec.rb
+++ b/plugins/chat/spec/system/chat_channel_spec.rb
@@ -189,7 +189,7 @@ RSpec.describe "Chat channel", type: :system, js: true do
end
end
- context "when replying to message that has tags" do
+ context "when replying to message that has HTML tags" do
fab!(:other_user) { Fabricate(:user) }
fab!(:message_2) do
Fabricate(
@@ -208,12 +208,10 @@ RSpec.describe "Chat channel", type: :system, js: true do
sign_in(current_user)
end
- xit "escapes the reply-to line" do
+ it "renders text in the reply-to" do
chat.visit_channel(channel_1)
- expect(find(".chat-reply .chat-reply__excerpt")["innerHTML"].strip).to eq(
- "&lt;mark&gt;not marked&lt;/mark&gt;",
- )
+ expect(find(".chat-reply .chat-reply__excerpt")["innerHTML"].strip).to eq("not marked")
end
end
diff --git a/plugins/chat/spec/system/chat_composer_spec.rb b/plugins/chat/spec/system/chat_composer_spec.rb
index 105d0cf4c4b..572770996d2 100644
--- a/plugins/chat/spec/system/chat_composer_spec.rb
+++ b/plugins/chat/spec/system/chat_composer_spec.rb
@@ -31,6 +31,19 @@ RSpec.describe "Chat composer", type: :system, js: true do
text: message_1.user.username,
)
end
+
+ context "with HTML tags" do
+ before { message_1.update!(message: "<mark>not marked</mark>") }
+
+ it "renders text in the details" do
+ chat.visit_channel(channel_1)
+ channel.reply_to(message_1)
+
+ expect(
+ find(".chat-composer-message-details .chat-reply__excerpt")["innerHTML"].strip,
+ ).to eq("not marked")
+ end
+ end
end
context "when editing a message" do