Files
orca/src/shared/remote-execution-host-pty-id.test.ts
T
Neil e1eef1f162 refactor(terminal): one isRemoteExecutionHostPtyId, on prefix semantics (#30232)
The shared copy parsed remote: ids fully, so a malformed or newer-format id read as local
to pty-running-work-probe. The renderer copy already used the prefix check; it is now the
only definition, in src/shared.
2026-10-18 00:15:22 -07:00

37 lines
1.5 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import { toRemoteRuntimePtyId } from './remote-runtime-pty-id'
import { toAppSshPtyId } from './ssh-pty-id'
import { isRemoteExecutionHostPtyId } from './remote-execution-host-pty-id'
describe('isRemoteExecutionHostPtyId', () => {
it('accepts paired-runtime ptys with and without an owner environment', () => {
expect(isRemoteExecutionHostPtyId(toRemoteRuntimePtyId('term_1', 'env-a'))).toBe(true)
expect(isRemoteExecutionHostPtyId(toRemoteRuntimePtyId('term_1'))).toBe(true)
})
// Why: decoding fails on a malformed owner, but the id still names a remote pty.
it('keeps a malformed or newer-format remote id remote', () => {
expect(isRemoteExecutionHostPtyId('remote:%E0%A4%A@@term_1')).toBe(true)
expect(isRemoteExecutionHostPtyId('remote:v2|env|term_1')).toBe(true)
})
it('accepts direct-SSH app pty ids', () => {
expect(isRemoteExecutionHostPtyId(toAppSshPtyId('target-1', 'pty-1'))).toBe(true)
})
it('rejects local ptys, empty ids, and absent ids', () => {
expect(isRemoteExecutionHostPtyId('worktree-1|pane-1')).toBe(false)
expect(isRemoteExecutionHostPtyId('')).toBe(false)
expect(isRemoteExecutionHostPtyId(null)).toBe(false)
expect(isRemoteExecutionHostPtyId(undefined)).toBe(false)
})
// Why: a bare "ssh:" id with no relay separator names no connection, so it is
// not evidence the request crosses a link.
it('rejects an ssh-prefixed id that carries no relay pty id', () => {
expect(isRemoteExecutionHostPtyId('ssh:target-1')).toBe(false)
})
})