fix: restore discovery task pipeline
This commit is contained in:
@@ -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 之一");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user