feat(canvas): 图片编辑 - 合并打光预设与镜头参数控制

This commit is contained in:
ddCat
2026-09-09 22:55:19 +08:00
24 changed files with 1634 additions and 19 deletions

View File

@@ -0,0 +1,31 @@
import { describe, expect, test } from "bun:test";
import { APERTURES, CAMERA_PROFILES, FOCAL_LENGTHS, LENS_PROFILES, buildCameraPrompt } from "../src/lib/canvas/camera-prompt-library";
describe("camera prompt contract", () => {
test("builds a deterministic prompt from registered camera parameters", () => {
const prompt = buildCameraPrompt({
cameraId: CAMERA_PROFILES[0].id,
lensId: LENS_PROFILES[0].id,
focalLengthMm: FOCAL_LENGTHS[0],
apertureF: APERTURES[0],
});
expect(prompt).toContain(CAMERA_PROFILES[0].shortTag);
expect(prompt).toContain(LENS_PROFILES[0].shortTag);
});
test("rejects unknown persisted parameters instead of silently changing generation semantics", () => {
const valid = {
cameraId: CAMERA_PROFILES[0].id,
lensId: LENS_PROFILES[0].id,
focalLengthMm: FOCAL_LENGTHS[0],
apertureF: APERTURES[0],
};
expect(() => buildCameraPrompt({ ...valid, cameraId: "unknown-camera" })).toThrow("不支持的相机配置");
expect(() => buildCameraPrompt({ ...valid, lensId: "unknown-lens" })).toThrow("不支持的镜头配置");
expect(() => buildCameraPrompt({ ...valid, focalLengthMm: 47 })).toThrow("不支持的焦距");
expect(() => buildCameraPrompt({ ...valid, apertureF: 3.2 })).toThrow("不支持的光圈");
});
});