chore: 保存工作副本——客户端授权新契约(双端点/验签/令牌/周检)与桌面会话可靠性改进
This commit is contained in:
1 parent
f71eef0eba
commit
ae6093c9b3
163 files changed
+4911
-2494
No files matched your search
@@ -1,6 +1,6 @@
|
||||
import { beforeEach, describe, expect, it } from 'vitest'
|
||||
import i18n from '../../src/i18n'
|
||||
import { translateErrorMessage } from '../../src/i18n/format'
|
||||
import { translateErrorMessage, translateIpcError } from '../../src/i18n/format'
|
||||
|
||||
describe('translateErrorMessage — SFTP real-device phrases', () => {
|
||||
beforeEach(async () => {
|
||||
@@ -34,6 +34,13 @@ describe('translateErrorMessage — SFTP real-device phrases', () => {
|
||||
'建立远程端口转发失败: 远端拒绝监听特权端口 80(需 root 或改用 ≥1024;另请确认 AllowTcpForwarding / PermitListen,且端口未被占用)。可用命令行核对:ssh -R 80:127.0.0.1:<本地端口> user@host',
|
||||
'errors:forward.remoteDeniedPrivileged',
|
||||
],
|
||||
['closed by user', 'errors:connection.unexpectedDropped'],
|
||||
['connection closed', 'errors:connection.unexpectedDropped'],
|
||||
['keepalive failed', 'errors:connection.keepaliveFailed'],
|
||||
['shell.idleTimeout', 'errors:connection.idleKicked'],
|
||||
['shell.exited', 'errors:connection.shellExited'],
|
||||
['命令已终止', 'ai:step.terminated'],
|
||||
['command cancelled', 'ai:step.terminated'],
|
||||
])('maps %s', (raw, key) => {
|
||||
expect(translateErrorMessage(raw)).toBe(i18n.t(key))
|
||||
})
|
||||
@@ -42,3 +49,18 @@ describe('translateErrorMessage — SFTP real-device phrases', () => {
|
||||
expect(translateErrorMessage('weird native blip 0xdead')).toBe('weird native blip 0xdead')
|
||||
})
|
||||
})
|
||||
|
||||
describe('translateIpcError', () => {
|
||||
beforeEach(async () => {
|
||||
await i18n.changeLanguage('zh-CN')
|
||||
})
|
||||
|
||||
it('maps a stable errorCode before the raw phrase', () => {
|
||||
expect(translateIpcError('ignored', 'native.taskJoin')).toBe(i18n.t('errors:native.taskJoin'))
|
||||
expect(translateIpcError('native.invalidBase64')).toBe(i18n.t('errors:native.invalidBase64'))
|
||||
})
|
||||
|
||||
it('falls back to phrase matching when the code is unknown', () => {
|
||||
expect(translateIpcError('Permission denied', 'not.a.real.code')).toBe(i18n.t('errors:sftp.permissionDenied'))
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user