mirror of
https://github.com/discourse/discourse.git
synced 2026-08-11 05:25:16 -05:00
UX: Add custom section button should not be shown to anon users (#21651)
This commit is contained in:
@@ -7,9 +7,13 @@ describe "Custom sidebar sections", type: :system, js: true do
|
||||
let(:sidebar) { PageObjects::Components::Sidebar.new }
|
||||
|
||||
it "allows the user to create custom section" do
|
||||
visit("/latest")
|
||||
|
||||
expect(sidebar).to have_no_add_section_button
|
||||
|
||||
sign_in user
|
||||
visit("/latest")
|
||||
sidebar.open_new_custom_section
|
||||
sidebar.click_add_section_button
|
||||
|
||||
expect(section_modal).to be_visible
|
||||
expect(section_modal).to have_disabled_save
|
||||
@@ -29,7 +33,7 @@ describe "Custom sidebar sections", type: :system, js: true do
|
||||
it "allows the user to create custom section with /my link" do
|
||||
sign_in user
|
||||
visit("/latest")
|
||||
sidebar.open_new_custom_section
|
||||
sidebar.click_add_section_button
|
||||
|
||||
expect(section_modal).to be_visible
|
||||
expect(section_modal).to have_disabled_save
|
||||
@@ -49,7 +53,7 @@ describe "Custom sidebar sections", type: :system, js: true do
|
||||
it "allows the user to create custom section with external link" do
|
||||
sign_in user
|
||||
visit("/latest")
|
||||
sidebar.open_new_custom_section
|
||||
sidebar.click_add_section_button
|
||||
|
||||
expect(section_modal).to be_visible
|
||||
expect(section_modal).to have_disabled_save
|
||||
@@ -167,7 +171,7 @@ describe "Custom sidebar sections", type: :system, js: true do
|
||||
it "allows admin to create, edit and delete public section" do
|
||||
sign_in admin
|
||||
visit("/latest")
|
||||
sidebar.open_new_custom_section
|
||||
sidebar.click_add_section_button
|
||||
|
||||
section_modal.fill_name("Public section")
|
||||
section_modal.fill_link("Sidebar Tags", "/tags")
|
||||
@@ -207,7 +211,7 @@ describe "Custom sidebar sections", type: :system, js: true do
|
||||
it "validates custom section fields" do
|
||||
sign_in user
|
||||
visit("/latest")
|
||||
sidebar.open_new_custom_section
|
||||
sidebar.click_add_section_button
|
||||
|
||||
section_modal.fill_name("A" * (SidebarSection::MAX_TITLE_LENGTH + 1))
|
||||
section_modal.fill_link("B" * (SidebarUrl::MAX_NAME_LENGTH + 1), "/wrong-url")
|
||||
|
||||
@@ -15,8 +15,12 @@ module PageObjects
|
||||
page.has_link?(category.name, class: "sidebar-section-link")
|
||||
end
|
||||
|
||||
def open_new_custom_section
|
||||
find("button.add-section").click
|
||||
def click_add_section_button
|
||||
click_button(add_section_button_text)
|
||||
end
|
||||
|
||||
def has_no_add_section_button?
|
||||
page.has_no_button?(add_section_button_text)
|
||||
end
|
||||
|
||||
def edit_custom_section(name)
|
||||
@@ -68,6 +72,10 @@ module PageObjects
|
||||
attributes[:class] += "--active" if active
|
||||
page.public_send(present ? :has_link? : :has_no_link?, name, **attributes)
|
||||
end
|
||||
|
||||
def add_section_button_text
|
||||
I18n.t("js.sidebar.sections.custom.add")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user