discourse/spec/system/admin_dashboard_redesign_spec.rb
Alan Guo Xiang Tan 9be3fabd40
UX: Anchor dashboard date range picker on the start month (#40395)
When the picker opened, its two-month view was anchored on the end of
the range, and for ranges spanning more than a month it showed the start
month and end month side by side as a non-consecutive pair. The calendar
did not read as a continuous timeline, and there was no quick way to
bring a specific endpoint's month into view.

This commit anchors the view on the start of the range so it always
shows two consecutive months, with the start month on the left and the
following month on the right. Focusing the start date input brings the
start month into the left panel, and focusing the end date input brings
the end month into the right panel, reusing the same view shift the
month navigation arrows already drive.

Also refactoring some AI induced slop introduced previously.
2026-06-02 07:18:33 +08:00

39 lines
1.2 KiB
Ruby
Vendored
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# frozen_string_literal: true
describe "Admin Dashboard Redesign" do
fab!(:current_user, :admin)
let(:dashboard) { PageObjects::Pages::AdminDashboard.new }
before do
SiteSetting.dashboard_improvements = true
sign_in(current_user)
end
it "allows a user to use a preset range or select a custom range",
time: Time.utc(2026, 5, 26, 12, 0, 0) do
dashboard.visit
expect(dashboard).to have_active_period("last_30_days")
dashboard.select_preset("last_7_days")
expect(page).to have_current_path("/admin?range=last_7_days")
expect(dashboard).to have_active_period("last_7_days")
picker = dashboard.open_custom_date_range
picker.pick_day("2026-05-01")
picker.pick_day("2026-05-20")
picker.apply
expect(dashboard).to have_active_period("custom")
expect(page).to have_current_path(
"/admin?end_date=2026-05-20&range=custom&start_date=2026-05-01",
)
expect(dashboard).to have_custom_label("May 1, 2026 May 20, 2026")
dashboard.select_preset("last_6_months")
expect(page).to have_current_path("/admin?range=last_6_months")
expect(dashboard).to have_active_period("last_6_months")
end
end