discourse/plugins/discourse-ai/spec/lib/admin_dashboard_spec.rb
Natalie Tay 035ce20c43
FEATURE: AI highlights for new dashboard (#40740)
Adds an AI feature, agent, to discourse-ai.

This feature is meant to be used on the new admin dashboard, but is
owned by the discourse-ai plugin. The PR includes an outlet for
discourse-ai to hook up to.

The agent introduced will take crafted data in for now to formulate the
headline and we will adjust this accordingly.

Note, we're not doing any streaming here for now. The results are cached
for 6h and per locale.

The AI feature is "hidden" for now
2026-06-10 23:00:35 +08:00

38 lines
1.2 KiB
Ruby
Vendored

# frozen_string_literal: true
RSpec.describe DiscourseAi::AdminDashboard do
before do
enable_current_plugin
assign_fake_provider_to(:ai_default_llm_model)
SiteSetting.ai_admin_dashboard_highlights_agent = "-38"
AiAgent.where(id: -38).delete_all
end
it "reports whether admin dashboard AI is enabled" do
SiteSetting.ai_admin_dashboard_enabled = false
expect(described_class).not_to be_enabled
SiteSetting.ai_admin_dashboard_enabled = true
expect(described_class).to be_enabled
end
it "reports whether admin dashboard highlights are enabled" do
SiteSetting.ai_admin_dashboard_enabled = true
agent = Fabricate(:ai_agent, id: -38, enabled: true)
expect(described_class).to be_highlights_enabled
agent.update!(enabled: false)
expect(described_class).not_to be_highlights_enabled
end
it "returns the selected admin dashboard highlights agent instance" do
SiteSetting.ai_admin_dashboard_enabled = true
Fabricate(:ai_agent, id: -38, enabled: true)
expect(described_class.highlights_agent_id).to eq(-38)
expect(described_class.highlights_agent_instance).to be_a(
DiscourseAi::Agents::AdminDashboardHighlights,
)
end
end