mirror of
https://github.com/discourse/discourse.git
synced 2025-06-04 11:11:13 +08:00
DEV: Add more structure for admin plugin config nav (#26707)
* Simplify config nav link generation to always inject the Settings tab * Auto-redirect to the first non-settings config link (if there is one) when the user lands on /admin/plugins/:plugin_id * Add `extras` to admin plugin serializer so plugins can add more data on first load * Add PikadayCalendar page object for system specs, extracted from the CalendarDateTimePicker to make it more generic.
This commit is contained in:
@ -3,25 +3,17 @@
|
||||
module PageObjects
|
||||
module Components
|
||||
class CalendarDateTimePicker < PageObjects::Components::Base
|
||||
delegate :select_day, :select_year, to: :@pikaday_calendar
|
||||
|
||||
def initialize(context)
|
||||
@context = context
|
||||
@pikaday_calendar = PageObjects::Components::PikadayCalendar.new(context)
|
||||
end
|
||||
|
||||
def component
|
||||
find(@context)
|
||||
end
|
||||
|
||||
def select_day(day_number)
|
||||
component.find("button.pika-button.pika-day[data-pika-day='#{day_number}']").click
|
||||
end
|
||||
|
||||
def select_year(year)
|
||||
component
|
||||
.find(".pika-select-year", visible: false)
|
||||
.find("option[value='#{year}']")
|
||||
.select_option
|
||||
end
|
||||
|
||||
def fill_time(time)
|
||||
component.find(".time-picker").fill_in(with: time)
|
||||
end
|
||||
|
88
spec/system/page_objects/components/pikaday_calendar.rb
Normal file
88
spec/system/page_objects/components/pikaday_calendar.rb
Normal file
@ -0,0 +1,88 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module PageObjects
|
||||
module Components
|
||||
class PikadayCalendar < PageObjects::Components::Base
|
||||
attr_reader :context
|
||||
|
||||
def initialize(context)
|
||||
@context = context
|
||||
end
|
||||
|
||||
def component
|
||||
find(@context)
|
||||
end
|
||||
|
||||
def open_calendar
|
||||
component.click
|
||||
end
|
||||
|
||||
def visible_pikaday
|
||||
find(".pika-single:not(.is-hidden)")
|
||||
end
|
||||
|
||||
def hidden?
|
||||
page.has_no_css?(".pika-single:not(.is-hidden)")
|
||||
end
|
||||
|
||||
def select_date(year, month, day)
|
||||
open_calendar
|
||||
select_year(year)
|
||||
select_month(month)
|
||||
select_day(day)
|
||||
end
|
||||
|
||||
def select_day(day_number)
|
||||
find("button.pika-button.pika-day[data-pika-day='#{day_number}']:not(.is-disabled)").click
|
||||
end
|
||||
|
||||
# The month is 0-based. Month name can be provided too.
|
||||
def select_month(month)
|
||||
parsed_month =
|
||||
begin
|
||||
Integer(month)
|
||||
rescue StandardError
|
||||
nil
|
||||
end
|
||||
|
||||
if parsed_month.nil?
|
||||
parsed_month =
|
||||
{
|
||||
"january" => 0,
|
||||
"february" => 1,
|
||||
"march" => 2,
|
||||
"april" => 3,
|
||||
"may" => 4,
|
||||
"june" => 5,
|
||||
"july" => 6,
|
||||
"august" => 7,
|
||||
"september" => 8,
|
||||
"october" => 9,
|
||||
"november" => 10,
|
||||
"december" => 11,
|
||||
}[
|
||||
month.downcase
|
||||
]
|
||||
end
|
||||
|
||||
# visible: false is here because pikaday sets the controls
|
||||
# to opacity: 0 for some reason.
|
||||
visible_pikaday
|
||||
.find(".pika-select-month", visible: false)
|
||||
.click
|
||||
.find("option[value='#{parsed_month}']")
|
||||
.click
|
||||
end
|
||||
|
||||
def select_year(year)
|
||||
# visible: false is here because pikaday sets the controls
|
||||
# to opacity: 0 for some reason.
|
||||
visible_pikaday
|
||||
.find(".pika-select-year", visible: false)
|
||||
.click
|
||||
.find("option[value='#{year}']")
|
||||
.click
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user