Skip to content

Commit e3e0b99

Browse files
committed
test(frontend): add unit test coverage for useChatHistory hook #1165
Add renderHook-based integration tests for useChatHistory covering: - Initial state (empty sessions, null currentSessionId, isHistoryOpen) - createNewSession (creation, initial messages, session counting) - updateCurrentSession (message updates, no-op guard, timestamp update) - loadSession (valid/invalid IDs, currentSessionId switching) - deleteSession (removal, clearing active, preserving other sessions) - clearAllHistory (state reset, localStorage removal) - togglePin (pin/unpin, no-op for invalid IDs) - Export functions (JSON and TXT, valid and invalid IDs) - Debounced search (with fake timers, empty/no-match queries) - Unmount cleanup (save and search debounce timeout clearing) - sorted sessions (pinnedSessions, unpinnedSessions, currentSession) - setIsHistoryOpen toggle - reorderPinned ordering - Negative tests for every operation with invalid/missing input Also fixes pre-existing structural issues in the race-condition describe blocks (missing closing braces, nested describe in wrong scope).
1 parent f445c33 commit e3e0b99

1 file changed

Lines changed: 856 additions & 38 deletions

File tree

0 commit comments

Comments
 (0)