From c5cf6cbb4ccc5eaba2134424a19bde5d05b39b60 Mon Sep 17 00:00:00 2001 From: "paseo-bot[bot]" <266920839+paseo-bot[bot]@users.noreply.github.com> Date: Sat, 7 Nov 2026 03:01:45 +0000 Subject: [PATCH] test(server): await shared fetch observation readiness (#8975) Snapshot refresh completion does not mean both workspaces have joined the repository fetch target. Wait for observation setup before releasing the first fetch, and retain delayed checkout resolution to exercise that ordering. Co-authored-by: paseo-bot[bot] <266920839+paseo-bot[bot]@users.noreply.github.com> --- .../src/server/workspace-git-service.test.ts | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/packages/server/src/server/workspace-git-service.test.ts b/packages/server/src/server/workspace-git-service.test.ts index d87e896ead..96ca7c333d 100644 --- a/packages/server/src/server/workspace-git-service.test.ts +++ b/packages/server/src/server/workspace-git-service.test.ts @@ -1134,6 +1134,18 @@ describe("WorkspaceGitServiceImpl", () => { }); test("repo-level fetch intervals are shared for workspaces in the same repo", async () => { + // Keep the second workspace's observation setup behind its initial snapshot. + const secondCwd = join(REPO_CWD, "packages", "server"); + const runGitCommand = vi.fn(async (_args, options) => { + if (options.cwd === secondCwd) await delay(250); + return { + stdout: `${REPO_CWD}\n`, + stderr: "", + truncated: false, + exitCode: 0, + signal: null, + }; + }); const firstFetch = createDeferred(); const runGitFetch = vi.fn(async () => { await firstFetch.promise; @@ -1155,6 +1167,7 @@ describe("WorkspaceGitServiceImpl", () => { const resolveAbsoluteGitDir = vi.fn(async () => join(REPO_CWD, ".git")); const service = createService({ + runGitCommand, getCheckoutSnapshotFacts, getCheckoutRefDerivedState, resolveAbsoluteGitDir, @@ -1163,10 +1176,7 @@ describe("WorkspaceGitServiceImpl", () => { }); const first = service.registerWorkspace({ cwd: REPO_CWD }, vi.fn()); - const second = service.registerWorkspace( - { cwd: join(REPO_CWD, "packages", "server") }, - vi.fn(), - ); + const second = service.registerWorkspace({ cwd: secondCwd }, vi.fn()); await vi.waitFor(() => { expect(getCheckoutSnapshotFacts).toHaveBeenCalledTimes(2); expect(runGitFetch).toHaveBeenCalledTimes(1); @@ -1177,6 +1187,8 @@ describe("WorkspaceGitServiceImpl", () => { expect(hasOriginRemote).toHaveBeenCalledTimes(0); expect(runGitFetch).toHaveBeenCalledTimes(1); + await waitForObservationToSettle(service, 2); + firstFetch.resolve(); await flushPromises(); await vi.advanceTimersByTimeAsync(1_000);