18 changed files with 536 additions and 90 deletions
@ -0,0 +1,90 @@ |
|||
import { beforeEach, describe, expect, it, vi } from "vitest"; |
|||
import { runBatchIfApplicable } from "../batchExecution"; |
|||
import { executeGenerateVideo } from "../generateVideoExecutor"; |
|||
import type { NodeExecutionContext } from "../types"; |
|||
import type { WorkflowNode } from "@/types"; |
|||
|
|||
vi.mock("../nanoBananaExecutor", () => ({ |
|||
executeNanoBanana: vi.fn(), |
|||
})); |
|||
|
|||
vi.mock("../generateVideoExecutor", () => ({ |
|||
executeGenerateVideo: vi.fn(), |
|||
})); |
|||
|
|||
vi.mock("../generateAudioExecutor", () => ({ |
|||
executeGenerateAudio: vi.fn(), |
|||
})); |
|||
|
|||
vi.mock("../llmGenerateExecutor", () => ({ |
|||
executeLlmGenerate: vi.fn(), |
|||
})); |
|||
|
|||
function makeCtx(node: WorkflowNode): NodeExecutionContext { |
|||
return { |
|||
node, |
|||
getConnectedInputs: vi.fn().mockReturnValue({ |
|||
images: [], |
|||
videos: ["https://example.com/source.mp4"], |
|||
audio: [], |
|||
model3d: null, |
|||
text: null, |
|||
textItems: [], |
|||
batchTextItems: ["one", "two"], |
|||
dynamicInputs: {}, |
|||
easeCurve: null, |
|||
}), |
|||
updateNodeData: vi.fn(), |
|||
updateMediaNodeData: vi.fn(), |
|||
getFreshNode: vi.fn().mockReturnValue(node), |
|||
getEdges: vi.fn().mockReturnValue([]), |
|||
getNodes: vi.fn().mockReturnValue([]), |
|||
providerSettings: {} as any, |
|||
addIncurredCost: vi.fn(), |
|||
appendOutputGalleryImage: vi.fn(), |
|||
get: vi.fn(), |
|||
}; |
|||
} |
|||
|
|||
describe("runBatchIfApplicable", () => { |
|||
beforeEach(() => { |
|||
vi.clearAllMocks(); |
|||
}); |
|||
|
|||
it("does not batch video auto task nodes", async () => { |
|||
const node = { |
|||
id: "video-crop-1", |
|||
type: "smartVideo", |
|||
position: { x: 0, y: 0 }, |
|||
data: { |
|||
derivedVideo: { |
|||
sourceNodeId: "video-source-1", |
|||
operation: "crop", |
|||
}, |
|||
}, |
|||
} as WorkflowNode; |
|||
|
|||
await expect(runBatchIfApplicable(makeCtx(node), { useStoredFallback: true })).resolves.toBe(false); |
|||
expect(executeGenerateVideo).not.toHaveBeenCalled(); |
|||
}); |
|||
|
|||
it("does not batch captured video frame smart image nodes", async () => { |
|||
const node = { |
|||
id: "video-frame-1", |
|||
type: "smartImage", |
|||
position: { x: 0, y: 0 }, |
|||
data: { |
|||
derivedMedia: { |
|||
sourceNodeId: "video-source-1", |
|||
operation: "videoFrame", |
|||
task: { |
|||
time: 1.25, |
|||
mode: "current", |
|||
}, |
|||
}, |
|||
}, |
|||
} as WorkflowNode; |
|||
|
|||
await expect(runBatchIfApplicable(makeCtx(node), { useStoredFallback: true })).resolves.toBe(false); |
|||
}); |
|||
}); |
|||
Loading…
Reference in new issue