fix(web): Address review findings for M4-LLM integration
- Sanitize user-facing error messages (no raw API/DB errors) - Remove dead try/catch from Chat.tsx handleSendMessage - Add onError callback for persistence errors in useChat - Add console.error logging to loadConversation - Guard minimize/toggleMinimize against closed overlay state - Improve error dedup bucketing for non-DOMException errors - Add tests: non-Error throws, updateConversation failure, minimize/toggleMinimize guards Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -369,6 +369,37 @@ describe("useChatOverlay", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("minimize/toggleMinimize guards", () => {
|
||||
it("should not allow minimize when overlay is closed", () => {
|
||||
const { result } = renderHook(() => useChatOverlay());
|
||||
|
||||
// Overlay starts closed
|
||||
expect(result.current.isOpen).toBe(false);
|
||||
|
||||
act(() => {
|
||||
result.current.minimize();
|
||||
});
|
||||
|
||||
// Should remain unchanged - cannot minimize when closed
|
||||
expect(result.current.isOpen).toBe(false);
|
||||
expect(result.current.isMinimized).toBe(false);
|
||||
});
|
||||
|
||||
it("should not allow toggleMinimize when overlay is closed", () => {
|
||||
const { result } = renderHook(() => useChatOverlay());
|
||||
|
||||
expect(result.current.isOpen).toBe(false);
|
||||
|
||||
act(() => {
|
||||
result.current.toggleMinimize();
|
||||
});
|
||||
|
||||
// Should remain unchanged - cannot toggle minimize when closed
|
||||
expect(result.current.isOpen).toBe(false);
|
||||
expect(result.current.isMinimized).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("storage error handling", () => {
|
||||
it("should call onStorageError when localStorage save fails", () => {
|
||||
const onStorageError = vi.fn();
|
||||
|
||||
Reference in New Issue
Block a user