新增优化案例领域模型

This commit is contained in:
czj
2026-07-08 13:08:12 +08:00
parent 8b10969c49
commit de539aecb0
6 changed files with 258 additions and 0 deletions
@@ -0,0 +1,55 @@
import { describe, expect, it } from "vitest";
import {
caseListFiltersSchema,
caseMetadataPatchSchema,
caseTypeSchema,
resultVersionStatusSchema,
} from "../validation";
describe("case validation", () => {
it("accepts the supported case types and result-version statuses", () => {
expect(caseTypeSchema.parse("article")).toBe("article");
expect(caseTypeSchema.parse("human_copy")).toBe("human_copy");
expect(resultVersionStatusSchema.parse("optimized")).toBe("optimized");
expect(resultVersionStatusSchema.parse("failed")).toBe("failed");
});
it("keeps optional ownership metadata empty and editable", () => {
expect(caseMetadataPatchSchema.parse({})).toEqual({});
expect(
caseMetadataPatchSchema.parse({
customer_name: "伟思德鲁",
brand_name: "IPMS",
project_tags: ["推荐榜单", "2026"],
notes: "客户偏好保留专业语气。",
}),
).toEqual({
customer_name: "伟思德鲁",
brand_name: "IPMS",
project_tags: ["推荐榜单", "2026"],
notes: "客户偏好保留专业语气。",
});
});
it("parses default list filters without archived cases", () => {
expect(caseListFiltersSchema.parse({})).toEqual({
include_archived: false,
});
expect(
caseListFiltersSchema.parse({
case_type: "human_copy",
status: "optimized",
project_tag: "朋友圈",
q: "自然表达",
include_archived: "true",
}),
).toMatchObject({
case_type: "human_copy",
status: "optimized",
project_tag: "朋友圈",
q: "自然表达",
include_archived: true,
});
});
});