test(conversation-memory): improve test coverage for embeddings, summarizer, and MCP handlers - #483
Conversation
…arizer, and MCP handlers - Refactor server.ts to export handler functions for testability - handleSearch(), handleGetObservations(), handleRead(), handleError() - Add comprehensive embeddings.test.ts (33 tests, 100% coverage) - Mock @huggingface/transformers to test actual code execution - Tests for initEmbeddings(), generateEmbedding(), generateExchangeEmbedding() - Add comprehensive summarizer.test.ts (30 tests, 91.08% coverage) - Mock LLM config and provider - Tests for trivial conversation detection, short/long summarization - Tests for token tracking and error handling - Add server.handler.test.ts (27 tests) - Tests for all exported handler functions - Tests for ID conversion, pagination, error cases Coverage improvements: - embeddings.ts: 0% → 100% - summarizer.ts: 0% → 91.08% - server.ts handlers: 0% → 42.54% (handlers fully covered) - Overall: 70.17% → 84.58% Test count: 762 → 815 (+53 tests) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Caution Review failedThe pull request is closed. 📝 WalkthroughWalkthroughThis PR adds comprehensive test coverage to the conversation-memory plugin, refactoring the MCP server to extract handler functions for better testability. It introduces new mocking strategies for embeddings and LLM modules, extensive test scenarios for summarization and search workflows, and handler abstractions in the server with corresponding test suites. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Poem
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Improved test coverage for conversation-memory plugin by creating comprehensive unit tests for three key modules that previously had 0% coverage.
Changes
1. Refactored
src/mcp/server.tshandleSearch()- Search handler with db parameterhandleGetObservations()- Observations handler with ID conversionhandleRead()- Read handler with paginationhandleError()- Error formatting utility2. New
src/core/embeddings.test.ts(33 tests, 100% coverage)@huggingface/transformersto test actual code executioninitEmbeddings(),generateEmbedding(),generateExchangeEmbedding()3. New
src/core/summarizer.test.ts(30 tests, 91.08% coverage)4. New
src/mcp/server.handler.test.ts(27 tests)Coverage Results
embeddings.tssummarizer.tsserver.ts(handlers)*Handler functions fully covered; MCP infrastructure code requires integration testing.
Testing
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Tests
Chores