Files
opsxshell/test/utils/terminalPanes.test.ts
T
Logan.LiandCursor 9ce71795b8 feat: add terminal broadcast, context menu, and shell close
Complete multi-pane broadcast, standard terminal right-click actions, batch host selection with progress, and native ssh_close_shell so closing a pane tears down the remote shell.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-05 19:53:39 +08:00

37 lines
1.3 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import {
resolveTerminalInputTargets,
shouldBroadcastTerminalInput,
} from '../../src/utils/terminalPanes'
const panes = [
{ id: 'left', shellId: 'shell-1' },
{ id: 'starting', shellId: null },
{ id: 'right', shellId: 'shell-3' },
]
describe('terminal pane input routing', () => {
it('routes normal input only to the source pane', () => {
expect(resolveTerminalInputTargets(panes, 'right', false)).toEqual(['shell-3'])
})
it('routes broadcast input to every ready shell in pane order', () => {
expect(resolveTerminalInputTargets(panes, 'left', true)).toEqual([
'shell-1',
'shell-3',
])
})
it('does not write when the source pane has no ready shell', () => {
expect(resolveTerminalInputTargets(panes, 'starting', false)).toEqual([])
expect(resolveTerminalInputTargets(panes, 'missing', false)).toEqual([])
})
it('never broadcasts input originating from a local terminal', () => {
expect(shouldBroadcastTerminalInput(true, true, 'local')).toBe(false)
expect(shouldBroadcastTerminalInput(true, true, 'ssh-connection')).toBe(false)
expect(shouldBroadcastTerminalInput(true, false, 'ssh-connection')).toBe(true)
expect(shouldBroadcastTerminalInput(true, false, null)).toBe(false)
})
})