chore: 保存工作副本——客户端授权新契约(双端点/验签/令牌/周检)与桌面会话可靠性改进

This commit is contained in:
Logan.Li committed 2026-09-14 22:10:22 +08:00
1 parent f71eef0eba
commit ae6093c9b3
163 files changed
+4911 -2494

No files matched your search

+23 -2
View File
@@ -1,13 +1,14 @@
import { fireEvent, render, screen } from '@testing-library/react'
import { describe, expect, it, vi } from 'vitest'
import { ShellClosedOverlay } from '../../src/components/terminal/TerminalOverlay'
import TerminalOverlay, { ShellClosedOverlay } from '../../src/components/terminal/TerminalOverlay'
describe('remote shell close recovery', () => {
it('explains remote TMOUT without claiming the pooled SSH connection is dead', () => {
const reopen = vi.fn()
render(<ShellClosedOverlay reason="远端 Shell 因空闲策略(TMOUT)自动退出" idleTimeout onReopen={reopen} />)
render(<ShellClosedOverlay reason="shell.idleTimeout" idleTimeout onReopen={reopen} />)
expect(screen.getByText('空闲超时,Shell 已退出')).toBeVisible()
expect(screen.getByText('远端 Shell 因空闲超时退出(TMOUT)')).toBeVisible()
expect(screen.getByText(/SSH 连接仍可用/)).toBeVisible()
fireEvent.click(screen.getByRole('button', { name: '重新打开 Shell' }))
expect(reopen).toHaveBeenCalledTimes(1)
@@ -22,3 +23,23 @@ describe('remote shell close recovery', () => {
expect(screen.queryByText(/SSH 连接仍可用/)).toBeNull()
})
})
describe('connection disconnect overlay', () => {
it('explains keepalive failure without calling it a user close', () => {
render(
<TerminalOverlay
connectionState="disconnected"
statusMessage=""
showSuspendedOverlay={false}
needsReconnect
disconnectKind="keepalive"
onReconnect={vi.fn()}
onResume={vi.fn()}
/>
)
expect(screen.getByText('心跳失败,连接已断开')).toBeVisible()
expect(screen.getByText(/不会向 Shell 发送按键/)).toBeVisible()
expect(screen.queryByText(/closed by user/i)).toBeNull()
})
})