Files
lobehub/src/features/Conversation/ChatList/hooks/useConversationSpacer.test.ts
Innei b2122a5224 ♻️ refactor: replace per-message useNewScreen with centralized useConversationSpacer (#13042)
* ♻️ refactor: replace per-message useNewScreen with centralized useConversationSpacer

Replace the old per-message min-height approach with a single spacer element appended to the virtual list, simplifying scroll-to-top UX when user sends a new message.

* 🔧 refactor: streamline handleSendButton logic and enhance editor focus behavior

Removed redundant editor null check and added double requestAnimationFrame calls to ensure the editor is focused after sending a message.

Signed-off-by: Innei <tukon479@gmail.com>

---------

Signed-off-by: Innei <tukon479@gmail.com>
2026-03-17 21:19:58 +08:00

18 lines
679 B
TypeScript

import { describe, expect, it } from 'vitest';
import { calculateConversationSpacerHeight, CONVERSATION_SPACER_ID } from './useConversationSpacer';
describe('useConversationSpacer helpers', () => {
it('should calculate the remaining spacer height behind the latest assistant message', () => {
expect(calculateConversationSpacerHeight(800, 200, 80)).toBe(520);
});
it('should clamp spacer height to zero when content already fills the viewport', () => {
expect(calculateConversationSpacerHeight(800, 300, 600)).toBe(0);
});
it('should keep the reserved spacer id stable', () => {
expect(CONVERSATION_SPACER_ID).toBe('__conversation_spacer__');
});
});