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
This commit is contained in:
1 parent
fea6d8db04
commit
b0d0e3a5f3
301 files changed
+28002
-2705
No files matched your search
@@ -1,7 +1,10 @@
|
||||
import { fireEvent, render, screen, waitFor } from '@testing-library/react'
|
||||
import userEvent from '@testing-library/user-event'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import App from '../../src/app/App'
|
||||
import { useSessionStore } from '../../src/stores/sessionStore'
|
||||
import { decodeBase64ToText } from '../../src/utils/textBase64'
|
||||
import { decryptSessionBackup } from '../../src/utils/sessionBackupCrypto'
|
||||
import { mockDesktopApi } from '../setup'
|
||||
import { unlockProForTests } from '../helpers/entitlement'
|
||||
|
||||
@@ -16,8 +19,9 @@ describe('App foundation acceptance', () => {
|
||||
expect(await screen.findByRole('heading', { name: 'OpsXShell' })).toBeVisible()
|
||||
expect(mockDesktopApi.onMenuOpenSettings).toHaveBeenCalled()
|
||||
|
||||
const title = screen.getByText('OpsXShell', { selector: 'span' })
|
||||
expect(title.closest('header')).toHaveAttribute('data-tauri-drag-region')
|
||||
const titleBar = document.querySelector('header[data-tauri-drag-region]')
|
||||
expect(titleBar).toBeTruthy()
|
||||
expect(titleBar).toHaveAttribute('data-tauri-drag-region')
|
||||
})
|
||||
|
||||
it('renders the shell while the native bridge is unavailable', async () => {
|
||||
@@ -50,8 +54,8 @@ describe('App foundation acceptance', () => {
|
||||
window.opsxApi = mockDesktopApi
|
||||
render(<App />)
|
||||
|
||||
const title = await screen.findByText('OpsXShell', { selector: 'span' })
|
||||
const titleBar = title.closest('header')
|
||||
await screen.findByRole('heading', { name: 'OpsXShell' })
|
||||
const titleBar = document.querySelector('header[data-tauri-drag-region]')
|
||||
expect(titleBar).toHaveAttribute('data-tauri-drag-region')
|
||||
expect(titleBar).not.toHaveClass('titlebar-drag')
|
||||
|
||||
@@ -59,7 +63,8 @@ describe('App foundation acceptance', () => {
|
||||
expect(mockDesktopApi.toggleMaximize).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('writes exported sessions to the selected JSON file', async () => {
|
||||
it('writes encrypted exported sessions to the selected backup file', async () => {
|
||||
const user = userEvent.setup()
|
||||
vi.clearAllMocks()
|
||||
unlockProForTests()
|
||||
vi.mocked(mockDesktopApi.licenseGet).mockResolvedValue({
|
||||
@@ -83,17 +88,39 @@ describe('App foundation acceptance', () => {
|
||||
})
|
||||
vi.mocked(mockDesktopApi.showSaveDialog).mockResolvedValueOnce({
|
||||
canceled: false,
|
||||
filePath: '/tmp/opsxshell-sessions.json',
|
||||
filePath: '/tmp/opsxshell-sessions.bak',
|
||||
})
|
||||
render(<App />)
|
||||
|
||||
await waitFor(() => expect(mockDesktopApi.onMenuExportSessions).toHaveBeenCalled())
|
||||
const callback = vi.mocked(mockDesktopApi.onMenuExportSessions).mock.calls[0][0]
|
||||
await callback()
|
||||
const exportPromise = callback()
|
||||
|
||||
expect(mockDesktopApi.writeFile).toHaveBeenCalledWith(
|
||||
'/tmp/opsxshell-sessions.json',
|
||||
expect.stringContaining('"prod.example.com"')
|
||||
const passwordInput = await screen.findByPlaceholderText('输入备份密码')
|
||||
await user.type(passwordInput, 'backup-secret')
|
||||
await user.click(screen.getByRole('button', { name: '确认' }))
|
||||
|
||||
const confirmInput = await screen.findByPlaceholderText('再次输入备份密码')
|
||||
await user.type(confirmInput, 'backup-secret')
|
||||
await user.click(screen.getByRole('button', { name: '确认' }))
|
||||
|
||||
await exportPromise
|
||||
|
||||
expect(mockDesktopApi.showSaveDialog).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
defaultPath: 'opsxshell-sessions.bak',
|
||||
})
|
||||
)
|
||||
expect(mockDesktopApi.writeFile).toHaveBeenCalledWith(
|
||||
'/tmp/opsxshell-sessions.bak',
|
||||
expect.any(String)
|
||||
)
|
||||
const [, encoded] = vi.mocked(mockDesktopApi.writeFile).mock.calls[0]
|
||||
const decoded = decodeBase64ToText(String(encoded))
|
||||
expect(decoded).toContain('"format": "opsxshell-backup"')
|
||||
expect(decoded).not.toContain('prod.example.com')
|
||||
const envelope = JSON.parse(decoded)
|
||||
const plaintext = await decryptSessionBackup(envelope, 'backup-secret')
|
||||
expect(plaintext).toContain('"prod.example.com"')
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user