0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-11 02:59:07 +08:00
discourse/plugins/discourse-ai/test/javascripts/integration/components/ai-regen-summaries-buttons-test.gjs
Sam 41773777e4
FEATURE: Add locale-aware AI summaries (#41893)
Store summaries by locale so topics can serve and regenerate the
appropriate localized version. Generate gists for source and translated
locales, and make backfills handle each locale independently.
2026-07-22 17:31:38 +10:00

52 lines
1.6 KiB
Text
Vendored

import Service from "@ember/service";
import { click, render } from "@ember/test-helpers";
import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import pretender, { response } from "discourse/tests/helpers/create-pretender";
import AiRegenSummariesButtons from "discourse/plugins/discourse-ai/discourse/components/ai-regen-summaries-buttons";
class ToastsStub extends Service {
messages = [];
success({ data }) {
this.messages.push(data.message);
}
error() {}
}
module("Integration | Component | AiRegenSummariesButtons", function (hooks) {
setupRenderingTest(hooks);
hooks.beforeEach(function () {
this.owner.unregister("service:toasts");
this.owner.register("service:toasts", ToastsStub);
this.currentUser.can_request_gists = true;
this.topicIds = [1];
pretender.put("/discourse-ai/summarization/regen_gist", () =>
response({ success: "OK" })
);
pretender.put("/discourse-ai/summarization/regen_summary", () =>
response({ success: "OK" })
);
});
test("reports regeneration as in progress after jobs are queued", async function (assert) {
await render(
<template>
<AiRegenSummariesButtons @topicIds={{this.topicIds}} />
</template>
);
await click(".ai-regen-gists-btn");
await click(".ai-regen-summaries-btn");
const toasts = this.owner.lookup("service:toasts");
assert.deepEqual(
toasts.messages,
["Regenerating short summaries…", "Regenerating topic summaries…"],
"the toasts describe queued asynchronous work"
);
});
});