import { render, screen } from '@testing-library/react'; import { EntrySelectionDialog } from './EntrySelectionDialog'; describe('EntrySelectionDialog', () => { it('父组件重渲染时不抢走入口按钮焦点,且不暴露无效关闭动作', () => { const entries = [ { path: 'a.xml', label: '模型 A' }, { path: 'b.xml', label: '模型 B' }, ], select = vi.fn(); const { rerender } = render(); const entry = screen.getByRole('button', { name: '模型 A' }); entry.focus(); rerender(); expect(entry).toHaveFocus(); expect(screen.queryByRole('button', { name: '关闭' })).not.toBeInTheDocument(); }); });