Skip to content

A platform for community discussion. Free, open, simple.

1.3 KB
Raw Blame
# 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_edit_categories_dropdown_option
        find("[data-section-name='categories'] .sidebar-section-header-dropdown").click
        find(
          ".sidebar-section-header-dropdown-menu-content [data-menu-option-id='edit-categories']",
        ).click
      end

      def click_outside
        width = page.evaluate_script("document.body.clientWidth")
        page.find("body").click(x: width - 1, y: 1)
      end
    end
  end
end