discourse/spec/system/page_objects/components/manage_reports_modal.rb
Osama Sayegh 0271308b66
FIX: Disable the last down-arrow in manage reports modal on mobile (#40540)
In the Manage reports modal, the mobile reorder controls left the
down-arrow on the last enabled report active, even though there was
nothing below it to swap with. Mirror the existing first-row up-arrow
behavior by disabling the down-arrow on the last enabled row.
2026-06-04 15:38:21 +03:00

106 lines
2.9 KiB
Ruby
Vendored

# frozen_string_literal: true
module PageObjects
module Components
class ManageReportsModal < PageObjects::Components::Base
MODAL = ".manage-reports"
ROW = ".manage-reports__row"
ENABLED_ROW = ".manage-reports__row.--enabled"
def has_open?
has_css?(MODAL)
end
def has_closed?
has_no_css?(MODAL)
end
def search(query)
find("#{MODAL} .manage-reports__search-wrapper .filter-input").set(query)
self
end
def enabled_identifiers
all("#{MODAL} #{ENABLED_ROW}").map { |el| el["data-identifier"] }
end
def has_all_row?(identifier)
has_css?("#{MODAL} #{ROW}[data-identifier='#{identifier}']")
end
def has_no_all_row?(identifier)
has_no_css?("#{MODAL} #{ROW}[data-identifier='#{identifier}']")
end
def toggle(identifier)
toggle_for(identifier).toggle
self
end
def has_toggle_on?(identifier)
has_css?("#{MODAL} #{ENABLED_ROW}[data-identifier='#{identifier}']")
end
def has_toggle_off?(identifier)
has_css?("#{MODAL} #{ROW}[data-identifier='#{identifier}']") &&
has_no_css?("#{MODAL} #{ENABLED_ROW}[data-identifier='#{identifier}']")
end
def toggle_for(identifier)
PageObjects::Components::DToggleSwitch.new(
"#{MODAL} #{ROW}[data-identifier='#{identifier}'] .d-toggle-switch__checkbox",
)
end
def apply
within(MODAL) { find(".manage-reports__apply").click }
self
end
def close
find("#{MODAL} .d-modal__header .modal-close").click
self
end
def has_disabled_move_up?(identifier)
has_css?(
"#{MODAL} #{ROW}[data-identifier='#{identifier}'] button.manage-reports__arrow[disabled] .d-icon-arrow-up",
)
end
def has_disabled_move_down?(identifier)
has_css?(
"#{MODAL} #{ROW}[data-identifier='#{identifier}'] button.manage-reports__arrow[disabled] .d-icon-arrow-down",
)
end
def has_enabled_move_up?(identifier)
has_css?(
"#{MODAL} #{ROW}[data-identifier='#{identifier}'] button.manage-reports__arrow:not([disabled]) .d-icon-arrow-up",
)
end
def has_enabled_move_down?(identifier)
has_css?(
"#{MODAL} #{ROW}[data-identifier='#{identifier}'] button.manage-reports__arrow:not([disabled]) .d-icon-arrow-down",
)
end
def has_drag_controls?
has_css?("#{MODAL} .manage-reports__list.--reorderable")
end
def has_no_drag_controls?
has_css?("#{MODAL} .manage-reports__list") &&
has_no_css?("#{MODAL} .manage-reports__list.--reorderable")
end
def has_counter?(count, max)
has_css?(
"#{MODAL} .manage-reports__counter",
text: I18n.t("admin_js.admin.dashboard.reports_section.modal.counter", count:, max:),
)
end
end
end
end