discourse/spec/system/page_objects/components/sidebar_header_dropdown.rb
Régis Hanol bc53187cfb
FEATURE: add "New category" action to sidebar for admins (#37082)
Admins now see a dropdown in the categories section header with:
- "New category" - navigates to /new-category
- "Edit sidebar categories" (or "Edit nav categories" in header dropdown
mode)

Non-admins continue to see the single pencil button for editing their
sidebar categories.

Ref - t/172219

**Regular user - pencil**
<img width="1667" height="1339" alt="2026-01-13 @ 11 56 54"
src="https://github.com/user-attachments/assets/4bc5df87-98eb-45f2-8c23-b5db1b2c27ed"
/>

**Admin - three dots (sidebar)**
<img width="1667" height="1339" alt="2026-01-13 @ 11 56 10"
src="https://github.com/user-attachments/assets/0983dbce-233d-47a4-8c68-ecd256242533"
/>

**Admin - three dots (header dropdown)**
<img width="1667" height="1339" alt="2026-01-13 @ 11 55 58"
src="https://github.com/user-attachments/assets/19ae1263-d956-4a8f-9b07-2b1dfd78889e"
/>
2026-01-14 10:47:32 +01:00

47 lines
1.2 KiB
Ruby

# frozen_string_literal: true
module PageObjects
module Components
class SidebarHeaderDropdown < PageObjects::Components::Base
def click
page.find(".hamburger-dropdown").click
wait_for_animation(find(".menu-panel"), timeout: 5)
self
end
SIDEBAR_HAMBURGER_DROPDOWN = ".sidebar-hamburger-dropdown"
def visible?
page.has_css?(SIDEBAR_HAMBURGER_DROPDOWN)
end
def hidden?
page.has_no_css?(SIDEBAR_HAMBURGER_DROPDOWN)
end
def has_no_keyboard_shortcuts_button?
page.has_no_css?(".sidebar-footer-actions-keyboard-shortcuts")
end
def click_categories_header_button
page.find("[data-section-name='categories'] .sidebar-section-header-button").click
end
def click_topics_link
find(".sidebar-section-link[data-link-name='everything']").click
end
def click_toggle_to_desktop_view_button
page.click_button(
I18n.t("js.desktop_view"),
class: "sidebar-footer-actions-toggle-mobile-view",
)
end
def click_outside
width = page.evaluate_script("document.body.clientWidth")
page.find("body").click(x: width - 1, y: 1)
end
end
end
end