0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-09 21:45:25 +08:00
discourse/plugins/chat/spec/system/user_chat_preferences_spec.rb
Keegan George 436041645f
FEATURE: Make the message send shortcut a core user option (#42105)
**Previously**, the enter/meta+enter send shortcut was a chat-only
preference (`chat_send_shortcut`), so chat-style composers in other
plugins — like AI bot conversations — always sent on Enter with no way
to insert a newline.

**In this update**, promoted it to a core `send_shortcut` user option on
the Interface preferences page, honored by the chat composer, the core
docked composer, and AI bot conversations.

The `chat_send_shortcut` column is backfilled into `send_shortcut`
post-deploy and kept (ignored) for now, mirroring the
`push_notification_level` promotion; the column drop, the serializer
compatibility alias removal, and the `plugin_manifest.yml` cleanup land
in a follow-up PR.

| Before | After |
| --- | --- |
|
![before](https://github.com/discourse/discourse/releases/download/_gh-attach-assets/before-jmgi09.png)
|
![after](https://github.com/discourse/discourse/releases/download/_gh-attach-assets/after-crkznx.png)
|
2026-07-28 13:58:12 -07:00

113 lines
3.5 KiB
Ruby
Vendored
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# frozen_string_literal: true
RSpec.describe "User chat preferences" do
fab!(:current_user, :user)
let(:user_preferences_chat_page) { PageObjects::Pages::UserPreferencesChat.new }
let(:emoji_picker) { PageObjects::Components::EmojiPicker.new }
let(:chat) { PageObjects::Pages::Chat.new }
let(:channel) { PageObjects::Pages::ChatChannel.new }
let(:form) { PageObjects::Components::FormKit.new(".form-kit") }
before do
chat_system_bootstrap
sign_in(current_user)
end
context "when chat disabled" do
before do
SiteSetting.chat_enabled = false
sign_in(current_user)
end
it "doesnt show the tab" do
visit("/my/preferences")
expect(page).to have_no_css(".user-nav__preferences-chat", visible: :all)
end
it "shows a not found page" do
user_preferences_chat_page.visit
expect(page).to have_content(I18n.t("page_not_found.title"))
end
end
it "can change chat quick reaction type to custom and select emoji" do
user_preferences_chat_page.visit
form.field("chat_quick_reaction_type").select("custom")
custom_field = form.field("chat_quick_reactions_custom")
expect(custom_field.component).to have_css(".emoji-picker-trigger", count: 3, wait: 5)
reaction_buttons = custom_field.component.all("button.emoji-picker-trigger")
expect(reaction_buttons.first.find("img")[:title]).to eq "heart"
reaction_buttons.first.click
emoji_picker.select_emoji(":sweat_smile:")
form.submit
user_preferences_chat_page.visit
expect(
form.field("chat_quick_reaction_type").component.find("input[type='radio'][value='custom']"),
).to be_checked
custom_field = form.field("chat_quick_reactions_custom")
reaction_buttons = custom_field.component.all("button.emoji-picker-trigger")
expect(reaction_buttons.first.find("img")[:title]).to eq "sweat_smile"
end
describe "chat interface" do
fab!(:category_channel_1, :category_channel)
fab!(:message_1) { Fabricate(:chat_message, chat_channel: category_channel_1) }
before { category_channel_1.add(current_user) }
it "sees expected quick-reactions on hover" do
# save custom and look for reaction
user_preferences_chat_page.visit
form.field("chat_quick_reaction_type").select("custom")
form.submit
expect(page).to have_css(".save-controls .saved")
chat.visit_channel(category_channel_1)
channel.hover_message(message_1)
expect(channel.find_quick_reaction("smile")).to be_present
# save frequent and look for reaction
user_preferences_chat_page.visit
form.field("chat_quick_reaction_type").select("frequent")
form.submit
expect(page).to have_css(".save-controls .saved")
chat.visit_channel(category_channel_1)
channel.hover_message(message_1)
expect(channel.find_quick_reaction("tada")).to be_present
end
end
it "can select and save separate sidebar mode" do
user_preferences_chat_page.visit
form.field("chat_separate_sidebar_mode").select("fullscreen")
form.submit
user_preferences_chat_page.visit
expect(form.field("chat_separate_sidebar_mode").value).to eq("fullscreen")
end
context "as an admin on another user's preferences" do
fab!(:current_user, :admin)
fab!(:user_1, :user)
before { sign_in(current_user) }
it "allows to change settings" do
visit("/u/#{user_1.username}/preferences")
find(".user-nav__preferences-chat", visible: :all).click
expect(page).to have_current_path("/u/#{user_1.username}/preferences/chat")
end
end
end