mirror of
https://github.com/discourse/discourse-ai.git
synced 2025-07-08 23:32:45 +00:00
spec added
This commit is contained in:
parent
20701cb48a
commit
e94385927b
@ -6,6 +6,7 @@ RSpec.describe DiscourseAi::Summarization::Strategies::TopicSummary do
|
||||
fab!(:topic) { Fabricate(:topic, highest_post_number: 25) }
|
||||
fab!(:post_1) { Fabricate(:post, topic: topic, post_number: 1) }
|
||||
fab!(:post_2) { Fabricate(:post, topic: topic, post_number: 2) }
|
||||
fab!(:admin)
|
||||
|
||||
describe "#targets_data" do
|
||||
shared_examples "includes only public-visible topics" do
|
||||
@ -62,4 +63,54 @@ RSpec.describe DiscourseAi::Summarization::Strategies::TopicSummary do
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#summary_extension_prompt" do
|
||||
context "when ai_summary_consolidator_persona_id siteSetting is set" do
|
||||
it "returns a prompt with the correct text" do
|
||||
AiPersona.create!(
|
||||
name: "TestPersona",
|
||||
system_prompt: "test prompt",
|
||||
description: "test",
|
||||
allowed_group_ids: [Group::AUTO_GROUPS[:trust_level_0]],
|
||||
)
|
||||
personaClass =
|
||||
DiscourseAi::AiBot::Personas::Persona.find_by(user: admin, name: "TestPersona")
|
||||
SiteSetting.ai_summary_consolidator_persona_id = personaClass.id
|
||||
|
||||
expect(
|
||||
topic_summary
|
||||
.summary_extension_prompt(nil, [{ id: 1, poster: "test", text: "hello" }])
|
||||
.messages
|
||||
.first[
|
||||
:content
|
||||
],
|
||||
).to include("test prompt")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#first_summary_prompt" do
|
||||
context "when ai_summary_persona_id siteSetting is set" do
|
||||
it "returns a prompt with the correct text" do
|
||||
AiPersona.create!(
|
||||
name: "TestPersona",
|
||||
system_prompt: "test prompt",
|
||||
description: "test",
|
||||
allowed_group_ids: [Group::AUTO_GROUPS[:trust_level_0]],
|
||||
)
|
||||
personaClass =
|
||||
DiscourseAi::AiBot::Personas::Persona.find_by(user: admin, name: "TestPersona")
|
||||
SiteSetting.ai_summary_persona_id = personaClass.id
|
||||
|
||||
expect(
|
||||
topic_summary
|
||||
.first_summary_prompt([{ id: 1, poster: "test", text: "hello" }])
|
||||
.messages
|
||||
.first[
|
||||
:content
|
||||
],
|
||||
).to include("test prompt")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user