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:
@@ -176,22 +176,19 @@ describe("Chat", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("sendMessage error handling", () => {
|
||||
it("should log error when sendMessage fails", async () => {
|
||||
const sendError = new Error("Send failed");
|
||||
const mockSendMessage = vi.fn().mockRejectedValue(sendError);
|
||||
describe("sendMessage delegation", () => {
|
||||
it("should delegate to useChat.sendMessage without extra error handling", async () => {
|
||||
const mockSendMessage = vi.fn().mockResolvedValue(undefined);
|
||||
mockUseChat.mockReturnValue(createMockUseChatReturn({ sendMessage: mockSendMessage }));
|
||||
|
||||
const ref = createRef<ChatRef>();
|
||||
const { getByTestId } = render(<Chat ref={ref} />);
|
||||
|
||||
// Click the send button (which calls handleSendMessage)
|
||||
const sendButton = getByTestId("chat-input");
|
||||
sendButton.click();
|
||||
|
||||
// Wait for async handling
|
||||
await vi.waitFor(() => {
|
||||
expect(consoleSpy).toHaveBeenCalledWith("Error sending message:", sendError);
|
||||
expect(mockSendMessage).toHaveBeenCalledWith("test message");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user