mirror of
https://github.com/discourse/discourse.git
synced 2026-08-06 13:08:40 +08:00
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>
77 lines
2.1 KiB
Ruby
Vendored
77 lines
2.1 KiB
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
RSpec.describe "User notification preferences | Chat notifications" do
|
|
fab!(:current_user, :user)
|
|
|
|
before do
|
|
chat_system_bootstrap
|
|
sign_in(current_user)
|
|
end
|
|
|
|
def visit_notifications
|
|
page.visit("/my/preferences/notifications")
|
|
end
|
|
|
|
def combo(selector)
|
|
PageObjects::Components::SelectKit.new(selector)
|
|
end
|
|
|
|
def save
|
|
find(".save-changes").click
|
|
expect(page).to have_css(".saved")
|
|
end
|
|
|
|
context "when chat is disabled site-wide" do
|
|
before { SiteSetting.chat_enabled = false }
|
|
|
|
it "does not render the chat notifications section" do
|
|
visit_notifications
|
|
|
|
expect(page).to have_no_css(".control-group.chat-notifications")
|
|
end
|
|
end
|
|
|
|
context "when the user has disabled chat" do
|
|
before { current_user.user_option.update!(chat_enabled: false) }
|
|
|
|
it "does not render the chat notifications section" do
|
|
visit_notifications
|
|
|
|
expect(page).to have_no_css(".control-group.chat-notifications")
|
|
end
|
|
end
|
|
|
|
it "renders the chat notifications section" do
|
|
visit_notifications
|
|
|
|
expect(page).to have_css(".control-group.chat-notifications")
|
|
end
|
|
|
|
it "can change and persist the chat notification settings" do
|
|
visit_notifications
|
|
|
|
combo(".chat-header-indicator-preference").expand
|
|
combo(".chat-header-indicator-preference").select_row_by_value("dm_and_mentions")
|
|
|
|
combo(".chat-sound").expand
|
|
combo(".chat-sound").select_row_by_value("retro")
|
|
|
|
save
|
|
visit_notifications
|
|
|
|
expect(combo(".chat-header-indicator-preference").value).to eq("dm_and_mentions")
|
|
expect(combo(".chat-sound").value).to eq("retro")
|
|
end
|
|
|
|
it "can toggle and persist ignore channel-wide mentions" do
|
|
current_user.user_option.update!(ignore_channel_wide_mention: false)
|
|
visit_notifications
|
|
|
|
find(".pref-chat-ignore-channel-wide-mention input[type=checkbox]").click
|
|
save
|
|
visit_notifications
|
|
|
|
expect(page).to have_css(".pref-chat-ignore-channel-wide-mention input[type=checkbox]:checked")
|
|
expect(current_user.reload.user_option.ignore_channel_wide_mention).to eq(true)
|
|
end
|
|
end
|