Skip to content

Commit 1d79c00

Browse files
Seluj78claude
andcommitted
fix(web): test mocks missing workspace_repos field
Playwright session mocks predate the SessionResponse.workspace_repos field. The new SessionRow chip + multi-repo group hook both read .length on the array, so an undefined value crashed the sidebar render and clickSidebarSession could not find any session row. Add workspace_repos: [] to both mocks. Also harden the two readers with ?.length ?? 0 so future API skew degrades gracefully. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 25c4c75 commit 1d79c00

4 files changed

Lines changed: 4 additions & 2 deletions

File tree

web/src/components/WorkspaceSidebar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ const SessionRow = memo(function SessionRow({
344344
{subtitle}
345345
</span>
346346
)}
347-
{firstSession && firstSession.workspace_repos.length > 1 && (
347+
{firstSession && (firstSession.workspace_repos?.length ?? 0) > 1 && (
348348
<span
349349
className="mt-0.5 flex flex-wrap gap-1 text-[10px] font-mono text-text-dim"
350350
title={firstSession.workspace_repos.map((r) => r.source_path).join("\n")}

web/src/hooks/useRepoGroups.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function loadCollapsed(id: string): boolean {
1313
}
1414

1515
function isMultiRepoWorkspace(ws: Workspace): boolean {
16-
return ws.sessions.some((s) => s.workspace_repos.length > 1);
16+
return ws.sessions.some((s) => (s.workspace_repos?.length ?? 0) > 1);
1717
}
1818

1919
export function useRepoGroups(workspaces: Workspace[]): {

web/tests/helpers/terminal-mocks.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export async function mockTerminalApis(page: Page): Promise<MockHandle> {
3434
is_sandboxed: false,
3535
has_terminal: true,
3636
profile: "default",
37+
workspace_repos: [],
3738
},
3839
],
3940
});

web/tests/ws-reconnect.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ async function mockApisExceptWs(page: Page, sessionTitle: string) {
3434
is_sandboxed: false,
3535
has_terminal: true,
3636
profile: "default",
37+
workspace_repos: [],
3738
},
3839
],
3940
});

0 commit comments

Comments
 (0)