import { describe, expect, it } from "vitest"; import { BatchResetTasksSchema, CreateDiscoveryTaskSchema, GetDiscoveryTasksQuerySchema, ProjectInputSchema, } from "./validations"; describe("ProjectInputSchema", () => { const baseProjectInput = { name: "Agent Park", description: "A curated list of practical AI agent tools.", tags: [{ name: "ai-agent" }], links: [{ type: "GITHUB" as const, url: "https://github.com/example/repo" }], }; it("should allow more than 10 tags", () => { const manyTags = Array.from({ length: 20 }, (_, index) => ({ name: `tag-${index + 1}`, })); expect(() => ProjectInputSchema.parse({ ...baseProjectInput, tags: manyTags, }) ).not.toThrow(); }); it("should still require at least one tag", () => { expect(() => ProjectInputSchema.parse({ ...baseProjectInput, tags: [], }) ).toThrow(); }); it("should default discovery task sourceType to manual", () => { const parsed = CreateDiscoveryTaskSchema.parse({ apiKey: "k".repeat(32), tasks: [{ sourceUrl: "https://github.com/example/repo" }], }); expect(parsed.tasks[0]?.sourceType).toBe("manual"); }); it("should parse comma-separated discovery statuses", () => { const parsed = GetDiscoveryTasksQuerySchema.parse({ status: "PENDING,FAILED", limit: "20", offset: "5", }); expect(parsed.status).toEqual(["PENDING", "FAILED"]); expect(parsed.limit).toBe(20); expect(parsed.offset).toBe(5); }); it("should reject batch reset without taskIds or statuses", () => { expect(() => BatchResetTasksSchema.parse({ apiKey: "k".repeat(32), }) ).toThrow("必须提供 taskIds 或 statuses 之一"); }); });