- Extend AppLanguage to 7 locales: zh-CN, zh-TW, en, ja, ko, vi, ru - Auto-detect system language via navigator.languages; fallback to English - Add BCP47 locale mapping for date formatting and sorting - Create 50 translation JSON files (5 languages × 10 namespaces, 1137 keys each) - Update language selector with native language names - Extend locale key parity test to cover all 7 languages (70 assertions) - Add VNC/RDP desktop, serial terminal, AI agent, port forwarding, and SFTP features - Add credential encryption, host metrics, session backup crypto, and zmodem bridge - Update Rust backend: desktop services, host metrics, SSH/SFTP enhancements
81 lines
3.1 KiB
TypeScript
81 lines
3.1 KiB
TypeScript
import { beforeEach, describe, expect, it } from 'vitest'
|
|
import {
|
|
getTerminalBroadcastTargets,
|
|
selectBroadcastTargetCount,
|
|
terminalBroadcastTargetCount,
|
|
useTerminalBroadcastStore,
|
|
} from '../../src/stores/terminalBroadcastStore'
|
|
|
|
describe('terminal broadcast store', () => {
|
|
beforeEach(() => useTerminalBroadcastStore.getState().reset())
|
|
|
|
it('defaults scope to current-tab', () => {
|
|
expect(useTerminalBroadcastStore.getState().scope).toBe('current-tab')
|
|
})
|
|
|
|
it('collects ready shells from every open terminal workspace when scope is all', () => {
|
|
const store = useTerminalBroadcastStore.getState()
|
|
store.setScope('all')
|
|
store.registerWorkspace({
|
|
tabId: 'tab-a',
|
|
targets: [
|
|
{ tabId: 'tab-a', paneId: 'left', shellId: 'shell-a', connectionId: 'conn-a', label: 'Host A' },
|
|
{ tabId: 'tab-a', paneId: 'right', shellId: 'shell-b', connectionId: 'conn-a', label: 'Host A' },
|
|
],
|
|
})
|
|
store.registerWorkspace({
|
|
tabId: 'tab-b',
|
|
targets: [
|
|
{ tabId: 'tab-b', paneId: 'main', shellId: 'shell-c', connectionId: 'local', label: 'Local' },
|
|
],
|
|
})
|
|
|
|
expect(getTerminalBroadcastTargets().map((target) => target.shellId)).toEqual([
|
|
'shell-a',
|
|
'shell-b',
|
|
'shell-c',
|
|
])
|
|
expect(terminalBroadcastTargetCount(useTerminalBroadcastStore.getState())).toBe(3)
|
|
expect(selectBroadcastTargetCount('tab-a')(useTerminalBroadcastStore.getState())).toBe(3)
|
|
|
|
useTerminalBroadcastStore.getState().unregisterWorkspace('tab-a')
|
|
expect(getTerminalBroadcastTargets().map((target) => target.shellId)).toEqual(['shell-c'])
|
|
})
|
|
|
|
it('limits targets to the source tab when scope is current-tab', () => {
|
|
const store = useTerminalBroadcastStore.getState()
|
|
store.registerWorkspace({
|
|
tabId: 'tab-a',
|
|
targets: [
|
|
{ tabId: 'tab-a', paneId: 'left', shellId: 'shell-a', connectionId: 'conn-a', label: 'Host A' },
|
|
{ tabId: 'tab-a', paneId: 'right', shellId: 'shell-b', connectionId: 'conn-a', label: 'Host A' },
|
|
],
|
|
})
|
|
store.registerWorkspace({
|
|
tabId: 'tab-b',
|
|
targets: [
|
|
{ tabId: 'tab-b', paneId: 'main', shellId: 'shell-c', connectionId: 'conn-b', label: 'Host B' },
|
|
],
|
|
})
|
|
|
|
expect(getTerminalBroadcastTargets('tab-a').map((t) => t.shellId)).toEqual(['shell-a', 'shell-b'])
|
|
expect(getTerminalBroadcastTargets('tab-b').map((t) => t.shellId)).toEqual(['shell-c'])
|
|
const latest = useTerminalBroadcastStore.getState()
|
|
expect(selectBroadcastTargetCount('tab-a')(latest)).toBe(2)
|
|
expect(selectBroadcastTargetCount('tab-b')(latest)).toBe(1)
|
|
// Without source tab id, current-tab must not silently expand to all tabs
|
|
expect(getTerminalBroadcastTargets()).toEqual([])
|
|
})
|
|
|
|
it('deduplicates a shell defensively', () => {
|
|
useTerminalBroadcastStore.getState().registerWorkspace({
|
|
tabId: 'tab-a',
|
|
targets: [
|
|
{ tabId: 'tab-a', paneId: 'a', shellId: 'shared', connectionId: 'conn-a', label: 'A' },
|
|
{ tabId: 'tab-a', paneId: 'b', shellId: 'shared', connectionId: 'conn-a', label: 'A' },
|
|
],
|
|
})
|
|
expect(getTerminalBroadcastTargets('tab-a')).toHaveLength(1)
|
|
})
|
|
})
|