discourse/plugins/chat/spec/lib/chat
Régis Hanol ce2767cf38
FIX: Chat channel onebox icons render and support channel emoji (#39826)
Chat channel oneboxes have been rendering with no icon next to the
channel title since #20744. That PR changed the mustache templates to
emit `<svg><use href="#d-chat"></use></svg>` and registered a JS-side
`replaceIcon("d-chat", "comment")` to compensate. The replacement only
runs through `iconHTML()` / `{{icon}}` at render time though — the
mustache markup is cooked into the post HTML server-side, so the JS swap
never touches it. `d-chat` has never been part of the SVG sprite, which
means the browser cannot resolve `#d-chat` and the badge renders empty.

This commit pre-renders the channel badge in `Chat::OneboxHandler` and
passes it to the templates as a single HTML blob:

* When the channel has an emoji, it is rendered via
`Emoji.codes_to_img`.
* Otherwise we fall back to the chat bubble (`#comment`, which is in the
sprite) tinted with the channel's category color.

The fix covers all three onebox templates (channel, message, thread). A
post-deploy migration flips `baked_version` to 0 on every post whose
cooked HTML contains `chat-onebox`, so the recurring `Post.rebake_old`
job picks them up and rebakes them in the background with the fixed
templates.

Ref - t/183234
2026-05-11 15:17:36 +02:00
..
channel_archive_service_spec.rb DEV: Restore and fix five chat specs (#39541) 2026-04-27 10:41:06 +02:00
channel_fetcher_spec.rb FEATURE: Show subcategory channels in category channel list (#37936) 2026-02-23 11:29:24 +10:00
channel_hashtag_data_source_spec.rb DEV: add channel hashtag style type (#33284) 2025-06-20 10:04:36 +04:00
channel_membership_manager_spec.rb DEV: add shortcut fab!(:variable, :fabricator) to specs (#33577) 2025-07-11 11:16:34 -03:00
core_pretty_text_spec.rb FIX: supports html entities in chat (#34591) 2025-08-28 07:34:24 +02:00
duplicate_message_validator_spec.rb DEV: add shortcut fab!(:variable, :fabricator) to specs (#33577) 2025-07-11 11:16:34 -03:00
guardian_extensions_spec.rb FIX: align deleted chat message restore behavior (#38493) 2026-03-11 13:39:54 +01:00
inline_onebox_handler_spec.rb DEV: add shortcut fab!(:variable, :fabricator) to specs (#33577) 2025-07-11 11:16:34 -03:00
message_bookmarkable_spec.rb DEV: Don't use fab! for non-ActiveRecord model objects (#39272) 2026-04-15 00:52:34 +02:00
message_mover_spec.rb DEV: add shortcut fab!(:variable, :fabricator) to specs (#33577) 2025-07-11 11:16:34 -03:00
message_processor_spec.rb FIX: secure uploads for quoted images in chat (#37900) 2026-02-18 21:03:13 +04:00
message_reactor_spec.rb FEATURE: Restore web push quick reply for chat messages (#39614) 2026-04-29 12:36:03 -03:00
messages_exporter_spec.rb DEV: add shortcut fab!(:variable, :fabricator) to specs (#33577) 2025-07-11 11:16:34 -03:00
notifier_spec.rb FEATURE: Restore web push quick reply for chat messages (#39614) 2026-04-29 12:36:03 -03:00
onebox_handler_spec.rb FIX: Chat channel onebox icons render and support channel emoji (#39826) 2026-05-11 15:17:36 +02:00
parsed_mentions_spec.rb DEV: add shortcut fab!(:variable, :fabricator) to specs (#33577) 2025-07-11 11:16:34 -03:00
post_notification_handler_spec.rb DEV: add shortcut fab!(:variable, :fabricator) to specs (#33577) 2025-07-11 11:16:34 -03:00
review_queue_spec.rb FIX: Prevent moderators from being auto-silenced (#39709) 2026-05-05 14:54:46 +08:00
slack_compatibility_spec.rb DEV: Remove unnecessary rails_helper requiring (#26364) 2024-03-26 11:32:01 +01:00
statistics_spec.rb DEV: add shortcut fab!(:variable, :fabricator) to specs (#33577) 2025-07-11 11:16:34 -03:00
transcript_service_spec.rb DEV: Fix a chat archive edge-case (#39625) 2026-04-29 11:38:55 +02:00