56 lines
1.6 KiB
TypeScript
56 lines
1.6 KiB
TypeScript
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,
|
|
});
|
|
});
|
|
});
|