import { describe, expect, it } from "vitest"; import { AnalyzeVideoInputSchema, SILENCE_DEFAULTS } from "./media-analysis.js"; import { EditVideoInputSchema } from "./media-video.js"; const edit = (steps: unknown[]) => EditVideoInputSchema.safeParse({ artifact_id: "a", title: "Reel", steps }); describe("remove_silence step", () => { it("fills its defaults and parses again unchanged", () => { const parsed = EditVideoInputSchema.parse({ artifact_id: "a", title: "Reel", steps: [ { op: "trim", start: 0, end: 30 }, { op: "remove_silence", padding: 0 }, ], }); expect(parsed.steps[1]).toEqual({ op: "remove_silence", threshold_db: SILENCE_DEFAULTS.thresholdDb, min_silence: SILENCE_DEFAULTS.minSilence, padding: 0, }); expect(EditVideoInputSchema.parse(parsed)).toEqual(parsed); }); it("keeps its settings in a useful range", () => { expect(edit([{ op: "remove_silence", threshold_db: -61 }]).success).toBe(false); expect(edit([{ op: "remove_silence", threshold_db: -5 }]).success).toBe(false); expect(edit([{ op: "remove_silence", min_silence: 0.1 }]).success).toBe(false); expect(edit([{ op: "remove_silence", min_silence: 6 }]).success).toBe(false); expect(edit([{ op: "remove_silence", padding: -0.1 }]).success).toBe(false); expect(edit([{ op: "remove_silence", padding: 1.5 }]).success).toBe(false); expect( edit([{ op: "remove_silence", threshold_db: -60, min_silence: 5, padding: 1 }]).success, ).toBe(true); }); }); describe("analyze_video input", () => { it("analyzes everything by default and needs a title for the card", () => { expect(AnalyzeVideoInputSchema.parse({ artifact_id: "a", title: " Cuts " })).toEqual({ artifact_id: "a", scenes: true, silences: true, loudness: true, title: "Cuts", }); expect(AnalyzeVideoInputSchema.safeParse({ artifact_id: "a" }).success).toBe(false); }); });