若干更新迭代
This commit is contained in:
1 parent
deb9cc5bcf
commit
4ac786aafb
64 files changed
+3251
-291
No files matched your search
@@ -88,21 +88,40 @@ describe("Seedance usage extraction", () => {
|
||||
expect(body?.content).toHaveLength(6);
|
||||
});
|
||||
|
||||
it("rejects more materials than the Seedance 2.0 content limit before calling the provider", async () => {
|
||||
it("accepts nine Seedance 2.0 reference images and rejects a tenth", async () => {
|
||||
process.env.SEEDANCE_API_KEY = "test-key";
|
||||
let body: Record<string, unknown> | undefined;
|
||||
const fetchMock = vi.fn(async (_input: RequestInfo | URL, init?: RequestInit) => {
|
||||
body = JSON.parse(String(init?.body));
|
||||
return new Response(JSON.stringify({ id: "task-20" }), { status: 200, headers: { "Content-Type": "application/json" } });
|
||||
});
|
||||
vi.stubGlobal("fetch", fetchMock);
|
||||
const materials = Array.from({ length: 9 }, (_, index) => ({
|
||||
type: "image" as const,
|
||||
url: `/image-${index + 1}.png`,
|
||||
label: `@图片${index + 1}`
|
||||
}));
|
||||
await createSeedanceTask({
|
||||
prompt: "combine",
|
||||
settings: {},
|
||||
materials,
|
||||
origin: "https://app.test"
|
||||
});
|
||||
expect(body?.content).toHaveLength(10);
|
||||
expect(fetchMock).toHaveBeenCalledTimes(1);
|
||||
await expect(createSeedanceTask({
|
||||
prompt: "combine", settings: {}, materials: [...materials, { type: "image", url: "/image-10.png" }], origin: "https://app.test"
|
||||
})).rejects.toThrow("最多支持 9 张图片");
|
||||
expect(fetchMock).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("rejects Seedance 2.0 audio without an image or video", async () => {
|
||||
process.env.SEEDANCE_API_KEY = "test-key";
|
||||
const fetchMock = vi.fn();
|
||||
vi.stubGlobal("fetch", fetchMock);
|
||||
|
||||
await expect(createSeedanceTask({
|
||||
prompt: "combine",
|
||||
settings: {},
|
||||
materials: Array.from({ length: 5 }, (_, index) => ({
|
||||
type: "image" as const,
|
||||
url: `/image-${index + 1}.png`,
|
||||
label: `@图片${index + 1}`
|
||||
})),
|
||||
origin: "https://app.test"
|
||||
})).rejects.toThrow("最多支持 4 个素材");
|
||||
prompt: "music", settings: {}, materials: [{ type: "audio", url: "/music.mp3" }], origin: "https://app.test"
|
||||
})).rejects.toThrow("音频不能单独使用");
|
||||
expect(fetchMock).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user