修复了2个bug
This commit is contained in:
1 parent
ce8372e878
commit
2a64dc7395
64 files changed
+1050
-39
No files matched your search
@@ -38,6 +38,28 @@ describe("Seedream layer edit result synchronization", () => {
|
||||
vi.unstubAllGlobals();
|
||||
});
|
||||
|
||||
it("uses the supported asset collection when production rejects platform item GET", async () => {
|
||||
vi.useFakeTimers();
|
||||
vi.stubGlobal("window", { setTimeout, clearTimeout });
|
||||
const job = { ...succeededBeforeOutputSync, outputAssetIds: [resultAsset.id] };
|
||||
const fetchMock = vi.fn(async (input: RequestInfo | URL) => {
|
||||
const url = String(input);
|
||||
if (url === "/api/generations/image/job-edit-1") return Response.json({ job });
|
||||
if (url === "/api/assets/asset-result") return new Response(null, { status: 405 });
|
||||
if (url === "/api/assets") return Response.json({ assets: [resultAsset] });
|
||||
return Response.json({ error: "unexpected request" }, { status: 404 });
|
||||
});
|
||||
vi.stubGlobal("fetch", fetchMock);
|
||||
|
||||
const pending = waitForJobOutputAssets(job, new AbortController().signal);
|
||||
const assertion = expect(pending).resolves.toEqual([resultAsset]);
|
||||
await vi.runAllTimersAsync();
|
||||
|
||||
await assertion;
|
||||
expect(fetchMock).toHaveBeenCalledWith("/api/assets", expect.objectContaining({ cache: "no-store" }));
|
||||
expect(fetchMock).not.toHaveBeenCalledWith("/api/assets/asset-result", expect.anything());
|
||||
});
|
||||
|
||||
it("refreshes a succeeded job whose output IDs arrive after the terminal status", async () => {
|
||||
vi.useFakeTimers();
|
||||
vi.stubGlobal("window", { setTimeout, clearTimeout });
|
||||
@@ -46,7 +68,7 @@ describe("Seedream layer edit result synchronization", () => {
|
||||
if (url === "/api/generations/image/job-edit-1") {
|
||||
return Response.json({ job: { ...succeededBeforeOutputSync, outputAssetIds: [resultAsset.id] } });
|
||||
}
|
||||
if (url === "/api/assets/asset-result") return Response.json({ asset: resultAsset });
|
||||
if (url === "/api/assets") return Response.json({ assets: [resultAsset] });
|
||||
return Response.json({ error: "unexpected request" }, { status: 404 });
|
||||
});
|
||||
vi.stubGlobal("fetch", fetchMock);
|
||||
@@ -56,10 +78,10 @@ describe("Seedream layer edit result synchronization", () => {
|
||||
|
||||
await expect(pending).resolves.toEqual([resultAsset]);
|
||||
expect(fetchMock).toHaveBeenCalledWith("/api/generations/image/job-edit-1", expect.objectContaining({ cache: "no-store" }));
|
||||
expect(fetchMock).toHaveBeenCalledWith("/api/assets/asset-result", expect.objectContaining({ cache: "no-store" }));
|
||||
expect(fetchMock).toHaveBeenCalledWith("/api/assets", expect.objectContaining({ cache: "no-store" }));
|
||||
});
|
||||
|
||||
it("retries the direct asset lookup while the registered result is not readable yet", async () => {
|
||||
it("retries the asset collection while the registered result is not readable yet", async () => {
|
||||
vi.useFakeTimers();
|
||||
vi.stubGlobal("window", { setTimeout, clearTimeout });
|
||||
let assetReads = 0;
|
||||
@@ -67,11 +89,11 @@ describe("Seedream layer edit result synchronization", () => {
|
||||
const fetchMock = vi.fn(async (input: RequestInfo | URL) => {
|
||||
const url = String(input);
|
||||
if (url === "/api/generations/image/job-edit-1") return Response.json({ job });
|
||||
if (url === "/api/assets/asset-result") {
|
||||
if (url === "/api/assets") {
|
||||
assetReads += 1;
|
||||
return assetReads === 1
|
||||
? Response.json({ error: "资产不存在" }, { status: 404 })
|
||||
: Response.json({ asset: resultAsset });
|
||||
? Response.json({ assets: [] })
|
||||
: Response.json({ assets: [resultAsset] });
|
||||
}
|
||||
return Response.json({ error: "unexpected request" }, { status: 404 });
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user