From 547c0e58096af3ed727d9b250bf088a62823981d Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Fri, 8 May 2026 20:55:01 -0700 Subject: [PATCH] Fix browser VCS status test mocks Co-authored-by: codex --- apps/web/src/components/ChatView.browser.tsx | 38 ++++++++++++++++--- .../components/KeybindingsToast.browser.tsx | 38 ++++++++++++++++--- 2 files changed, 64 insertions(+), 12 deletions(-) diff --git a/apps/web/src/components/ChatView.browser.tsx b/apps/web/src/components/ChatView.browser.tsx index 34b97eba8c..f9a48dbd82 100644 --- a/apps/web/src/components/ChatView.browser.tsx +++ b/apps/web/src/components/ChatView.browser.tsx @@ -65,12 +65,38 @@ import { BrowserWsRpcHarness, type NormalizedWsRpcRequestBody } from "../../test import { DEFAULT_CLIENT_SETTINGS } from "@t3tools/contracts/settings"; -vi.mock("../lib/vcsStatusState", () => ({ - useVcsStatus: () => ({ data: null, error: null, cause: null, isPending: false }), - useVcsStatuses: () => new Map(), - refreshVcsStatus: () => Promise.resolve(null), - resetVcsStatusStateForTests: () => undefined, -})); +vi.mock("../lib/vcsStatusState", () => { + const status = { + data: { + isRepo: true, + sourceControlProvider: { + kind: "github", + name: "GitHub", + baseUrl: "https://github.com", + }, + hasPrimaryRemote: true, + isDefaultRef: true, + refName: "main", + hasWorkingTreeChanges: false, + workingTree: { files: [], insertions: 0, deletions: 0 }, + hasUpstream: true, + aheadCount: 0, + behindCount: 0, + pr: null, + }, + error: null, + cause: null, + isPending: false, + }; + + return { + getVcsStatusSnapshot: () => status, + useVcsStatus: () => status, + useVcsStatuses: () => new Map(), + refreshVcsStatus: () => Promise.resolve(null), + resetVcsStatusStateForTests: () => undefined, + }; +}); const THREAD_ID = "thread-browser-test" as ThreadId; const THREAD_TITLE = "Browser test thread"; diff --git a/apps/web/src/components/KeybindingsToast.browser.tsx b/apps/web/src/components/KeybindingsToast.browser.tsx index e29a008c5d..4320f6ecf4 100644 --- a/apps/web/src/components/KeybindingsToast.browser.tsx +++ b/apps/web/src/components/KeybindingsToast.browser.tsx @@ -33,12 +33,38 @@ import { useStore } from "../store"; import { createAuthenticatedSessionHandlers } from "../../test/authHttpHandlers"; import { BrowserWsRpcHarness } from "../../test/wsRpcHarness"; -vi.mock("../lib/vcsStatusState", () => ({ - useVcsStatus: () => ({ data: null, error: null, cause: null, isPending: false }), - useVcsStatuses: () => new Map(), - refreshVcsStatus: () => Promise.resolve(null), - resetVcsStatusStateForTests: () => undefined, -})); +vi.mock("../lib/vcsStatusState", () => { + const status = { + data: { + isRepo: true, + sourceControlProvider: { + kind: "github", + name: "GitHub", + baseUrl: "https://github.com", + }, + hasPrimaryRemote: true, + isDefaultRef: true, + refName: "main", + hasWorkingTreeChanges: false, + workingTree: { files: [], insertions: 0, deletions: 0 }, + hasUpstream: true, + aheadCount: 0, + behindCount: 0, + pr: null, + }, + error: null, + cause: null, + isPending: false, + }; + + return { + getVcsStatusSnapshot: () => status, + useVcsStatus: () => status, + useVcsStatuses: () => new Map(), + refreshVcsStatus: () => Promise.resolve(null), + resetVcsStatusStateForTests: () => undefined, + }; +}); const THREAD_ID = "thread-kb-toast-test" as ThreadId; const PROJECT_ID = "project-1" as ProjectId;