|
4 | 4 | before do |
5 | 5 | assign_fake_provider_to(:ai_summarization_model) |
6 | 6 | SiteSetting.ai_summarization_enabled = true |
| 7 | + SiteSetting.ai_summarize_max_hot_topics_gists_per_batch = 100 |
7 | 8 | end |
8 | 9 |
|
9 | 10 | fab!(:user) |
10 | 11 |
|
11 | 12 | describe "#inject_into" do |
12 | 13 | describe "hot topics gist summarization" do |
13 | 14 | fab!(:topic_ai_gist) |
14 | | - fab!(:regular_summary) { Fabricate(:ai_summary, target: topic_ai_gist.target) } |
15 | 15 |
|
16 | 16 | before { TopicHotScore.create!(topic_id: topic_ai_gist.target_id, score: 1.0) } |
17 | 17 |
|
18 | 18 | let(:topic_query) { TopicQuery.new(user) } |
19 | 19 |
|
20 | 20 | describe "topic_query_create_list_topics modifier" do |
21 | 21 | context "when hot topic summarization is enabled" do |
22 | | - before { SiteSetting.ai_summarize_max_hot_topics_gists_per_batch = 100 } |
| 22 | + it "doesn't duplicate records when there more than one summary type" do |
| 23 | + Fabricate(:ai_summary, target: topic_ai_gist.target) |
23 | 24 |
|
24 | | - skip "preloads only gist summaries" do |
25 | | - gist_topic = topic_query.list_hot.topics.find { |t| t.id == topic_ai_gist.target_id } |
| 25 | + expect(topic_query.list_hot.topics.map(&:id)).to contain_exactly( |
| 26 | + topic_ai_gist.target_id, |
| 27 | + ) |
| 28 | + end |
26 | 29 |
|
27 | | - expect(gist_topic.ai_summaries.size).to eq(1) |
28 | | - expect(gist_topic.ai_summaries.first).to eq(topic_ai_gist) |
| 30 | + it "doesn't exclude records when the topic has a single different summary" do |
| 31 | + regular_summary_2 = Fabricate(:ai_summary) |
| 32 | + TopicHotScore.create!(topic_id: regular_summary_2.target_id, score: 1.0) |
| 33 | + |
| 34 | + expect(topic_query.list_hot.topics.map(&:id)).to contain_exactly( |
| 35 | + regular_summary_2.target_id, |
| 36 | + topic_ai_gist.target_id, |
| 37 | + ) |
29 | 38 | end |
30 | 39 |
|
31 | 40 | it "doesn't filter out hot topics without summaries" do |
|
118 | 127 | gist_topic, |
119 | 128 | scope: Guardian.new(admin), |
120 | 129 | root: false, |
121 | | - filter: :hot, |
| 130 | + filter: :unread, |
122 | 131 | ).as_json |
123 | 132 |
|
124 | 133 | expect(serialized[:ai_topic_gist]).to be_present |
125 | 134 | end |
| 135 | + |
| 136 | + it "doesn't include the summary if it's not a gist" do |
| 137 | + regular_summary_2 = Fabricate(:ai_summary) |
| 138 | + TopicHotScore.create!(topic_id: regular_summary_2.target_id, score: 1.0) |
| 139 | + |
| 140 | + hot_topic = topic_query.list_hot.topics.find { |t| t.id == regular_summary_2.target_id } |
| 141 | + |
| 142 | + serialized = |
| 143 | + TopicListItemSerializer.new( |
| 144 | + hot_topic, |
| 145 | + scope: Guardian.new(user), |
| 146 | + root: false, |
| 147 | + filter: :hot, |
| 148 | + ).as_json |
| 149 | + |
| 150 | + expect(serialized[:ai_topic_gist]).to be_nil |
| 151 | + end |
126 | 152 | end |
127 | 153 | end |
128 | 154 | end |
|
0 commit comments