From 5b02fd73770998f1dfd210c001198c6b4082db32 Mon Sep 17 00:00:00 2001 From: Brennan Benson <79079362+brennanb2025@users.noreply.github.com> Date: Thu, 12 Nov 2026 23:47:04 -0800 Subject: [PATCH] test: preserve stored workspace rows in orchestration fixture Co-authored-by: Wooseong Kim --- .../worktree-ps-degraded-repo-scan.test.ts | 10 ++++++++-- ...estration-worker-workspace-resolution.unit.test.ts | 11 ++++++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/main/runtime/workspaces/process-listing/worktree-ps-degraded-repo-scan.test.ts b/src/main/runtime/workspaces/process-listing/worktree-ps-degraded-repo-scan.test.ts index ada74807a73..153b27eb53d 100644 --- a/src/main/runtime/workspaces/process-listing/worktree-ps-degraded-repo-scan.test.ts +++ b/src/main/runtime/workspaces/process-listing/worktree-ps-degraded-repo-scan.test.ts @@ -1,5 +1,7 @@ import type * as WorktreeListingModule from '../../../git/worktrees/catalog/worktree-listing' +import { randomUUID } from 'node:crypto' import { beforeEach, describe, expect, it, vi } from 'vitest' +import { mergeWorktreeMetaForWrite } from '../../../persistence/loading-store/worktree-metadata/worktree-meta-write-normalization' const electronMocks = vi.hoisted(() => { const ipcMain = { @@ -103,8 +105,12 @@ function makeStore(options: StoreOptions = {}) { ], getAllWorktreeMeta: vi.fn(() => metaById), getWorktreeMeta: (id: string) => metaById[id], - setWorktreeMeta: ({ id }: HostWorktreeTarget, meta: Partial) => { - metaById[id] = { ...(metaById[id] ?? makeMeta()), ...meta } + setWorktreeMeta: ({ id, hostId }: HostWorktreeTarget, meta: Partial) => { + const existing = metaById[id] + metaById[id] = mergeWorktreeMetaForWrite(existing, meta, { + instanceId: meta.instanceId ?? existing?.instanceId ?? randomUUID(), + hostId + }) return metaById[id] }, removeWorktreeMeta: () => {}, diff --git a/tests/e2e/orchestration-worker-workspace-resolution.unit.test.ts b/tests/e2e/orchestration-worker-workspace-resolution.unit.test.ts index 3ff35ee95ad..ac64d3c9c7a 100644 --- a/tests/e2e/orchestration-worker-workspace-resolution.unit.test.ts +++ b/tests/e2e/orchestration-worker-workspace-resolution.unit.test.ts @@ -1,4 +1,5 @@ import { beforeEach, describe, expect, it, vi } from 'vitest' +import type * as RepoWorktreeResolutionScan from '../../src/main/runtime/workspaces/catalog/repo-worktree-resolution-scan' const electronMocks = vi.hoisted(() => { const ipcMain = { @@ -16,9 +17,13 @@ const electronMocks = vi.hoisted(() => { vi.mock('electron', () => electronMocks) const scanLocalRepoWorktreesForResolution = vi.hoisted(() => vi.fn()) -vi.mock('../../src/main/runtime/workspaces/catalog/repo-worktree-resolution-scan', () => ({ - scanLocalRepoWorktreesForResolution -})) +vi.mock( + '../../src/main/runtime/workspaces/catalog/repo-worktree-resolution-scan', + async (importOriginal) => ({ + ...(await importOriginal()), + scanLocalRepoWorktreesForResolution + }) +) import '../../src/main/runtime/orchestration/db/contract-constants' import '../../src/main/runtime/orchestration/db/messages/mailbox-routing-page'