From f6cdc11eafda6feebe2ce05e95b27c9ea6e36c75 Mon Sep 17 00:00:00 2001 From: "paseo-bot[bot]" <266920839+paseo-bot[bot]@users.noreply.github.com> Date: Sun, 18 Oct 2026 10:00:03 +0200 Subject: [PATCH] test: reproduce independent Gitea worktree refresh requests --- .../server/src/services/gitea-service.test.ts | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/packages/server/src/services/gitea-service.test.ts b/packages/server/src/services/gitea-service.test.ts index 9e3a3ecc62..aaa40e7ce3 100644 --- a/packages/server/src/services/gitea-service.test.ts +++ b/packages/server/src/services/gitea-service.test.ts @@ -430,6 +430,47 @@ function giteaMergeStatus( } describe("createGiteaService", () => { + it("coalesces concurrent current PR list reads across worktrees of one repository", async () => { + const { service, calls } = makeService(() => ok("[]")); + + const statuses = await Promise.all( + ["one", "two", "three"].map((branch) => + service.getCurrentPullRequestStatus({ + cwd: `/worktrees/${branch}`, + headRef: branch, + reason: "self-heal-forge-pr-status", + }), + ), + ); + + expect(statuses).toEqual([null, null, null]); + expect(calls).toHaveLength(2); + }); + + it("stops another worktree's refresh after the shared endpoint reports Too Many Requests", async () => { + const { service, calls } = makeService((args) => { + throw new TeaCommandError({ + args, + cwd: "/worktrees/one", + exitCode: 1, + stderr: + "Error: Get https://gitea.com/api/v1/repos/example-user/sample-repo/pulls: Too Many Requests", + }); + }); + + for (const branch of ["one", "two"]) { + await expect( + service.getCurrentPullRequestStatus({ + cwd: `/worktrees/${branch}`, + headRef: branch, + reason: "self-heal-forge-pr-status", + }), + ).rejects.toThrow(TeaCommandError); + } + + expect(calls).toHaveLength(1); + }); + it("maps a tea pr list item to the neutral current PR status by head branch", async () => { const { service, calls } = makeService((args) => { if (args[0] === "pr" && args[1] === "list")