Files
orca/src/shared/execution-host.test.ts
T
OrcaWin 03d572c022 Fix Windows worktree deletion and host labels (#5391)
- close local filesystem watchers before Windows worktree deletion\n- normalize local repo/worktree path comparisons for Windows casing and slashes\n- use platform-aware local host labels\n- remove the Nim highlighting changes; that should land separately via a maintained grammar path\n- add review coverage for pending watcher grace teardown
2026-06-15 17:07:12 -07:00

75 lines
2.8 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import {
ALL_EXECUTION_HOSTS_SCOPE,
LOCAL_EXECUTION_HOST_ID,
getLocalExecutionHostLabel,
getRepoExecutionHostId,
getSettingsFocusedExecutionHostId,
normalizeExecutionHostOrder,
normalizeExecutionHostScope,
normalizeVisibleExecutionHostIds,
parseExecutionHostId,
toRuntimeExecutionHostId,
toSshExecutionHostId
} from './execution-host'
describe('execution host identity', () => {
it('normalizes local, SSH, and runtime host ids', () => {
expect(parseExecutionHostId('local')).toEqual({ kind: 'local', id: 'local' })
expect(parseExecutionHostId(toSshExecutionHostId('win vm'))).toEqual({
kind: 'ssh',
id: 'ssh:win%20vm',
targetId: 'win vm'
})
expect(parseExecutionHostId(toRuntimeExecutionHostId('prod/server'))).toEqual({
kind: 'runtime',
id: 'runtime:prod%2Fserver',
environmentId: 'prod/server'
})
})
it('labels the local host by platform', () => {
expect(getLocalExecutionHostLabel('darwin')).toBe('Local Mac')
expect(getLocalExecutionHostLabel('win32')).toBe('Local Windows')
expect(getLocalExecutionHostLabel('linux')).toBe('Local Linux')
expect(getLocalExecutionHostLabel('freebsd')).toBe('This computer')
})
it('falls back invalid scopes to all hosts', () => {
expect(normalizeExecutionHostScope(null)).toBe(ALL_EXECUTION_HOSTS_SCOPE)
expect(normalizeExecutionHostScope('')).toBe(ALL_EXECUTION_HOSTS_SCOPE)
expect(normalizeExecutionHostScope('bogus')).toBe(ALL_EXECUTION_HOSTS_SCOPE)
expect(normalizeExecutionHostScope('ssh:')).toBe(ALL_EXECUTION_HOSTS_SCOPE)
expect(normalizeExecutionHostScope('all')).toBe(ALL_EXECUTION_HOSTS_SCOPE)
})
it('normalizes visible host id arrays', () => {
expect(normalizeVisibleExecutionHostIds(null)).toBeNull()
expect(normalizeVisibleExecutionHostIds([])).toBeNull()
expect(normalizeVisibleExecutionHostIds(['local', 'bogus', 'ssh:win%20vm', 'local'])).toEqual([
'local',
'ssh:win%20vm'
])
})
it('normalizes host order arrays', () => {
expect(normalizeExecutionHostOrder(null)).toEqual([])
expect(normalizeExecutionHostOrder([])).toEqual([])
expect(normalizeExecutionHostOrder(['ssh:win%20vm', 'bogus', 'local', 'ssh:win%20vm'])).toEqual(
['ssh:win%20vm', 'local']
)
})
it('derives repo ownership from SSH connection ids', () => {
expect(getRepoExecutionHostId({ connectionId: null })).toBe(LOCAL_EXECUTION_HOST_ID)
expect(getRepoExecutionHostId({ connectionId: 'ssh-target-1' })).toBe('ssh:ssh-target-1')
})
it('derives focused host compatibility from active runtime settings', () => {
expect(getSettingsFocusedExecutionHostId(null)).toBe(LOCAL_EXECUTION_HOST_ID)
expect(getSettingsFocusedExecutionHostId({ activeRuntimeEnvironmentId: 'runtime-1' })).toBe(
'runtime:runtime-1'
)
})
})