0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-07 13:19:19 +08:00
discourse/spec/lib/seed_data/admin_dashboard_sections_spec.rb
Alan Guo Xiang Tan d01a79a0da
FEATURE: Add Search section to the redesigned admin dashboard (#40779)
This PR adds a Search section to the redesigned admin dashboard. It
shows total search volume and a no-result rate for the selected date
range with prior-period deltas, a rule-based headline summarising the
period, the top 10 trending search terms, and the top 10 content gaps
(terms whose searches end without a click), badged "No match" or "Poor
match".
2026-06-11 12:25:10 +08:00

52 lines
1.4 KiB
Ruby
Vendored

# frozen_string_literal: true
require "seed_data/admin_dashboard_sections"
describe SeedData::AdminDashboardSections do
before { AdminDashboardSection.delete_all }
it "seeds every known section, visible, in canonical order" do
described_class.create
rows = AdminDashboardSection.order(:position).pluck(:section_id, :position, :visible)
expect(rows).to eq(
[
["highlights", 0, true],
["reports", 1, true],
["traffic", 2, true],
["engagement", 3, true],
["search", 4, true],
],
)
end
it "is idempotent and does not duplicate rows" do
described_class.create
described_class.create
expect(AdminDashboardSection.count).to eq(
AdminDashboardSectionConfiguration::KNOWN_SECTIONS.size,
)
end
it "preserves existing visibility and position" do
AdminDashboardSection.create!(section_id: "reports", position: 0, visible: false)
described_class.create
reports = AdminDashboardSection.find_by(section_id: "reports")
expect(reports).to have_attributes(position: 0, visible: false)
end
it "re-adds a missing known section at the end" do
described_class.create
AdminDashboardSection.where(section_id: "engagement").delete_all
described_class.create
expect(AdminDashboardSection.order(:position).last).to have_attributes(
section_id: "engagement",
visible: true,
)
end
end