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>
This commit is contained in:
1 parent
494ef6b9d0
commit
9ce71795b8
38 files changed
+1437
-186
No files matched your search
@@ -0,0 +1,48 @@
|
||||
import { fireEvent, render, screen } from '@testing-library/react'
|
||||
import type { ComponentProps } from 'react'
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import TerminalContextMenu from '../../src/components/terminal/TerminalContextMenu'
|
||||
|
||||
function renderMenu(overrides: Partial<ComponentProps<typeof TerminalContextMenu>> = {}) {
|
||||
const props: ComponentProps<typeof TerminalContextMenu> = {
|
||||
position: { x: 20, y: 20 },
|
||||
hasSelection: false,
|
||||
canSplit: true,
|
||||
canClosePane: true,
|
||||
canCloseTerminal: true,
|
||||
closeLabel: '关闭当前分屏',
|
||||
maximized: false,
|
||||
onClose: vi.fn(),
|
||||
onCopy: vi.fn(),
|
||||
onPaste: vi.fn(),
|
||||
onSelectAll: vi.fn(),
|
||||
onClear: vi.fn(),
|
||||
onSplitRight: vi.fn(),
|
||||
onSplitDown: vi.fn(),
|
||||
onToggleMaximize: vi.fn(),
|
||||
onClosePane: vi.fn(),
|
||||
...overrides,
|
||||
}
|
||||
render(<TerminalContextMenu {...props} />)
|
||||
return props
|
||||
}
|
||||
|
||||
describe('TerminalContextMenu', () => {
|
||||
it('provides standard clipboard and pane actions without browser debug entries', () => {
|
||||
const props = renderMenu()
|
||||
expect(screen.getByRole('menuitem', { name: '复制' })).toBeDisabled()
|
||||
fireEvent.click(screen.getByRole('menuitem', { name: '粘贴' }))
|
||||
expect(props.onPaste).toHaveBeenCalled()
|
||||
expect(screen.queryByText('Reload')).not.toBeInTheDocument()
|
||||
expect(screen.queryByText('Inspect Element')).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('exposes right/down split and the context-aware close action', () => {
|
||||
const props = renderMenu({ hasSelection: true, closeLabel: '关闭当前终端标签' })
|
||||
fireEvent.click(screen.getByRole('menuitem', { name: '向右分屏' }))
|
||||
expect(props.onSplitRight).toHaveBeenCalled()
|
||||
|
||||
renderMenu({ closeLabel: '关闭当前终端标签' })
|
||||
expect(screen.getAllByRole('menuitem', { name: '关闭当前终端标签' })[0]).toBeEnabled()
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user