chat-page-message-map.test.ts
1 import { describe, expect, it } from 'vitest' 2 3 import { 4 moveMessageMapKey, 5 removeMessageMapKey, 6 } from '@/features/chat/components/chat-page/message-map' 7 8 describe('message-map helpers', () => { 9 it('moves pending message scoped state to the persisted assistant id', () => { 10 const previous = { 11 pending_1: { latencyMs: 1200, durationMs: 3400 }, 12 stable: { latencyMs: 900, durationMs: 1000 }, 13 } 14 15 const next = moveMessageMapKey(previous, 'pending_1', 'assistant_1') 16 17 expect(next.pending_1).toBeUndefined() 18 expect(next.assistant_1).toEqual({ latencyMs: 1200, durationMs: 3400 }) 19 expect(next.stable).toEqual({ latencyMs: 900, durationMs: 1000 }) 20 }) 21 22 it('removes message scoped state for deleted placeholders', () => { 23 const previous = { 24 pending_1: ['entry'], 25 keep_1: ['still-here'], 26 } 27 28 const next = removeMessageMapKey(previous, 'pending_1') 29 30 expect(next.pending_1).toBeUndefined() 31 expect(next.keep_1).toEqual(['still-here']) 32 }) 33 })