import { fireEvent, render, screen } from '@testing-library/react' import { describe, expect, it, vi } from 'vitest' 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() 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) }) it('local shell exit never mentions the SSH connection', () => { const reopen = vi.fn() render() expect(screen.getByText('Shell 已退出')).toBeVisible() expect(screen.getByText('重新打开 Shell 即可继续使用本地终端')).toBeVisible() expect(screen.queryByText(/SSH 连接仍可用/)).toBeNull() }) }) describe('connection disconnect overlay', () => { it('explains keepalive failure without calling it a user close', () => { render( ) expect(screen.getByText('心跳失败,连接已断开')).toBeVisible() expect(screen.getByText(/不会向 Shell 发送按键/)).toBeVisible() expect(screen.queryByText(/closed by user/i)).toBeNull() }) })