mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: configurable public sidebar sections (#20303)
Extension of https://github.com/discourse/discourse/pull/20057 Admin can create a public session visible to everyone. An additional checkbox is displayed for staff members.
This commit is contained in:
committed by
GitHub
parent
e3ee81aa3c
commit
b9d037770c
@@ -2,6 +2,7 @@
|
||||
|
||||
describe "Custom sidebar sections", type: :system, js: true do
|
||||
fab!(:user) { Fabricate(:user) }
|
||||
fab!(:admin) { Fabricate(:admin) }
|
||||
let(:section_modal) { PageObjects::Modals::SidebarSectionForm.new }
|
||||
let(:sidebar) { PageObjects::Components::Sidebar.new }
|
||||
|
||||
@@ -9,6 +10,7 @@ describe "Custom sidebar sections", type: :system, js: true do
|
||||
### TODO remove when enable_custom_sidebar_sections SiteSetting is removed
|
||||
group = Fabricate(:group)
|
||||
Fabricate(:group_user, group: group, user: user)
|
||||
Fabricate(:group_user, group: group, user: admin)
|
||||
SiteSetting.enable_custom_sidebar_sections = group.id.to_s
|
||||
sign_in user
|
||||
end
|
||||
@@ -55,6 +57,23 @@ describe "Custom sidebar sections", type: :system, js: true do
|
||||
expect(page).not_to have_link("Sidebar Categories")
|
||||
end
|
||||
|
||||
it "does not allow the user to edit public section" do
|
||||
sidebar_section = Fabricate(:sidebar_section, title: "Public section", user: user, public: true)
|
||||
sidebar_url_1 = Fabricate(:sidebar_url, name: "Sidebar Tags", value: "/tags")
|
||||
Fabricate(:sidebar_section_link, sidebar_section: sidebar_section, linkable: sidebar_url_1)
|
||||
sidebar_url_2 = Fabricate(:sidebar_url, name: "Sidebar Categories", value: "/categories")
|
||||
Fabricate(:sidebar_section_link, sidebar_section: sidebar_section, linkable: sidebar_url_2)
|
||||
|
||||
visit("/latest")
|
||||
|
||||
expect(page).to have_button("Public section")
|
||||
find(".sidebar-section-public-section").hover
|
||||
expect(page).not_to have_css(
|
||||
".sidebar-section-public-section button.sidebar-section-header-button",
|
||||
)
|
||||
expect(page).not_to have_css(".sidebar-section-public-section .d-icon-globe")
|
||||
end
|
||||
|
||||
it "allows the user to delete custom section" do
|
||||
sidebar_section = Fabricate(:sidebar_section, title: "My section", user: user)
|
||||
sidebar_url_1 = Fabricate(:sidebar_url, name: "tags", value: "/tags")
|
||||
@@ -69,4 +88,31 @@ describe "Custom sidebar sections", type: :system, js: true do
|
||||
|
||||
expect(page).not_to have_button("My section")
|
||||
end
|
||||
|
||||
it "allows admin to create, edit and delete public section" do
|
||||
sign_in admin
|
||||
visit("/latest")
|
||||
sidebar.open_new_custom_section
|
||||
|
||||
section_modal.fill_name("Public section")
|
||||
section_modal.fill_link("Sidebar Tags", "/tags")
|
||||
section_modal.mark_as_public
|
||||
section_modal.save
|
||||
|
||||
expect(page).to have_button("Public section")
|
||||
expect(page).to have_link("Sidebar Tags")
|
||||
expect(page).to have_css(".sidebar-section-public-section .d-icon-globe")
|
||||
|
||||
sidebar.edit_custom_section("Public section")
|
||||
section_modal.fill_name("Edited public section")
|
||||
section_modal.save
|
||||
|
||||
expect(page).to have_button("Edited public section")
|
||||
|
||||
sidebar.edit_custom_section("Edited public section")
|
||||
section_modal.delete
|
||||
section_modal.confirm_delete
|
||||
|
||||
expect(page).not_to have_button("Edited public section")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -12,6 +12,10 @@ module PageObjects
|
||||
fill_in "link-url", with: url, match: :first
|
||||
end
|
||||
|
||||
def mark_as_public
|
||||
find(".modal .mark-public").click
|
||||
end
|
||||
|
||||
def remove_last_link
|
||||
all(".delete-link").last.click
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user