@@ -399,6 +399,59 @@ describe("collectPluginClawHubReleasePlan", () => {
|
399 | 399 | ]); |
400 | 400 | }); |
401 | 401 | |
| 402 | +it("cancels unused ClawHub package and version response bodies", async () => { |
| 403 | +const repoDir = createTempPluginRepo(); |
| 404 | +const canceled: string[] = []; |
| 405 | +const fetchImpl: typeof fetch = async (input) => { |
| 406 | +const requestUrl = |
| 407 | +typeof input === "string" ? input : input instanceof URL ? input.href : input.url; |
| 408 | +const url = new URL(requestUrl); |
| 409 | + |
| 410 | +if (url.pathname === "/api/v1/packages/%40openclaw%2Fdemo-plugin") { |
| 411 | +return new Response( |
| 412 | +new ReadableStream<Uint8Array>({ |
| 413 | +cancel() { |
| 414 | +canceled.push("package"); |
| 415 | +}, |
| 416 | +}), |
| 417 | +{ status: 200 }, |
| 418 | +); |
| 419 | +} |
| 420 | +if (url.pathname === "/api/v1/packages/%40openclaw%2Fdemo-plugin/trusted-publisher") { |
| 421 | +return new Response( |
| 422 | +JSON.stringify({ |
| 423 | +trustedPublisher: { |
| 424 | +repository: "openclaw/openclaw", |
| 425 | +workflowFilename: "plugin-clawhub-release.yml", |
| 426 | +}, |
| 427 | +}), |
| 428 | +{ status: 200 }, |
| 429 | +); |
| 430 | +} |
| 431 | +if (url.pathname === "/api/v1/packages/%40openclaw%2Fdemo-plugin/versions/2026.4.1") { |
| 432 | +return new Response( |
| 433 | +new ReadableStream<Uint8Array>({ |
| 434 | +cancel() { |
| 435 | +canceled.push("version"); |
| 436 | +}, |
| 437 | +}), |
| 438 | +{ status: 404 }, |
| 439 | +); |
| 440 | +} |
| 441 | + |
| 442 | +throw new Error(`Unexpected ClawHub request to ${url.pathname}`); |
| 443 | +}; |
| 444 | + |
| 445 | +await collectPluginClawHubReleasePlan({ |
| 446 | +rootDir: repoDir, |
| 447 | +selection: ["@openclaw/demo-plugin"], |
| 448 | + fetchImpl, |
| 449 | +registryBaseUrl: "https://clawhub.ai", |
| 450 | +}); |
| 451 | + |
| 452 | +expect(canceled).toEqual(["package", "version"]); |
| 453 | +}); |
| 454 | + |
402 | 455 | it("routes missing package rows to bootstrap candidates instead of normal candidates", async () => { |
403 | 456 | const repoDir = createTempPluginRepo(); |
404 | 457 | const { fetchImpl } = createClawHubPlanFetch({ |
|