0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-06 13:08:40 +08:00
discourse/spec/system/admin_dashboard_redesign_spec.rb
Alan Guo Xiang Tan 5f144bd39c
UX: Return dashboard report views to dashboard (#41318)
This PR lets admins return from dashboard-launched report detail pages
to the same dashboard URL they came from.

Previously, report detail pages always showed "Back to all reports",
even when the admin opened the report from the redesigned dashboard.
That sent dashboard users to the reports index and discarded the
dashboard query state they were reviewing.

Key changes:
* Detect dashboard-origin report views from the incoming route
transition, and capture the dashboard's query params (date range and
version) so the back link restores the exact dashboard state.
* Keep the dashboard back link stable while admins interact with filters
on the report page.
* Show a contextual "Back to dashboard" link only for dashboard-origin
report views, and keep the existing "Back to all reports" fallback for
direct report views.
2026-07-02 09:39:11 +08:00

64 lines
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 }
let(:dashboard_reports) { PageObjects::Pages::AdminDashboardReports.new }
let(:admin_report) { PageObjects::Pages::AdminReport.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
it "lets admins return to the dashboard after viewing a report" do
admin_report.visit_default_dashboard_report
expect(admin_report).to have_back_to_all_reports
expect(admin_report).to have_no_back_to_dashboard
admin_report.go_back
expect(admin_report).to have_current_all_reports_path
dashboard.visit_with_custom_range(from: "2026-01-01", to: "2026-01-31")
expect(dashboard_reports).to have_default_report
dashboard_reports.open_default_report
expect(admin_report).to have_back_to_dashboard
expect(admin_report).to have_no_back_to_all_reports
admin_report.go_back
expect(dashboard).to have_custom_range(from: "2026-01-01", to: "2026-01-31")
end
end