mirror of
https://github.com/discourse/discourse.git
synced 2026-08-07 13:19:19 +08:00
Previously, a member who turned chat off in their preferences saw their existing chat notifications render as blank rows, and any chat link silently bounced them to the homepage. This change registers the chat notification renderers whenever chat is enabled site-wide so those notifications still render correctly, and sends chat links to a new "chat is disabled" page that explains how to turn it back on. **BEFORE** (the notification are "blank") <img width="1400" height="1200" alt="before-notifications" src="https://github.com/user-attachments/assets/d8dcef2e-98eb-4b30-bf33-4a1f8c2c4626" /> **AFTER** (the notification are there) <img width="1400" height="1200" alt="after-notifications" src="https://github.com/user-attachments/assets/72b17123-8f82-4c5e-a74d-7d5347de623a" /> (the "blank slate" page that is displayed when you click a #chat notification after you've disabled #chat in your preferences) <img width="1400" height="1200" alt="after-disabled-page" src="https://github.com/user-attachments/assets/1905ecb5-7b8c-4682-87a9-1559ca4ec569" />
64 lines
1.9 KiB
Ruby
Vendored
64 lines
1.9 KiB
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
RSpec.describe "Chat | disabled in preferences" do
|
|
include ThemeScreenshotMarker
|
|
|
|
fab!(:current_user, :user)
|
|
fab!(:inviter, :user)
|
|
fab!(:channel_1, :category_channel)
|
|
fab!(:message_1) { Fabricate(:chat_message, chat_channel: channel_1, user: inviter) }
|
|
|
|
let(:user_menu) { PageObjects::Components::UserMenu.new }
|
|
|
|
before do
|
|
chat_system_bootstrap(current_user, [channel_1])
|
|
current_user.user_option.update!(chat_enabled: false)
|
|
|
|
current_user.notifications.create!(
|
|
notification_type: Notification.types[:chat_invitation],
|
|
high_priority: true,
|
|
read: false,
|
|
data: {
|
|
chat_channel_id: channel_1.id,
|
|
chat_channel_title: channel_1.title(current_user),
|
|
chat_channel_slug: channel_1.slug,
|
|
invited_by_username: inviter.username,
|
|
chat_message_id: message_1.id,
|
|
}.to_json,
|
|
)
|
|
|
|
current_user.notifications.create!(
|
|
notification_type: Notification.types[:chat_mention],
|
|
high_priority: true,
|
|
read: false,
|
|
data: {
|
|
chat_message_id: message_1.id,
|
|
chat_channel_id: channel_1.id,
|
|
mentioned_by_username: inviter.username,
|
|
is_direct_message_channel: false,
|
|
chat_channel_title: channel_1.title(current_user),
|
|
chat_channel_slug: channel_1.slug,
|
|
}.to_json,
|
|
)
|
|
|
|
sign_in(current_user)
|
|
end
|
|
|
|
it "still renders chat notifications in the user menu" do
|
|
visit "/"
|
|
user_menu.open
|
|
|
|
expect(page).to have_css(
|
|
".user-menu .notification.chat-invitation .item-label",
|
|
text: inviter.username,
|
|
)
|
|
screenshot_marker(label: "chatdisabled-notifications", only: :desktop)
|
|
end
|
|
|
|
it "shows the disabled page instead of redirecting home" do
|
|
visit "/chat/disabled"
|
|
|
|
expect(page).to have_css(".chat-disabled .empty-state__title")
|
|
screenshot_marker(label: "chatdisabled-page", only: :desktop)
|
|
end
|
|
end
|