Files
Logan.Li b0d0e3a5f3 feat(i18n): add multi-language support (ja/ko/vi/ru/zh-TW) with system auto-detection
- 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
2026-08-12 00:07:48 +08:00

55 lines
2.0 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import { isWindowsLocalPath, joinLocalPath, parentPath, splitPathSegments } from '../../src/utils/localPath'
import { fallbackLocalShells, localShellEnterKey } from '../../src/utils/platformShells'
describe('localPath', () => {
it('detects windows paths', () => {
expect(isWindowsLocalPath('C:\\Users\\a')).toBe(true)
expect(isWindowsLocalPath('D:/tmp')).toBe(true)
expect(isWindowsLocalPath('/home/a')).toBe(false)
})
it('computes windows parents without collapsing to /', () => {
expect(parentPath('C:\\Users\\logan\\docs', true)).toBe('C:\\Users\\logan')
expect(parentPath('C:\\Users', true)).toBe('C:\\')
expect(parentPath('C:\\', true)).toBe('C:\\')
})
it('splits windows breadcrumbs with drive root', () => {
const segments = splitPathSegments('C:\\Users\\logan', true)
expect(segments.root).toBe('C:\\')
expect(segments.parts).toEqual(['Users', 'logan'])
expect(segments.join(['Users'])).toBe('C:\\Users')
})
it('keeps posix remote parents', () => {
expect(parentPath('/var/log', false)).toBe('/var')
expect(parentPath('/', false)).toBe('/')
})
it('joins local paths with platform separators', () => {
expect(joinLocalPath('C:\\Users', 'a.txt')).toBe('C:\\Users\\a.txt')
expect(joinLocalPath('/home/a', 'b.txt')).toBe('/home/a/b.txt')
})
})
describe('platformShells', () => {
it('returns windows shells for windows platform', () => {
const shells = fallbackLocalShells('windows')
expect(shells.some((shell) => shell.kind === 'cmd')).toBe(true)
expect(shells.some((shell) => shell.kind === 'pwsh')).toBe(true)
})
it('defaults linux to bash', () => {
const shells = fallbackLocalShells('linux')
expect(shells[0]?.kind).toBe('bash')
expect(shells[0]?.isDefault).toBe(true)
})
it('uses CRLF enter for windows shells', () => {
expect(localShellEnterKey('cmd')).toBe('\r\n')
expect(localShellEnterKey('pwsh')).toBe('\r\n')
expect(localShellEnterKey('bash')).toBe('\r')
})
})