Merge remote-tracking branch 'origin/pr-573' into codex/pr-557-589-security-integration

This commit is contained in:
ddCat
2026-09-22 11:02:04 +08:00
6 changed files with 111 additions and 15 deletions

View File

@@ -53,6 +53,16 @@ describe("creation library button", () => {
expect(source).toContain("个素材已上传到素材库并自动选中");
});
test("视频创作使用同名模型组的全部参考能力开放素材入口", () => {
const source = readCreateSource();
const workspace = readCreateWorkspaceSource();
expect(source).toContain('modelGroupReferenceLimits(config, preferredModel || selectedModel, "video")');
expect(source).toContain("reconcileCreationAttachmentLimits(attachments, mentionReferences, videoReferenceLimits)");
expect(workspace).toContain('props.mode !== "video" || props.maxReferences > 0');
expect(workspace).not.toContain('props.videoProfile.operations.includes("image_to_video")');
});
test("previews prompt reference images without removing them", () => {
const createSource = readCreateWorkspaceSource();
const canvasSource = readFileSync(resolve(import.meta.dir, "../src/components/canvas/canvas-node-prompt-panel.tsx"), "utf8");

View File

@@ -2,7 +2,15 @@ import { describe, expect, test } from "bun:test";
import { canvasResourceMentionToken } from "../src/lib/canvas/canvas-resource-references";
import { creationAttachmentKind, creationFileAccepted, creationMediaAspectRatio, creationUploadAccept, type CreationAttachment } from "../src/pages/create/creation-assets";
import { buildCreationMentionReferences, displayCreationPrompt, reconcileCreationAttachmentLimit, removeCreationReferenceTokens, replaceCreationAttachmentReference, selectedCreationReferences } from "../src/pages/create/creation-references";
import {
buildCreationMentionReferences,
displayCreationPrompt,
reconcileCreationAttachmentLimit,
reconcileCreationAttachmentLimits,
removeCreationReferenceTokens,
replaceCreationAttachmentReference,
selectedCreationReferences,
} from "../src/pages/create/creation-references";
function imageAttachment(id: string): CreationAttachment {
return {
@@ -14,6 +22,10 @@ function imageAttachment(id: string): CreationAttachment {
};
}
function mediaAttachment(id: string, type: string): CreationAttachment {
return { id, name: id, type, url: `blob:${id}`, storageKey: `${id}:key`, previewUrl: "" };
}
describe("creation references", () => {
test("removes attachments and prompt tokens beyond the current model limit", () => {
const attachments = [imageAttachment("first"), imageAttachment("second"), imageAttachment("third")];
@@ -37,6 +49,23 @@ describe("creation references", () => {
expect(result.removedReferences).toEqual([]);
});
test("视频参考内容分别遵守图片、视频和音频上限", () => {
const attachments = [imageAttachment("image-1"), mediaAttachment("video-1", "video/mp4"), imageAttachment("image-2"), mediaAttachment("audio-1", "audio/mpeg"), mediaAttachment("video-2", "video/mp4")];
const references = buildCreationMentionReferences([], attachments);
const result = reconcileCreationAttachmentLimits(attachments, references, { maxImages: 1, maxVideos: 2, maxAudios: 0 });
expect(result.attachments.map((attachment) => attachment.id)).toEqual(["image-1", "video-1", "video-2"]);
expect(result.removedReferences.map((reference) => reference.attachmentId)).toEqual(["image-2", "audio-1"]);
});
test("视频参考内容在各类型均未超限时保留原数组", () => {
const attachments = [imageAttachment("image"), mediaAttachment("video", "video/mp4"), mediaAttachment("audio", "audio/mpeg")];
const result = reconcileCreationAttachmentLimits(attachments, buildCreationMentionReferences([], attachments), { maxImages: 1, maxVideos: 1, maxAudios: 1 });
expect(result.attachments).toBe(attachments);
expect(result.removedReferences).toEqual([]);
});
test("文本创作允许媒体和常用文档,图片创作仍只接受图片", () => {
expect(creationFileAccepted("text", { name: "story.pdf", type: "application/pdf" })).toBe(true);
expect(creationFileAccepted("text", { name: "clip.mp4", type: "video/mp4" })).toBe(true);