discourse/spec/system/topic_summarization_spec.rb
Roman Rizzi 61aeb2da90
FEATURE: Inline topic summary. Cached version accessible to everyone. (#22551)
* FEATURE:  Inline topic summary. Cached version accessible to everyone.

Anons and non-members of the `custom_summarization_allowed_groups_map` groups can see cached summaries for any accessible topic. After the first 12 hours and if the posts to summarize have changed, allowed users clicking on the button will automatically re-generate it.

* Ensure chat summaries work and prevent model hallucinations when there are no messages.
2023-07-12 11:21:51 -03:00

33 lines
954 B
Ruby

# frozen_string_literal: true
RSpec.describe "Topic summarization", type: :system, js: true do
fab!(:user) { Fabricate(:admin) }
# has_summary to force topic map to be present.
fab!(:topic) { Fabricate(:topic, has_summary: true) }
fab!(:post_1) { Fabricate(:post, topic: topic) }
fab!(:post_2) { Fabricate(:post, topic: topic) }
let(:plugin) { Plugin::Instance.new }
let(:expected_summary) { "This is a summary" }
let(:summarization_result) { { summary: expected_summary, chunks: [] } }
before do
sign_in(user)
strategy = DummyCustomSummarization.new(summarization_result)
plugin.register_summarization_strategy(strategy)
SiteSetting.summarization_strategy = strategy.model
end
it "returns a summary using the selected timeframe" do
visit("/t/-/#{topic.id}")
find(".topic-strategy-summarization").click
summary = find(".summary-box p").text
expect(summary).to eq(expected_summary)
end
end