test(server): wait for Git observation before completing fetch

The structural fallback test advanced its debounce timer before asynchronous watcher setup and fetch completion. Wait for those stages so slow filesystem setup does not turn the intended refresh assertion into a scheduling race.
This commit is contained in:
paseo-bot[bot]
2026-10-28 03:36:09 +00:00
parent 2d3a097358
commit 88d2ed8ecb
@@ -1105,12 +1105,23 @@ describe("WorkspaceGitServiceImpl", () => {
{ cwd: join(REPO_CWD, "packages", "server") },
vi.fn(),
);
await vi.waitFor(() => {
expect(getCheckoutSnapshotFacts).toHaveBeenCalledTimes(2);
});
await vi.waitFor(
() => {
expect(getCheckoutSnapshotFacts).toHaveBeenCalledTimes(2);
expect(service.getMetrics()).toMatchObject({
repositoryWorkspaceLinkCount: 2,
workspaceObservationSetupInFlightCount: 0,
workspaceRefreshInFlightCount: 0,
fetchInFlightCount: 1,
});
},
{ timeout: 10_000 },
);
releaseFetch.resolve();
await flushPromises();
await vi.waitFor(() => {
expect(service.getMetrics().fetchInFlightCount).toBe(0);
});
await vi.advanceTimersByTimeAsync(1_000);
await vi.waitFor(() => {
expect(getCheckoutSnapshotFacts).toHaveBeenCalledTimes(4);