From 13ed3db77ccbcf160b4d231057003fddacdf9df1 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 7 Jul 2026 21:05:08 +0000 Subject: [PATCH] Drop tight per-test timeout overrides in GitManager tests Six cross-repo PR tests carried 12s/20s per-test timeouts from when the suite default was Vitest's 5s. The server suite now sets a 120s budget precisely because these git-subprocess-heavy tests can crawl on loaded CI hosts, so the leftover overrides only shrank the budget and made the tests time out spuriously. Remove them so the tests inherit the configured default. Co-authored-by: Theo Browne --- apps/server/src/git/GitManager.test.ts | 478 ++++++++++++------------- 1 file changed, 232 insertions(+), 246 deletions(-) diff --git a/apps/server/src/git/GitManager.test.ts b/apps/server/src/git/GitManager.test.ts index e1924c03ad..ea7d50bb1d 100644 --- a/apps/server/src/git/GitManager.test.ts +++ b/apps/server/src/git/GitManager.test.ts @@ -1008,73 +1008,70 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => { }), ); - it.effect( - "status detects cross-repo PRs from the upstream remote URL owner", - () => - Effect.gen(function* () { - const repoDir = yield* makeTempDir("t3code-git-manager-"); - yield* initRepo(repoDir); - const forkDir = yield* createBareRemote(); - yield* runGit(repoDir, ["remote", "add", "fork-seed", forkDir]); - yield* runGit(repoDir, ["checkout", "-b", "statemachine"]); - NodeFS.writeFileSync(NodePath.join(repoDir, "fork-pr.txt"), "fork pr\n"); - yield* runGit(repoDir, ["add", "fork-pr.txt"]); - yield* runGit(repoDir, ["commit", "-m", "Fork PR branch"]); - yield* runGit(repoDir, ["push", "-u", "fork-seed", "statemachine"]); - yield* runGit(repoDir, ["checkout", "-b", "t3code/pr-488/statemachine"]); - yield* runGit(repoDir, ["branch", "--set-upstream-to", "fork-seed/statemachine"]); - yield* configureVisibleRemoteUrlWithLocalRewrite( - repoDir, - "fork-seed", - "git@github.com:jasonLaster/codething-mvp.git", - forkDir, - ); + it.effect("status detects cross-repo PRs from the upstream remote URL owner", () => + Effect.gen(function* () { + const repoDir = yield* makeTempDir("t3code-git-manager-"); + yield* initRepo(repoDir); + const forkDir = yield* createBareRemote(); + yield* runGit(repoDir, ["remote", "add", "fork-seed", forkDir]); + yield* runGit(repoDir, ["checkout", "-b", "statemachine"]); + NodeFS.writeFileSync(NodePath.join(repoDir, "fork-pr.txt"), "fork pr\n"); + yield* runGit(repoDir, ["add", "fork-pr.txt"]); + yield* runGit(repoDir, ["commit", "-m", "Fork PR branch"]); + yield* runGit(repoDir, ["push", "-u", "fork-seed", "statemachine"]); + yield* runGit(repoDir, ["checkout", "-b", "t3code/pr-488/statemachine"]); + yield* runGit(repoDir, ["branch", "--set-upstream-to", "fork-seed/statemachine"]); + yield* configureVisibleRemoteUrlWithLocalRewrite( + repoDir, + "fork-seed", + "git@github.com:jasonLaster/codething-mvp.git", + forkDir, + ); - const { manager, ghCalls } = yield* makeManager({ - ghScenario: { - prListSequence: [ - // @effect-diagnostics-next-line preferSchemaOverJson:off - JSON.stringify([]), - // @effect-diagnostics-next-line preferSchemaOverJson:off - JSON.stringify([]), - // @effect-diagnostics-next-line preferSchemaOverJson:off - JSON.stringify([ - { - number: 488, - title: "Rebase this PR on latest main", - url: "https://github.com/pingdotgg/codething-mvp/pull/488", - baseRefName: "main", - headRefName: "statemachine", - state: "OPEN", - updatedAt: "2026-03-10T07:00:00Z", - isCrossRepository: true, - headRepository: { - nameWithOwner: "jasonLaster/codething-mvp", - }, - headRepositoryOwner: { - login: "jasonLaster", - }, + const { manager, ghCalls } = yield* makeManager({ + ghScenario: { + prListSequence: [ + // @effect-diagnostics-next-line preferSchemaOverJson:off + JSON.stringify([]), + // @effect-diagnostics-next-line preferSchemaOverJson:off + JSON.stringify([]), + // @effect-diagnostics-next-line preferSchemaOverJson:off + JSON.stringify([ + { + number: 488, + title: "Rebase this PR on latest main", + url: "https://github.com/pingdotgg/codething-mvp/pull/488", + baseRefName: "main", + headRefName: "statemachine", + state: "OPEN", + updatedAt: "2026-03-10T07:00:00Z", + isCrossRepository: true, + headRepository: { + nameWithOwner: "jasonLaster/codething-mvp", }, - ]), - ], - }, - }); + headRepositoryOwner: { + login: "jasonLaster", + }, + }, + ]), + ], + }, + }); - const status = yield* manager.status({ cwd: repoDir }); - expect(status.refName).toBe("t3code/pr-488/statemachine"); - expect(status.pr).toEqual({ - number: 488, - title: "Rebase this PR on latest main", - url: "https://github.com/pingdotgg/codething-mvp/pull/488", - baseRef: "main", - headRef: "statemachine", - state: "open", - }); - expect(ghCalls).toContain( - "pr list --head jasonLaster:statemachine --state all --limit 20 --json number,title,url,baseRefName,headRefName,state,mergedAt,updatedAt,isCrossRepository,headRepository,headRepositoryOwner", - ); - }), - 20_000, + const status = yield* manager.status({ cwd: repoDir }); + expect(status.refName).toBe("t3code/pr-488/statemachine"); + expect(status.pr).toEqual({ + number: 488, + title: "Rebase this PR on latest main", + url: "https://github.com/pingdotgg/codething-mvp/pull/488", + baseRef: "main", + headRef: "statemachine", + state: "open", + }); + expect(ghCalls).toContain( + "pr list --head jasonLaster:statemachine --state all --limit 20 --json number,title,url,baseRefName,headRefName,state,mergedAt,updatedAt,isCrossRepository,headRepository,headRepositoryOwner", + ); + }), ); it.effect( @@ -1190,7 +1187,6 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => { ), ).toBe(false); }), - 20_000, ); it.effect("status returns merged PR state when latest PR was merged", () => @@ -1884,65 +1880,62 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => { }), ); - it.effect( - "returns existing cross-repo PR metadata using the fork owner selector", - () => - Effect.gen(function* () { - const repoDir = yield* makeTempDir("t3code-git-manager-"); - yield* initRepo(repoDir); - yield* runGit(repoDir, ["checkout", "-b", "statemachine"]); - const forkDir = yield* createBareRemote(); - yield* runGit(repoDir, ["remote", "add", "fork-seed", forkDir]); - yield* runGit(repoDir, ["push", "-u", "fork-seed", "statemachine"]); - yield* configureVisibleRemoteUrlWithLocalRewrite( - repoDir, - "fork-seed", - "git@github.com:octocat/codething-mvp.git", - forkDir, - ); + it.effect("returns existing cross-repo PR metadata using the fork owner selector", () => + Effect.gen(function* () { + const repoDir = yield* makeTempDir("t3code-git-manager-"); + yield* initRepo(repoDir); + yield* runGit(repoDir, ["checkout", "-b", "statemachine"]); + const forkDir = yield* createBareRemote(); + yield* runGit(repoDir, ["remote", "add", "fork-seed", forkDir]); + yield* runGit(repoDir, ["push", "-u", "fork-seed", "statemachine"]); + yield* configureVisibleRemoteUrlWithLocalRewrite( + repoDir, + "fork-seed", + "git@github.com:octocat/codething-mvp.git", + forkDir, + ); - const { manager, ghCalls } = yield* makeManager({ - ghScenario: { - prListSequence: [ - // @effect-diagnostics-next-line preferSchemaOverJson:off - JSON.stringify([]), - // @effect-diagnostics-next-line preferSchemaOverJson:off - JSON.stringify([ - { - number: 142, - title: "Existing fork PR", - url: "https://github.com/pingdotgg/codething-mvp/pull/142", - baseRefName: "main", - headRefName: "statemachine", - state: "OPEN", - isCrossRepository: true, - headRepository: { - nameWithOwner: "octocat/codething-mvp", - }, - headRepositoryOwner: { - login: "octocat", - }, + const { manager, ghCalls } = yield* makeManager({ + ghScenario: { + prListSequence: [ + // @effect-diagnostics-next-line preferSchemaOverJson:off + JSON.stringify([]), + // @effect-diagnostics-next-line preferSchemaOverJson:off + JSON.stringify([ + { + number: 142, + title: "Existing fork PR", + url: "https://github.com/pingdotgg/codething-mvp/pull/142", + baseRefName: "main", + headRefName: "statemachine", + state: "OPEN", + isCrossRepository: true, + headRepository: { + nameWithOwner: "octocat/codething-mvp", }, - ]), - ], - }, - }); + headRepositoryOwner: { + login: "octocat", + }, + }, + ]), + ], + }, + }); - const result = yield* runStackedAction(manager, { - cwd: repoDir, - action: "commit_push_pr", - }); + const result = yield* runStackedAction(manager, { + cwd: repoDir, + action: "commit_push_pr", + }); - expect(result.pr.status).toBe("opened_existing"); - expect(result.pr.number).toBe(142); - expect( - ghCalls.some((call) => - call.includes("pr list --head octocat:statemachine --state open --limit 1"), - ), - ).toBe(true); - expect(ghCalls.some((call) => call.startsWith("pr create "))).toBe(false); - }), - 12_000, + expect(result.pr.status).toBe("opened_existing"); + expect(result.pr.number).toBe(142); + expect( + ghCalls.some((call) => + call.includes("pr list --head octocat:statemachine --state open --limit 1"), + ), + ).toBe(true); + expect(ghCalls.some((call) => call.startsWith("pr create "))).toBe(false); + }), ); it.effect( @@ -2042,149 +2035,142 @@ it.layer(GitManagerTestLayer)("GitManager", (it) => { false, ); }), - 20_000, ); - it.effect( - "prefers owner-qualified selectors before bare branch names for cross-repo PRs", - () => - Effect.gen(function* () { - const repoDir = yield* makeTempDir("t3code-git-manager-"); - yield* initRepo(repoDir); - yield* runGit(repoDir, ["checkout", "-b", "statemachine"]); - const forkDir = yield* createBareRemote(); - yield* runGit(repoDir, ["remote", "add", "fork-seed", forkDir]); - yield* runGit(repoDir, ["push", "-u", "fork-seed", "statemachine"]); - yield* runGit(repoDir, ["checkout", "-b", "t3code/pr-142/statemachine"]); - yield* runGit(repoDir, ["branch", "--set-upstream-to", "fork-seed/statemachine"]); - yield* configureVisibleRemoteUrlWithLocalRewrite( - repoDir, - "fork-seed", - "git@github.com:octocat/codething-mvp.git", - forkDir, - ); + it.effect("prefers owner-qualified selectors before bare branch names for cross-repo PRs", () => + Effect.gen(function* () { + const repoDir = yield* makeTempDir("t3code-git-manager-"); + yield* initRepo(repoDir); + yield* runGit(repoDir, ["checkout", "-b", "statemachine"]); + const forkDir = yield* createBareRemote(); + yield* runGit(repoDir, ["remote", "add", "fork-seed", forkDir]); + yield* runGit(repoDir, ["push", "-u", "fork-seed", "statemachine"]); + yield* runGit(repoDir, ["checkout", "-b", "t3code/pr-142/statemachine"]); + yield* runGit(repoDir, ["branch", "--set-upstream-to", "fork-seed/statemachine"]); + yield* configureVisibleRemoteUrlWithLocalRewrite( + repoDir, + "fork-seed", + "git@github.com:octocat/codething-mvp.git", + forkDir, + ); - const { manager, ghCalls } = yield* makeManager({ - ghScenario: { - prListByHeadSelector: { - // @effect-diagnostics-next-line preferSchemaOverJson:off - "t3code/pr-142/statemachine": JSON.stringify([]), - // @effect-diagnostics-next-line preferSchemaOverJson:off - statemachine: JSON.stringify([ - { - number: 41, - title: "Unrelated same-repo PR", - url: "https://github.com/pingdotgg/codething-mvp/pull/41", - baseRefName: "main", - headRefName: "statemachine", + const { manager, ghCalls } = yield* makeManager({ + ghScenario: { + prListByHeadSelector: { + // @effect-diagnostics-next-line preferSchemaOverJson:off + "t3code/pr-142/statemachine": JSON.stringify([]), + // @effect-diagnostics-next-line preferSchemaOverJson:off + statemachine: JSON.stringify([ + { + number: 41, + title: "Unrelated same-repo PR", + url: "https://github.com/pingdotgg/codething-mvp/pull/41", + baseRefName: "main", + headRefName: "statemachine", + }, + ]), + // @effect-diagnostics-next-line preferSchemaOverJson:off + "octocat:statemachine": JSON.stringify([ + { + number: 142, + title: "Existing fork PR", + url: "https://github.com/pingdotgg/codething-mvp/pull/142", + baseRefName: "main", + headRefName: "statemachine", + state: "OPEN", + isCrossRepository: true, + headRepository: { + nameWithOwner: "octocat/codething-mvp", }, - ]), - // @effect-diagnostics-next-line preferSchemaOverJson:off - "octocat:statemachine": JSON.stringify([ - { - number: 142, - title: "Existing fork PR", - url: "https://github.com/pingdotgg/codething-mvp/pull/142", - baseRefName: "main", - headRefName: "statemachine", - state: "OPEN", - isCrossRepository: true, - headRepository: { - nameWithOwner: "octocat/codething-mvp", - }, - headRepositoryOwner: { - login: "octocat", - }, + headRepositoryOwner: { + login: "octocat", }, - ]), - // @effect-diagnostics-next-line preferSchemaOverJson:off - "fork-seed:statemachine": JSON.stringify([]), - }, + }, + ]), + // @effect-diagnostics-next-line preferSchemaOverJson:off + "fork-seed:statemachine": JSON.stringify([]), }, - }); + }, + }); - const result = yield* runStackedAction(manager, { - cwd: repoDir, - action: "commit_push_pr", - }); + const result = yield* runStackedAction(manager, { + cwd: repoDir, + action: "commit_push_pr", + }); - expect(result.pr.status).toBe("opened_existing"); - expect(result.pr.number).toBe(142); + expect(result.pr.status).toBe("opened_existing"); + expect(result.pr.number).toBe(142); - const ownerSelectorCallIndex = ghCalls.findIndex((call) => - call.includes("pr list --head octocat:statemachine --state open --limit 1"), - ); - expect(ownerSelectorCallIndex).toBeGreaterThanOrEqual(0); - expect(ghCalls.some((call) => call.startsWith("pr create "))).toBe(false); - }), - 12_000, + const ownerSelectorCallIndex = ghCalls.findIndex((call) => + call.includes("pr list --head octocat:statemachine --state open --limit 1"), + ); + expect(ownerSelectorCallIndex).toBeGreaterThanOrEqual(0); + expect(ghCalls.some((call) => call.startsWith("pr create "))).toBe(false); + }), ); - it.effect( - "stops probing head selectors after finding an existing PR", - () => - Effect.gen(function* () { - const repoDir = yield* makeTempDir("t3code-git-manager-"); - yield* initRepo(repoDir); - yield* runGit(repoDir, ["checkout", "-b", "statemachine"]); - const forkDir = yield* createBareRemote(); - yield* runGit(repoDir, ["remote", "add", "fork-seed", forkDir]); - yield* runGit(repoDir, ["push", "-u", "fork-seed", "statemachine"]); - yield* runGit(repoDir, ["checkout", "-b", "t3code/pr-142/statemachine"]); - yield* runGit(repoDir, ["branch", "--set-upstream-to", "fork-seed/statemachine"]); - yield* configureVisibleRemoteUrlWithLocalRewrite( - repoDir, - "fork-seed", - "git@github.com:octocat/codething-mvp.git", - forkDir, - ); + it.effect("stops probing head selectors after finding an existing PR", () => + Effect.gen(function* () { + const repoDir = yield* makeTempDir("t3code-git-manager-"); + yield* initRepo(repoDir); + yield* runGit(repoDir, ["checkout", "-b", "statemachine"]); + const forkDir = yield* createBareRemote(); + yield* runGit(repoDir, ["remote", "add", "fork-seed", forkDir]); + yield* runGit(repoDir, ["push", "-u", "fork-seed", "statemachine"]); + yield* runGit(repoDir, ["checkout", "-b", "t3code/pr-142/statemachine"]); + yield* runGit(repoDir, ["branch", "--set-upstream-to", "fork-seed/statemachine"]); + yield* configureVisibleRemoteUrlWithLocalRewrite( + repoDir, + "fork-seed", + "git@github.com:octocat/codething-mvp.git", + forkDir, + ); - const { manager, ghCalls } = yield* makeManager({ - ghScenario: { - prListByHeadSelector: { - // @effect-diagnostics-next-line preferSchemaOverJson:off - "octocat:statemachine": JSON.stringify([ - { - number: 142, - title: "Existing fork PR", - url: "https://github.com/pingdotgg/codething-mvp/pull/142", - baseRefName: "main", - headRefName: "statemachine", - state: "OPEN", - isCrossRepository: true, - headRepository: { - nameWithOwner: "octocat/codething-mvp", - }, - headRepositoryOwner: { - login: "octocat", - }, + const { manager, ghCalls } = yield* makeManager({ + ghScenario: { + prListByHeadSelector: { + // @effect-diagnostics-next-line preferSchemaOverJson:off + "octocat:statemachine": JSON.stringify([ + { + number: 142, + title: "Existing fork PR", + url: "https://github.com/pingdotgg/codething-mvp/pull/142", + baseRefName: "main", + headRefName: "statemachine", + state: "OPEN", + isCrossRepository: true, + headRepository: { + nameWithOwner: "octocat/codething-mvp", }, - ]), - // @effect-diagnostics-next-line preferSchemaOverJson:off - "fork-seed:statemachine": JSON.stringify([]), - // @effect-diagnostics-next-line preferSchemaOverJson:off - "t3code/pr-142/statemachine": JSON.stringify([]), - // @effect-diagnostics-next-line preferSchemaOverJson:off - statemachine: JSON.stringify([]), - }, + headRepositoryOwner: { + login: "octocat", + }, + }, + ]), + // @effect-diagnostics-next-line preferSchemaOverJson:off + "fork-seed:statemachine": JSON.stringify([]), + // @effect-diagnostics-next-line preferSchemaOverJson:off + "t3code/pr-142/statemachine": JSON.stringify([]), + // @effect-diagnostics-next-line preferSchemaOverJson:off + statemachine: JSON.stringify([]), }, - }); + }, + }); - const result = yield* runStackedAction(manager, { - cwd: repoDir, - action: "commit_push_pr", - }); + const result = yield* runStackedAction(manager, { + cwd: repoDir, + action: "commit_push_pr", + }); - expect(result.pr.status).toBe("opened_existing"); - expect(result.pr.number).toBe(142); + expect(result.pr.status).toBe("opened_existing"); + expect(result.pr.number).toBe(142); - const openLookupCalls = ghCalls.filter((call) => call.includes("--state open --limit 1")); - expect(openLookupCalls).toHaveLength(1); - expect(openLookupCalls[0]).toContain( - "pr list --head octocat:statemachine --state open --limit 1", - ); - }), - 12_000, + const openLookupCalls = ghCalls.filter((call) => call.includes("--state open --limit 1")); + expect(openLookupCalls).toHaveLength(1); + expect(openLookupCalls[0]).toContain( + "pr list --head octocat:statemachine --state open --limit 1", + ); + }), ); it.effect("creates PR when one does not already exist", () =>