FIX: Clicking on summary links breaks summary (#759)

This commit is contained in:
Keegan George 2024-08-20 06:57:23 -07:00 committed by GitHub
parent bfe3b1c3b8
commit 4a40531143
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 36 additions and 3 deletions

View File

@ -69,8 +69,10 @@ export default class AiSummaryBox extends Component {
}
@bind
subscribe(unsubscribe) {
if (unsubscribe && this._channel) {
subscribe(unsubscribe, [topicId]) {
const sameTopicId = this.args.outletArgs.topic.id === topicId;
if (unsubscribe && this._channel && !sameTopicId) {
this.unsubscribe();
}
const channel = `/discourse-ai/summaries/topic/${this.args.outletArgs.topic.id}`;

View File

@ -37,7 +37,7 @@
}
}
&-box {
padding-bottom: 1rem;
padding-block: 1rem;
}
}
}

View File

@ -66,6 +66,37 @@ acceptance("Topic - Summary", function (needs) {
.dom(".ai-summary-box .summarized-on")
.exists("summary metadata exists");
});
test("clicking summary links", async function (assert) {
await visit("/t/-/1");
const partialSummary = "In this post,";
await publishToMessageBus("/discourse-ai/summaries/topic/1", {
done: false,
ai_topic_summary: { summarized_text: partialSummary },
});
await click(".ai-topic-summarization");
const finalSummaryCooked =
"In this post, <a href='/t/-/1/1'>bianca</a> said some stuff.";
const finalSummaryResult = "In this post, bianca said some stuff.";
await publishToMessageBus("/discourse-ai/summaries/topic/1", {
done: true,
ai_topic_summary: {
summarized_text: finalSummaryCooked,
summarized_on: "2023-01-01T04:00:00.000Z",
algorithm: "OpenAI GPT-4",
outdated: false,
new_posts_since_summary: false,
can_regenerate: true,
},
});
await click(".generated-summary a");
assert
.dom(".ai-summary-box .generated-summary p")
.hasText(finalSummaryResult, "Retains final summary after clicking link");
});
});
acceptance("Topic - Summary - Anon", function (needs) {