Why: Process output folded on every text delta, successful tool results disappeared after refresh, and generated files stayed plain text instead of a card that opens a closable preview. Evidence: npx tsc -b --noEmit (clean); npx vitest run (51 passed). Impact: Live work stays expanded until the run ends, then folds to one worked-time line. File cards open a per-conversation preview pane. docx renders page by page, with mammoth if that fails. Refs: feature/chat-timeline-preview Co-authored-by: Cursor <cursoragent@cursor.com>
25 lines
1.2 KiB
TypeScript
25 lines
1.2 KiB
TypeScript
import { describe, it, expect } from 'vitest'
|
|
import { openPreviewTab, closePreviewTab } from '../src/previewtabs'
|
|
|
|
describe('preview tabs', () => {
|
|
it('opens a new tab and re-activates an existing one without duplicating it', () => {
|
|
const first = openPreviewTab([], { id: 'a', name: '甲.docx' })
|
|
const second = openPreviewTab(first.tabs, { id: 'b', name: '乙.pptx' })
|
|
expect(second.tabs.map(t => t.id)).toEqual(['a', 'b'])
|
|
expect(second.activeId).toBe('b')
|
|
const again = openPreviewTab(second.tabs, { id: 'a', name: '甲.docx' })
|
|
expect(again.tabs).toHaveLength(2)
|
|
expect(again.activeId).toBe('a')
|
|
})
|
|
|
|
it('closing the active tab selects the neighbor, and closing another keeps the active tab', () => {
|
|
const tabs = [{ id: 'a', name: '甲' }, { id: 'b', name: '乙' }, { id: 'c', name: '丙' }]
|
|
const closedB = closePreviewTab(tabs, 'b', 'b')
|
|
expect(closedB.tabs.map(t => t.id)).toEqual(['a', 'c'])
|
|
expect(closedB.activeId).toBe('c')
|
|
const closedA = closePreviewTab(closedB.tabs, 'c', 'a')
|
|
expect(closedA.activeId).toBe('c')
|
|
expect(closePreviewTab([{ id: 'a', name: '甲' }], 'a', 'a')).toEqual({ tabs: [], activeId: null })
|
|
})
|
|
})
|