mirror of
https://github.com/discourse/discourse.git
synced 2026-08-09 21:45:25 +08:00
Follow up to https://github.com/discourse/discourse/pull/41586 1. **Bulk of the PR diff** -- there's a mix of usages for "description" and "caption", we'll stick to V1 terminology and keep "AI caption" instead of bringing in "description". 2. Move image caption out of AI helper, into its own dedicated "AI Feature" for consolidated settings 3. Update default values for the existing image caption agent - vision_enabled was default off, now on - update description 4. Validations and problem checks - via Site Setting validation - agent / llm - when enabling the feature - or when selecting invalid agent - inform admin when they've enabled the setting but the agent is misconfigured via ProblemCheck
36 lines
1.3 KiB
JavaScript
Vendored
36 lines
1.3 KiB
JavaScript
Vendored
import { module, test } from "qunit";
|
|
import { imageBase62Sha1 } from "discourse/plugins/discourse-ai/discourse/lib/post-image-caption-editor";
|
|
|
|
module("Unit | Lib | post-image-caption-editor", function () {
|
|
test("imageBase62Sha1 reads data-base62-sha1", function (assert) {
|
|
const image = document.createElement("img");
|
|
image.dataset.base62Sha1 = "abc123XYZ";
|
|
|
|
assert.strictEqual(imageBase62Sha1(image), "abc123XYZ");
|
|
});
|
|
|
|
test("imageBase62Sha1 falls back to upload short URLs", function (assert) {
|
|
const image = document.createElement("img");
|
|
image.setAttribute("data-orig-src", "upload://abc123XYZ.png");
|
|
|
|
assert.strictEqual(imageBase62Sha1(image), "abc123XYZ");
|
|
});
|
|
|
|
test("imageBase62Sha1 falls back to resolved upload URLs", function (assert) {
|
|
const image = document.createElement("img");
|
|
image.setAttribute(
|
|
"src",
|
|
"/uploads/default/original/1X/0049585045f353bed81bb257092d58b968539ff6.jpeg"
|
|
);
|
|
|
|
assert.strictEqual(imageBase62Sha1(image), "2x8JyApqlboI0dAsfwbPbZ7Ho2");
|
|
});
|
|
|
|
test("imageBase62Sha1 ignores invalid values", function (assert) {
|
|
const image = document.createElement("img");
|
|
image.dataset.base62Sha1 = "../bad";
|
|
image.dataset.origSrc = "https://example.com/image.png";
|
|
|
|
assert.strictEqual(imageBase62Sha1(image), undefined);
|
|
});
|
|
});
|