FIX: correctly follow enable_emoji_shortcuts in chat (#33297)

Prior to this fix, this setting would have no effect in chat.
This commit is contained in:
Joffrey JAFFEUX
2025-06-23 17:42:24 +02:00
committed by GitHub
parent f0f75b1a63
commit e241de51cd
2 changed files with 29 additions and 1 deletions
+1 -1
View File
@@ -214,7 +214,6 @@ module Chat
chat-transcript
discourse-local-dates
emoji
emojiShortcuts
inlineEmoji
html-img
hashtag-autocomplete
@@ -253,6 +252,7 @@ module Chat
features = MARKDOWN_FEATURES.dup
features << "image-grid" if bot
features << "emojiShortcuts" if SiteSetting.enable_emoji_shortcuts
rules = MARKDOWN_IT_RULES.dup
rules << "heading" if bot
@@ -198,6 +198,34 @@ describe Chat::Message do
end
describe ".cook" do
context "with enable_emoji_shortcuts site setting" do
context "when enabled" do
before { SiteSetting.enable_emoji_shortcuts = true }
it "converts emoji shortcuts to emoji" do
cooked = described_class.cook <<~MD
emoji shortcut :)
MD
expected =
"<p>emoji shortcut <img src=\"/images/emoji/twitter/slight_smile.png?v=#{Emoji::EMOJI_VERSION}\" title=\":slight_smile:\" class=\"emoji\" alt=\":slight_smile:\" loading=\"lazy\" width=\"20\" height=\"20\"></p>"
expect(cooked).to match(expected)
end
end
context "when disabled" do
before { SiteSetting.enable_emoji_shortcuts = false }
it "does not convert emoji shortcuts" do
cooked = described_class.cook <<~MD
emoji shortcut :)
MD
expect(cooked).to match("<p>emoji shortcut :)</p>")
end
end
end
it "does not support HTML tags" do
cooked = described_class.cook("<h1>test</h1>")