Restore removal helper bindings and complete test doubles

This commit is contained in:
Brennan Benson
2026-11-12 01:28:59 -08:00
parent 79f5004952
commit 75d820da83
6 changed files with 20 additions and 12 deletions
@@ -327,7 +327,9 @@ it.each([
const enumerateWitnesses = vi.spyOn(witnesses, Symbol.iterator)
const enumerateGlobal = vi.spyOn(pendingWorktreeRemovals, Symbol.iterator)
try {
deps.metaById[records[0].worktreeId] = { displayName: 'changed metadata' } as WorktreeMeta
deps.metaById[records[0].worktreeId] = mergeWorktreeMetaForWrite(undefined, {
displayName: 'changed metadata'
})
joinResolvedWorktreeScans(deps.store, () => deps, scans)
// Unrelated metadata cannot invalidate removal membership: no witness entries need copying.
expect(enumerateWitnesses).not.toHaveBeenCalled()
@@ -5,7 +5,8 @@ import {
splitWorktreeIdForFilesystem,
worktreeIdentityKey
} from '../../../../shared/worktree/id'
import { getRepoExecutionHostId, type ExecutionHostId } from '../../../../shared/execution-host'
import { getRepoExecutionHostId, LOCAL_EXECUTION_HOST_ID } from '../../../../shared/execution-host'
import type { ExecutionHostId } from '../../../../shared/execution-host'
import {
readAllWorktreeMetaForHost,
readWorktreeMetaForHost
@@ -37,7 +38,6 @@ import {
type WorktreeRemovalWitnessScan
} from '../../../workspaces/removal/worktree-removal-listing'
import { pendingWorktreeRemovals } from '../../../workspaces/removal/worktree-removal-table'
import { LOCAL_EXECUTION_HOST_ID } from '../../../../shared/execution-host'
type RepoWorktreeRowStore = Pick<
RuntimeStore,
@@ -126,7 +126,7 @@ describe('durable worktree removal records', () => {
})
const job = interruptedJob()
void startBackgroundWorktreeRemoval({ removal, ...job })
const initial = [{ id: removal.worktreeId }]
const initial: { id: string; hostId?: 'local' }[] = [{ id: removal.worktreeId }]
expect(
projectPendingWorktreeRemovals(
initial,
@@ -228,7 +228,7 @@ describe('durable worktree removal records', () => {
)
const refusal = expect(retried).rejects.toThrow('Could not start deletion')
expect(
projectPendingWorktreeRemovals(
projectPendingWorktreeRemovals<{ id: string; hostId?: 'local' }>(
[{ id: removal.worktreeId }],
(row) => row.id,
true,
@@ -1,5 +1,6 @@
import {
addPendingRemoval,
assertAcceptedBranchChoice,
settlementsByWorktreeId,
waitForPendingWorktreeRemoval,
type RemovalSettlement
@@ -9,7 +10,7 @@ export {
waitForWorktreeRemovalAcceptance,
finishAcceptedWorktreeRemoval
} from './worktree-removal-settlement'
import type { ExecutionHostId } from '../../../shared/execution-host'
import { LOCAL_EXECUTION_HOST_ID, type ExecutionHostId } from '../../../shared/execution-host'
import type { RemoveWorktreeResult } from '../../../shared/worktree/create-types'
import type { GitWorktreeInfo } from '../../../shared/worktree/types'
import { normalizeLocalBranchRef } from '../../git/worktrees/worktree-operation-options'
@@ -59,7 +59,7 @@ export function waitForPendingWorktreeRemoval(
return settlementsByWorktreeId.get(worktreeId)?.result
}
function assertAcceptedBranchChoice(
export function assertAcceptedBranchChoice(
record: WorktreeRemovalRecord | undefined,
deleteBranch: boolean | undefined
): void {
@@ -52,17 +52,22 @@ it('still registers a genuinely unowned file folder and opens it', async () => {
path: '/new/folder',
hostId: 'local'
})
const addRepoPath = vi.fn(async () => {
const addRepoPath = vi.fn<typeof initialState.addRepoPath>(async () => {
useAppStore.setState({ worktreesByRepo: { added: [row] } })
return { id: 'added' }
return {
id: 'added',
path: '/new/folder',
displayName: 'added',
badgeColor: 'blue',
addedAt: 1
}
})
const fetchWorktrees = vi.fn(async () => {})
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: the action reads only the returned repo id; production store actions are not invoked.
const fetchWorktrees = vi.fn().mockResolvedValue(true)
useAppStore.setState({
worktreesByRepo: {},
folderWorkspaces: [],
activeWorktreeId: null,
addRepoPath: addRepoPath as typeof initialState.addRepoPath,
addRepoPath,
fetchWorktrees
})
await expect(