Reduce hot run polling pressure

This commit is contained in:
npc0-hue
2026-09-07 20:26:20 +08:00
parent 4ab7bb820d
commit fd9dbab669
16 changed files with 335 additions and 56 deletions
+5 -1
View File
@@ -323,6 +323,9 @@ describe("PlatformApiClient AI providers", () => {
if (url.endsWith("/api/v1/jobs?states=queued%2Crunning%2Cfailed")) {
return jsonResponse({ items: [job], count: 1 });
}
if (url.endsWith("/api/v1/jobs?states=queued%2Crunning%2Cfailed&limit=25")) {
return jsonResponse({ items: [job], count: 1 });
}
if (url.endsWith("/api/v1/jobs?serverInstanceId=server-1&states=queued%2Crunning%2Cfailed")) {
return jsonResponse({ items: [job], count: 1 });
}
@@ -584,6 +587,7 @@ describe("PlatformApiClient AI providers", () => {
await expect(client.listJobs()).resolves.toMatchObject({ count: 1 });
await expect(client.listJobs(server.id)).resolves.toMatchObject({ count: 1 });
await expect(client.listJobs(undefined, { states: ["queued", "running", "failed"] })).resolves.toMatchObject({ count: 1 });
await expect(client.listJobs(undefined, { states: ["queued", "running", "failed"], limit: 25 })).resolves.toMatchObject({ count: 1 });
await expect(client.listJobs(server.id, { states: ["queued", "running", "failed"] })).resolves.toMatchObject({ count: 1 });
await expect(client.listArtifacts({ ownerKind: "job", ownerId: job.id, state: "available" })).resolves.toMatchObject({ count: 1, items: [{ id: artifact.id }] });
await expect(client.openArtifactDownload(artifact.id)).resolves.toMatchObject({ downloadUrl: "/api/v1/artifacts/artifact-1/content", rangeSupported: true });
@@ -625,7 +629,7 @@ describe("PlatformApiClient AI providers", () => {
client.invokeAI({ requestId: "ai-1", serverInstanceId: server.id, purpose: "config.suggest", prompt: "Tune PVP safely", currentConfig: "server.name=Example Survival #1\n" })
).resolves.toMatchObject({ status: "ok", usage: { mocked: true }, configRecommendation: { diffSummary: "review required" } });
expect(fetchMock).toHaveBeenCalledTimes(46);
expect(fetchMock).toHaveBeenCalledTimes(47);
});
it("normalizes server file workspace null arrays from older platform responses", async () => {