2025-04-10 08:16:31 -07:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2025-06-20 23:49:44 +02:00
|
|
|
RSpec.describe "Admin AI features configuration", type: :system do
|
2025-04-10 08:16:31 -07:00
|
|
|
fab!(:admin)
|
|
|
|
fab!(:llm_model)
|
|
|
|
fab!(:summarization_persona) { Fabricate(:ai_persona) }
|
|
|
|
fab!(:group_1) { Fabricate(:group) }
|
|
|
|
fab!(:group_2) { Fabricate(:group) }
|
|
|
|
let(:page_header) { PageObjects::Components::DPageHeader.new }
|
|
|
|
let(:form) { PageObjects::Components::FormKit.new("form") }
|
|
|
|
let(:ai_features_page) { PageObjects::Pages::AdminAiFeatures.new }
|
|
|
|
|
|
|
|
before do
|
|
|
|
summarization_persona.allowed_group_ids = [group_1.id, group_2.id]
|
|
|
|
summarization_persona.save!
|
|
|
|
assign_fake_provider_to(:ai_summarization_model)
|
|
|
|
SiteSetting.ai_summarization_enabled = true
|
|
|
|
SiteSetting.ai_summarization_persona = summarization_persona.id
|
|
|
|
sign_in(admin)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "lists all persona backed AI features separated by configured/unconfigured" do
|
|
|
|
ai_features_page.visit
|
2025-06-09 16:13:09 -03:00
|
|
|
ai_features_page.toggle_configured
|
|
|
|
|
|
|
|
expect(ai_features_page).to have_listed_modules(1)
|
|
|
|
|
|
|
|
ai_features_page.toggle_unconfigured
|
|
|
|
|
2025-06-13 10:17:27 +08:00
|
|
|
expect(ai_features_page).to have_listed_modules(5)
|
2025-04-10 08:16:31 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
it "lists the persona used for the corresponding AI feature" do
|
|
|
|
ai_features_page.visit
|
2025-06-09 16:13:09 -03:00
|
|
|
|
|
|
|
ai_features_page.toggle_configured
|
|
|
|
|
|
|
|
expect(ai_features_page).to have_feature_persona("topic_summaries", summarization_persona.name)
|
2025-04-10 08:16:31 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
it "lists the groups allowed to use the AI feature" do
|
|
|
|
ai_features_page.visit
|
|
|
|
|
2025-06-09 16:13:09 -03:00
|
|
|
ai_features_page.toggle_configured
|
|
|
|
|
|
|
|
expect(ai_features_page).to have_feature_groups("topic_summaries", [group_1.name, group_2.name])
|
2025-04-10 08:16:31 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
it "shows edit page with settings" do
|
|
|
|
ai_features_page.visit
|
2025-06-09 16:13:09 -03:00
|
|
|
|
|
|
|
ai_features_page.click_edit_module("summarization")
|
|
|
|
|
2025-04-10 08:16:31 -07:00
|
|
|
expect(page).to have_current_path("/admin/plugins/discourse-ai/ai-features/1/edit")
|
|
|
|
|
|
|
|
expect(page).to have_css(".setting")
|
|
|
|
end
|
|
|
|
end
|