// 空态点工件无反应(2026-10-10 实测复现):requestPreview 写 '_' 键、渲染判 // currentConvId 非空——键口径不一致导致空态点击只剩弹层关闭。这里测纯函数口径。 import { describe, expect, it } from 'vitest' import { mergeOrphanPreviewTabs, previewTabsKey } from '../src/previewtabs' describe('previewTabsKey', () => { it('falls back to the empty-state key when no conversation is selected', () => { expect(previewTabsKey(null)).toBe('_') expect(previewTabsKey(undefined)).toBe('_') expect(previewTabsKey('cnv_1')).toBe('cnv_1') }) }) describe('mergeOrphanPreviewTabs', () => { it('merges empty-state tabs into the conversation key and clears the orphan key', () => { const got = mergeOrphanPreviewTabs({ _: [{ id: 'a', name: 'A.docx' }, { id: 'b', name: 'B.md' }], cnv_1: [{ id: 'b', name: 'B.md' }], }, 'cnv_1') expect(got._).toEqual([]) expect(got.cnv_1.map(t => t.id)).toEqual(['b', 'a']) }) it('returns the input untouched when there is no orphan or the target is the orphan key', () => { const none = { cnv_1: [{ id: 'a', name: 'A' }] } expect(mergeOrphanPreviewTabs(none, 'cnv_1')).toBe(none) const self = { _: [{ id: 'a', name: 'A' }] } expect(mergeOrphanPreviewTabs(self, '_')).toBe(self) }) })