mirror of
https://github.com/discourse/discourse.git
synced 2026-08-19 01:14:56 -05:00
FEATURE: enable_public_channels site setting (#22565)
`SiteSetting.enable_public_channels` allows site admin to decide if public channels are available at all. There's no distinction between admins or not as we expect admins to create private category channels if they want to limit usage.
This commit is contained in:
@@ -20,6 +20,15 @@ RSpec.describe "Browse page", type: :system do
|
||||
end
|
||||
end
|
||||
|
||||
context "when public channels are disabled" do
|
||||
before { SiteSetting.enable_public_channels = false }
|
||||
|
||||
it "redirects to homepage" do
|
||||
visit("/chat/browse") # no page object here as we actually don't load it
|
||||
expect(page).to have_current_path("/latest")
|
||||
end
|
||||
end
|
||||
|
||||
context "when user has chat enabled" do
|
||||
context "when visiting browse page" do
|
||||
it "defaults to open filer" do
|
||||
|
||||
@@ -20,6 +20,47 @@ RSpec.describe "New message", type: :system do
|
||||
expect(chat_page.message_creator).to be_opened
|
||||
end
|
||||
|
||||
context "when public channels are disabled" do
|
||||
fab!(:channel_1) { Fabricate(:chat_channel) }
|
||||
|
||||
before do
|
||||
SiteSetting.enable_public_channels = false
|
||||
channel_1.add(current_user)
|
||||
end
|
||||
|
||||
it "doesn’t list public channels" do
|
||||
visit("/")
|
||||
chat_page.open_new_message
|
||||
|
||||
expect(chat_page.message_creator).to be_not_listing(channel_1)
|
||||
end
|
||||
|
||||
it "has a correct placeholder" do
|
||||
visit("/")
|
||||
chat_page.open_new_message
|
||||
|
||||
expect(chat_page.message_creator.input["placeholder"]).to eq(
|
||||
I18n.t("js.chat.new_message_modal.default_user_search_placeholder"),
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context "when public channels are disabled and user can't create direct message" do
|
||||
fab!(:current_user) { Fabricate(:user) }
|
||||
|
||||
before do
|
||||
SiteSetting.enable_public_channels = false
|
||||
SiteSetting.direct_message_enabled_groups = Group::AUTO_GROUPS[:staff]
|
||||
end
|
||||
|
||||
it "doesn’t list public channels" do
|
||||
visit("/")
|
||||
chat_page.open_new_message(ensure_open: false)
|
||||
|
||||
expect(chat_page.message_creator).to be_closed
|
||||
end
|
||||
end
|
||||
|
||||
context "when the the content is not filtered" do
|
||||
fab!(:channel_1) { Fabricate(:chat_channel) }
|
||||
fab!(:channel_2) { Fabricate(:chat_channel) }
|
||||
|
||||
@@ -29,9 +29,9 @@ module PageObjects
|
||||
visit("/chat")
|
||||
end
|
||||
|
||||
def open_new_message
|
||||
def open_new_message(ensure_open: true)
|
||||
send_keys([PLATFORM_KEY_MODIFIER, "k"])
|
||||
find(".chat-modal-new-message")
|
||||
find(".chat-modal-new-message") if ensure_open
|
||||
end
|
||||
|
||||
def has_drawer?(channel_id: nil, expanded: true)
|
||||
|
||||
@@ -24,6 +24,10 @@ module PageObjects
|
||||
page.has_css?(SELECTOR)
|
||||
end
|
||||
|
||||
def closed?
|
||||
page.has_no_css?(SELECTOR)
|
||||
end
|
||||
|
||||
def enter_shortcut
|
||||
input.send_keys(:enter)
|
||||
end
|
||||
|
||||
@@ -3,19 +3,27 @@
|
||||
module PageObjects
|
||||
module Pages
|
||||
class Sidebar < PageObjects::Pages::Base
|
||||
PUBLIC_CHANNELS_SECTION_SELECTOR = ".sidebar-section[data-section-name='chat-channels']"
|
||||
DM_CHANNELS_SECTION_SELECTOR = ".sidebar-section[data-section-name='chat-dms']"
|
||||
|
||||
def has_no_public_channels_section?
|
||||
has_no_css?(PUBLIC_CHANNELS_SECTION_SELECTOR)
|
||||
end
|
||||
|
||||
def channels_section
|
||||
find(".sidebar-section[data-section-name='chat-channels']")
|
||||
find(PUBLIC_CHANNELS_SECTION_SELECTOR)
|
||||
end
|
||||
|
||||
def channels_section
|
||||
find(PUBLIC_CHANNELS_SECTION_SELECTOR)
|
||||
end
|
||||
|
||||
def dms_section
|
||||
find(".sidebar-section[data-section-name='chat-dms']")
|
||||
find(DM_CHANNELS_SECTION_SELECTOR)
|
||||
end
|
||||
|
||||
def open_browse
|
||||
find(
|
||||
".sidebar-section[data-section-name='chat-channels'] .sidebar-section-header-button",
|
||||
visible: false,
|
||||
).click
|
||||
channels_section.find(".sidebar-section-header-button", visible: false).click
|
||||
end
|
||||
|
||||
def open_channel(channel)
|
||||
|
||||
@@ -8,6 +8,7 @@ RSpec.describe "Navigation", type: :system do
|
||||
fab!(:category_channel) { Fabricate(:category_channel) }
|
||||
fab!(:category_channel_2) { Fabricate(:category_channel) }
|
||||
let(:chat_page) { PageObjects::Pages::Chat.new }
|
||||
let(:sidebar_page) { PageObjects::Pages::Sidebar.new }
|
||||
|
||||
before do
|
||||
chat_system_bootstrap(user, [category_channel, category_channel_2])
|
||||
@@ -40,6 +41,16 @@ RSpec.describe "Navigation", type: :system do
|
||||
expect(page).to have_no_css("#d-sidebar")
|
||||
end
|
||||
end
|
||||
|
||||
context "when public channels are disabled" do
|
||||
before { SiteSetting.enable_public_channels = false }
|
||||
|
||||
it "has public channels section" do
|
||||
visit("/")
|
||||
|
||||
expect(sidebar_page).to have_no_public_channels_section
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "when visiting on mobile" do
|
||||
|
||||
Reference in New Issue
Block a user