hermes-agent/apps/desktop/src/store/preview-status.test.ts
Brooklyn Nicholson d0af7fc954 feat(desktop): detect tool previews into composer status stack
Register previewable artifacts from the tool row, feed a session-scoped store,
and render compact rows above the composer. Remove the inline preview card.
2026-06-22 19:22:11 -05:00

41 lines
1.3 KiB
TypeScript

import { beforeEach, describe, expect, it } from 'vitest'
import {
$previewStatusBySession,
clearPreviewArtifacts,
dismissPreviewArtifact,
recordPreviewArtifact
} from './preview-status'
beforeEach(() => $previewStatusBySession.set({}))
describe('recordPreviewArtifact', () => {
it('appends new targets newest-last and is idempotent', () => {
recordPreviewArtifact('s1', '/a/index.html', '/work')
recordPreviewArtifact('s1', '/a/about.html', '/work')
recordPreviewArtifact('s1', '/a/index.html', '/work')
expect($previewStatusBySession.get().s1.map(i => i.id)).toEqual(['/a/index.html', '/a/about.html'])
})
it('caps the list and derives a label', () => {
for (const n of [1, 2, 3, 4, 5]) {
recordPreviewArtifact('s1', `/a/p${n}.html`, '/work')
}
const list = $previewStatusBySession.get().s1
expect(list).toHaveLength(4)
expect(list[0].id).toBe('/a/p2.html')
expect(list[3].label).toBe('p5.html')
})
it('dismiss and clear remove rows', () => {
recordPreviewArtifact('s1', '/a/index.html', '/work')
recordPreviewArtifact('s1', '/a/about.html', '/work')
dismissPreviewArtifact('s1', '/a/index.html')
expect($previewStatusBySession.get().s1.map(i => i.id)).toEqual(['/a/about.html'])
clearPreviewArtifacts('s1')
expect($previewStatusBySession.get().s1).toBeUndefined()
})
})