mirror of
https://github.com/discourse/discourse.git
synced 2024-12-11 19:43:41 +08:00
d3a1b09361
This commit allows the user to set their preference vis-a-vis the chat icon in the header of the page. There are three options: - All New (default) - This maintains the existing behaviour where all new messages in the channel show a blue dot on the icon - Direct Messages and Mentions - Only show the green dot on the icon when you are directly messaged or mentioned, the blue dot is never shown - Never - Never show any dot on the chat icon, for those who want tractor-beam-laser-focus
60 lines
1.7 KiB
Ruby
60 lines
1.7 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
RSpec.describe "User chat preferences", type: :system, js: true do
|
|
fab!(:current_user) { Fabricate(:user) }
|
|
|
|
let(:chat) { PageObjects::Pages::Chat.new }
|
|
|
|
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 "shows a not found page" do
|
|
visit("/u/#{current_user.username}/preferences/chat")
|
|
|
|
expect(page).to have_content(I18n.t("page_not_found.title"))
|
|
end
|
|
end
|
|
|
|
it "can select chat sound" do
|
|
visit("/u/#{current_user.username}/preferences/chat")
|
|
find("#user_chat_sounds .select-kit-header[data-value]").click
|
|
find("[data-value='bell']").click
|
|
find(".save-changes").click
|
|
|
|
expect(page).to have_css("#user_chat_sounds .select-kit-header[data-value='bell']")
|
|
end
|
|
|
|
it "can select header_indicator_preference" do
|
|
visit("/u/#{current_user.username}/preferences/chat")
|
|
find("#user_chat_header_indicator_preference .select-kit-header[data-value]").click
|
|
find("[data-value='dm_and_mentions']").click
|
|
find(".save-changes").click
|
|
|
|
expect(page).to have_css(
|
|
"#user_chat_header_indicator_preference .select-kit-header[data-value='dm_and_mentions']",
|
|
)
|
|
end
|
|
|
|
context "as an admin on another user's preferences" do
|
|
fab!(:current_user) { Fabricate(:admin) }
|
|
fab!(:user_1) { Fabricate(:user) }
|
|
|
|
before { sign_in(current_user) }
|
|
|
|
it "allows to change settings" do
|
|
visit("/u/#{user_1.username}/preferences")
|
|
find(".preferences-chat-link").click
|
|
|
|
expect(page).to have_current_path("/u/#{user_1.username}/preferences/chat")
|
|
end
|
|
end
|
|
end
|