mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 05:50:14 +08:00
8938ecabc2
* FEATURE: Content custom summarization strategies. This PR establishes a pattern for plugins to register alternative ways of summarizing content by extending a class that defines an interface. Core controls which strategy we'll use and who has access to it through the `summarization_strategy` and `custom_summarization_allowed_groups`. It also defines the UI for summarizing topics. Other plugins can access this summarization mechanism and implement their features, removing cross-plugin customizations, as it currently happens between chat and the discourse-ai plugin. * Group membership validation and rate limiting * Work with objects instead of classes * Port summarization feature from discourse-ai to chat * Rename available summaries to 'Top Replies' and 'Summary'
30 lines
882 B
Ruby
30 lines
882 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 }
|
|
|
|
before do
|
|
sign_in(user)
|
|
strategy = DummyCustomSummarization.new("dummy")
|
|
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
|
|
|
|
expect(page.has_css?(".topic-summary-modal", wait: 5)).to eq(true)
|
|
|
|
expect(find(".summary-area").text).to eq(DummyCustomSummarization::RESPONSE)
|
|
end
|
|
end
|