0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-06 13:08:40 +08:00
discourse/plugins/chat/spec/system/user_chat_preferences_spec.rb
chapoi ceed7027de
UX: Consolidate chat notifications into live notification preferences (#41538)
Previously, chat notification settings lived on a separate Chat
preferences tab and push delivery was gated by a standalone
`only_chat_push_notifications` toggle, splitting notification controls
across two places.

This change moves the chat notification settings onto the main
notifications preferences page and replaces the boolean with a
`push_notification_level` dropdown (`none`/`all`/`chat_only`), so push
notifications are managed in one place. This follows an established
pattern, as the solved and assign plugins do this too.

This should make this control more coherent and less confusing.

<img width="574" height="838" alt="CleanShot 2026-07-13 at 15 04 03"
src="https://github.com/user-attachments/assets/0217cb63-77a3-437a-83ae-8003082af6b7"
/>

---------

Co-authored-by: Martin Brennan <martin@discourse.org>
2026-07-14 08:32:48 +02:00

124 lines
3.9 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 send shorcut sidebar mode" do
user_preferences_chat_page.visit
form.field("chat_send_shortcut").select("meta_enter")
form.submit
user_preferences_chat_page.visit
expect(
form.field("chat_send_shortcut").component.find("input[type='radio'][value='meta_enter']"),
).to be_checked
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