fix: restore discovery task pipeline

This commit is contained in:
2026-04-22 14:20:54 +08:00
parent 804fd756e7
commit 79744667c6
10 changed files with 1426 additions and 20 deletions
+36 -2
View File
@@ -1,5 +1,10 @@
import { describe, it, expect } from "vitest";
import { ProjectInputSchema } from "./validations";
import { describe, expect, it } from "vitest";
import {
BatchResetTasksSchema,
CreateDiscoveryTaskSchema,
GetDiscoveryTasksQuerySchema,
ProjectInputSchema,
} from "./validations";
describe("ProjectInputSchema", () => {
const baseProjectInput = {
@@ -30,4 +35,33 @@ describe("ProjectInputSchema", () => {
})
).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 之一");
});
});