|
|
|
@ -35,6 +35,10 @@ function makeInput(): GenerationInput { |
|
|
|
}, |
|
|
|
prompt: "@角色1 和 @角色2 在一起吃火锅", |
|
|
|
images: ["https://example.com/1.png", "https://example.com/2.png"], |
|
|
|
referenceSubjectList: [ |
|
|
|
{ id: 1, type: "image", url: "https://example.com/1.png", name: "图1" }, |
|
|
|
{ id: 2, type: "image", url: "https://example.com/2.png", name: "图2" }, |
|
|
|
], |
|
|
|
subType: POPI_VIDEO_SUBTYPE_OMNI_REFERENCE, |
|
|
|
parameters: { |
|
|
|
ratio: "16:9", |
|
|
|
@ -97,15 +101,11 @@ describe("popiserver generation provider", () => { |
|
|
|
expect(body).toMatchObject({ |
|
|
|
type: 2, |
|
|
|
subType: POPI_VIDEO_SUBTYPE_OMNI_REFERENCE, |
|
|
|
aiPlatform: "GATEWAY", |
|
|
|
origin: "canvas", |
|
|
|
model: "", |
|
|
|
aiModelId: 15, |
|
|
|
aiModelCode: "viduq2-pro", |
|
|
|
aiModelCodeAlias: "viduq2-pro", |
|
|
|
batchSize: 1, |
|
|
|
ratio: "16:9", |
|
|
|
aspect_ratio: "16:9", |
|
|
|
resolution: "720", |
|
|
|
videoRatio: 10, |
|
|
|
}); |
|
|
|
@ -197,12 +197,48 @@ describe("popiserver generation provider", () => { |
|
|
|
}, |
|
|
|
referenceSubjectList: [ |
|
|
|
{ id: 1, type: "image", url: "https://example.com/1.png", name: "图1" }, |
|
|
|
{ id: 2, type: "image", url: "https://example.com/2.png", name: "图2" }, |
|
|
|
], |
|
|
|
}); |
|
|
|
expect(body.generate_audio).toBeUndefined(); |
|
|
|
}); |
|
|
|
|
|
|
|
it("uses the frontend referenceSubjectList order without rebuilding it from images", async () => { |
|
|
|
vi.mocked(global.fetch).mockResolvedValue({ |
|
|
|
ok: true, |
|
|
|
json: () => Promise.resolve({ |
|
|
|
status: "0000", |
|
|
|
message: "ok", |
|
|
|
data: { id: 1198 }, |
|
|
|
}), |
|
|
|
} as Response); |
|
|
|
|
|
|
|
const input = makeInput(); |
|
|
|
input.images = [ |
|
|
|
"https://popitest-public-1313913486.cos.ap-guangzhou.myqcloud.com/media/image/2026/0702/9535.jpeg", |
|
|
|
"https://popitest-public-1313913486.cos.ap-guangzhou.myqcloud.com/media/image/2026/0701/9225.png", |
|
|
|
]; |
|
|
|
input.referenceSubjectList = [ |
|
|
|
{ |
|
|
|
id: 1, |
|
|
|
type: "image", |
|
|
|
url: "https://popitest-public-1313913486.cos.ap-guangzhou.myqcloud.com/media/image/2026/0701/9225.png", |
|
|
|
name: "图1", |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: 2, |
|
|
|
type: "image", |
|
|
|
url: "https://popitest-public-1313913486.cos.ap-guangzhou.myqcloud.com/media/image/2026/0702/9535.jpeg", |
|
|
|
name: "图2", |
|
|
|
}, |
|
|
|
]; |
|
|
|
|
|
|
|
await submitPopiTask(makeRequest(), "login-token", input); |
|
|
|
|
|
|
|
const [, init] = vi.mocked(global.fetch).mock.calls[0]; |
|
|
|
const body = JSON.parse(String(init?.body)); |
|
|
|
expect(body.referenceSubjectList).toEqual(input.referenceSubjectList); |
|
|
|
}); |
|
|
|
|
|
|
|
it("collects all task ids from batched task create responses", async () => { |
|
|
|
vi.mocked(global.fetch).mockResolvedValue({ |
|
|
|
ok: true, |
|
|
|
@ -239,10 +275,7 @@ describe("popiserver generation provider", () => { |
|
|
|
const [, init] = vi.mocked(global.fetch).mock.calls[0]; |
|
|
|
const body = JSON.parse(String(init?.body)); |
|
|
|
expect(body).toMatchObject({ |
|
|
|
ratio: "9:16", |
|
|
|
aspect_ratio: "9:16", |
|
|
|
width: 720, |
|
|
|
height: 1280, |
|
|
|
}); |
|
|
|
expect(body.aspectRatio).toBeUndefined(); |
|
|
|
}); |
|
|
|
@ -283,7 +316,6 @@ describe("popiserver generation provider", () => { |
|
|
|
const body = JSON.parse(String(init?.body)); |
|
|
|
expect(body).toMatchObject({ |
|
|
|
chatPrompt: "比例:16:9\n清晰度:1K\n提示词:create a cinematic cat", |
|
|
|
model: "", |
|
|
|
ratio: "16:9", |
|
|
|
resolution: "1K", |
|
|
|
}); |
|
|
|
@ -325,15 +357,13 @@ describe("popiserver generation provider", () => { |
|
|
|
const body = JSON.parse(String(init?.body)); |
|
|
|
expect(body).toMatchObject({ |
|
|
|
chatPrompt: "比例:9:16\n清晰度:2K\n提示词:create a clean product render", |
|
|
|
model: "", |
|
|
|
ratio: "9:16", |
|
|
|
aspect_ratio: "9:16", |
|
|
|
resolution: "2K", |
|
|
|
}); |
|
|
|
expect(body.aspectRatio).toBeUndefined(); |
|
|
|
}); |
|
|
|
|
|
|
|
it("builds referenceSubjectList for image tasks without @ in names", async () => { |
|
|
|
it("uses frontend referenceSubjectList for image tasks", async () => { |
|
|
|
vi.mocked(global.fetch).mockResolvedValue({ |
|
|
|
ok: true, |
|
|
|
json: () => Promise.resolve({ |
|
|
|
@ -359,18 +389,18 @@ describe("popiserver generation provider", () => { |
|
|
|
}; |
|
|
|
input.prompt = "@图1 作为人物参考生成海报"; |
|
|
|
input.images = ["https://statictest.popi.art/media/ani/character/2026/0512/4540.jpg"]; |
|
|
|
input.subType = 103; |
|
|
|
input.parameters = { |
|
|
|
ratio: "16:9", |
|
|
|
resolution: "1K", |
|
|
|
referenceSubjectList: [ |
|
|
|
input.referenceSubjectList = [ |
|
|
|
{ |
|
|
|
id: 1, |
|
|
|
type: "image", |
|
|
|
url: "stale-image-url", |
|
|
|
name: "@图1", |
|
|
|
url: "https://statictest.popi.art/media/ani/character/2026/0512/4540.jpg", |
|
|
|
name: "图1", |
|
|
|
}, |
|
|
|
], |
|
|
|
]; |
|
|
|
input.subType = 103; |
|
|
|
input.parameters = { |
|
|
|
ratio: "16:9", |
|
|
|
resolution: "1K", |
|
|
|
}; |
|
|
|
|
|
|
|
const result = await submitPopiTask(makeRequest(), "login-token", input); |
|
|
|
@ -410,15 +440,14 @@ describe("popiserver generation provider", () => { |
|
|
|
expect(JSON.parse(String(init?.body))).toEqual({ |
|
|
|
type: 3, |
|
|
|
chatPrompt: "我是一个小白兔,白白的小白兔", |
|
|
|
model: "", |
|
|
|
origin: "canvas", |
|
|
|
aiPlatform: "GATEWAY", |
|
|
|
aiModelName: "Speech 2.8 HD", |
|
|
|
aiModelId: 30, |
|
|
|
aiModelCode: "speech-2.8-hd", |
|
|
|
aiModelCodeAlias: "speech-2.8-hd", |
|
|
|
subType: 301, |
|
|
|
batchSize: 1, |
|
|
|
referenceSubjectList: undefined, |
|
|
|
extraTaskParams: {}, |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
@ -585,7 +614,7 @@ describe("popiserver generation provider", () => { |
|
|
|
]); |
|
|
|
}); |
|
|
|
|
|
|
|
it("builds referenceSubjectList from final image and video URLs", async () => { |
|
|
|
it("uses frontend referenceSubjectList with image, video, and audio references", async () => { |
|
|
|
vi.mocked(global.fetch).mockResolvedValue({ |
|
|
|
ok: true, |
|
|
|
json: () => Promise.resolve({ |
|
|
|
@ -612,39 +641,39 @@ describe("popiserver generation provider", () => { |
|
|
|
}; |
|
|
|
input.prompt = "@图1的人物参考@视频2的人物的动作跳舞"; |
|
|
|
input.images = ["https://statictest.popi.art/media/ani/character/2026/0512/4540.jpg"]; |
|
|
|
input.dynamicInputs = { |
|
|
|
videos: ["https://statictest.popi.art/media/aiGen/2026/0603/5470.mp4"], |
|
|
|
voices: ["https://statictest.popi.art/media/audio/2026/0603/5470.mp3"], |
|
|
|
}; |
|
|
|
input.parameters = { |
|
|
|
aiModelName: "seedance 2.0-fast", |
|
|
|
aiPlatform: "seedance 2.0", |
|
|
|
model: "seedance 2.0", |
|
|
|
ratio: "16:9", |
|
|
|
resolution: "480P", |
|
|
|
duration: 5, |
|
|
|
batchSize: 1, |
|
|
|
referenceSubjectList: [ |
|
|
|
input.referenceSubjectList = [ |
|
|
|
{ |
|
|
|
id: 1, |
|
|
|
type: "image", |
|
|
|
url: "stale-image-url", |
|
|
|
name: "@图1", |
|
|
|
url: "https://statictest.popi.art/media/ani/character/2026/0512/4540.jpg", |
|
|
|
name: "图1", |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: 2, |
|
|
|
type: "video", |
|
|
|
url: "stale-video-url", |
|
|
|
name: "@视频2", |
|
|
|
url: "https://statictest.popi.art/media/aiGen/2026/0603/5470.mp4", |
|
|
|
name: "视频2", |
|
|
|
duration: 5.033, |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: 3, |
|
|
|
type: "audio", |
|
|
|
url: "stale-audio-url", |
|
|
|
name: "@音频3", |
|
|
|
url: "https://statictest.popi.art/media/audio/2026/0603/5470.mp3", |
|
|
|
name: "音频3", |
|
|
|
}, |
|
|
|
], |
|
|
|
]; |
|
|
|
input.dynamicInputs = { |
|
|
|
videos: ["https://statictest.popi.art/media/aiGen/2026/0603/5470.mp4"], |
|
|
|
voices: ["https://statictest.popi.art/media/audio/2026/0603/5470.mp3"], |
|
|
|
}; |
|
|
|
input.parameters = { |
|
|
|
aiModelName: "seedance 2.0-fast", |
|
|
|
aiPlatform: "seedance 2.0", |
|
|
|
model: "seedance 2.0", |
|
|
|
ratio: "16:9", |
|
|
|
resolution: "480P", |
|
|
|
duration: 5, |
|
|
|
batchSize: 1, |
|
|
|
}; |
|
|
|
input.subType = POPI_VIDEO_SUBTYPE_OMNI_REFERENCE; |
|
|
|
|
|
|
|
@ -666,33 +695,11 @@ describe("popiserver generation provider", () => { |
|
|
|
resolution: "480P", |
|
|
|
duration: 5, |
|
|
|
batchSize: 1, |
|
|
|
width: 1280, |
|
|
|
height: 720, |
|
|
|
chatPrompt: "@图1的人物参考@视频2的人物的动作跳舞", |
|
|
|
images: ["https://statictest.popi.art/media/ani/character/2026/0512/4540.jpg"], |
|
|
|
videos: ["https://statictest.popi.art/media/aiGen/2026/0603/5470.mp4"], |
|
|
|
voices: ["https://statictest.popi.art/media/audio/2026/0603/5470.mp3"], |
|
|
|
referenceSubjectList: [ |
|
|
|
{ |
|
|
|
id: 1, |
|
|
|
type: "image", |
|
|
|
url: "https://statictest.popi.art/media/ani/character/2026/0512/4540.jpg", |
|
|
|
name: "图1", |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: 2, |
|
|
|
type: "video", |
|
|
|
url: "https://statictest.popi.art/media/aiGen/2026/0603/5470.mp4", |
|
|
|
name: "视频2", |
|
|
|
duration: 5.033, |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: 3, |
|
|
|
type: "audio", |
|
|
|
url: "https://statictest.popi.art/media/audio/2026/0603/5470.mp3", |
|
|
|
name: "音频3", |
|
|
|
}, |
|
|
|
], |
|
|
|
referenceSubjectList: input.referenceSubjectList, |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
@ -714,43 +721,13 @@ describe("popiserver generation provider", () => { |
|
|
|
input.dynamicInputs = { |
|
|
|
videos: ["https://statictest.popi.art/media/aiGen/2026/0603/5470.mp4"], |
|
|
|
}; |
|
|
|
input.parameters = { |
|
|
|
...input.parameters, |
|
|
|
referenceSubjectList: [ |
|
|
|
{ |
|
|
|
id: 1, |
|
|
|
type: "image", |
|
|
|
url: "stale-image-url", |
|
|
|
name: "@图1", |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: 2, |
|
|
|
type: "video", |
|
|
|
url: "stale-video-url", |
|
|
|
name: "@视频2", |
|
|
|
}, |
|
|
|
], |
|
|
|
}; |
|
|
|
|
|
|
|
await submitPopiTask(makeRequest(), "login-token", input); |
|
|
|
|
|
|
|
const [, init] = vi.mocked(global.fetch).mock.calls[0]; |
|
|
|
const body = JSON.parse(String(init?.body)); |
|
|
|
expect(body.videos).toBeUndefined(); |
|
|
|
expect(body.referenceSubjectList).toEqual([ |
|
|
|
{ |
|
|
|
id: 1, |
|
|
|
type: "image", |
|
|
|
url: "https://example.com/1.png", |
|
|
|
name: "图1", |
|
|
|
}, |
|
|
|
{ |
|
|
|
id: 2, |
|
|
|
type: "image", |
|
|
|
url: "https://example.com/2.png", |
|
|
|
name: "图2", |
|
|
|
}, |
|
|
|
]); |
|
|
|
expect(body.referenceSubjectList).toEqual(input.referenceSubjectList); |
|
|
|
}); |
|
|
|
|
|
|
|
it("extracts completed image task output from task list", async () => { |
|
|
|
|