|
|
|
@ -814,6 +814,65 @@ describe("GenerationComposer", () => { |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
it("sums connected video durations and rounds up for Seedance estimates", async () => { |
|
|
|
const fetchMock = vi.fn(async (input: RequestInfo | URL) => { |
|
|
|
const url = String(input); |
|
|
|
if (url.startsWith("/api/points/estimate")) { |
|
|
|
return new Response(JSON.stringify({ |
|
|
|
success: true, |
|
|
|
data: { |
|
|
|
estimated_points: 234, |
|
|
|
}, |
|
|
|
}), { status: 200 }); |
|
|
|
} |
|
|
|
if (url.startsWith("/api/models")) { |
|
|
|
return new Response(JSON.stringify({ success: true, models: [] }), { status: 200 }); |
|
|
|
} |
|
|
|
throw new Error(`Unexpected fetch: ${url}`); |
|
|
|
}); |
|
|
|
vi.stubGlobal("fetch", fetchMock); |
|
|
|
useWorkflowStore.setState({ |
|
|
|
nodes: [ |
|
|
|
videoNode("source-1", false, { |
|
|
|
outputVideo: "https://static.popi.art/source-1.mp4", |
|
|
|
durationSeconds: 2.2, |
|
|
|
}), |
|
|
|
videoNode("source-2", false, { |
|
|
|
outputVideo: "https://static.popi.art/source-2.mp4", |
|
|
|
outputDuration: 3.1, |
|
|
|
}), |
|
|
|
videoNode("vid-1", true, { |
|
|
|
durationSeconds: 5, |
|
|
|
resolution: "720p", |
|
|
|
selectedModel: { |
|
|
|
provider: "newapiwg", |
|
|
|
modelId: "doubao-seedance-2-0-260128", |
|
|
|
displayName: "doubao-seedance-2-0-260128", |
|
|
|
capabilities: ["text-to-video", "image-to-video"], |
|
|
|
}, |
|
|
|
}), |
|
|
|
], |
|
|
|
edges: [ |
|
|
|
videoEdge("source-1", "vid-1", 0), |
|
|
|
videoEdge("source-2", "vid-1", 1), |
|
|
|
], |
|
|
|
}); |
|
|
|
|
|
|
|
render(<GenerationComposer />); |
|
|
|
|
|
|
|
await waitFor(() => { |
|
|
|
expect(fetchMock.mock.calls.some(([input]) => String(input).startsWith("/api/points/estimate"))).toBe(true); |
|
|
|
}); |
|
|
|
const estimateCall = fetchMock.mock.calls.find(([input]) => String(input).startsWith("/api/points/estimate")); |
|
|
|
expect(estimateCall).toBeDefined(); |
|
|
|
expect(JSON.parse(String((estimateCall?.[1] as RequestInit).body))).toMatchObject({ |
|
|
|
seedanceVideo: { |
|
|
|
input_video_duration_seconds: 6, |
|
|
|
output_video_duration_seconds: 5, |
|
|
|
}, |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
it("uses PopiServer task price estimates for selected image models", async () => { |
|
|
|
const fetchMock = vi.fn(async (input: RequestInfo | URL) => { |
|
|
|
const url = String(input); |
|
|
|
|