test: MCP config CRUD + Locale utility coverage#369
Conversation
… bug Add 16 tests for MCP config operations (resolveConfigPath, addMcpToConfig, removeMcpFromConfig, listMcpInConfig, findAllConfigPaths) — all previously untested. Add 13 tests for Locale utilities (number, duration, truncateMiddle, pluralize). Discovered and filed #368: Locale.duration >=24h branch has days/hours swapped, always showing "0d Xh". Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> https://claude.ai/code/session_0144wYQpTz6tEZgSYUnzns2A
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
Disabled knowledge base sources:
📝 WalkthroughWalkthroughAdded two new test files covering MCP configuration utilities and Locale formatting functions. The tests validate configuration path resolution, server discovery, configuration mutation operations, and utility functions for numeric/duration formatting, string truncation, and pluralization logic. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
…on_0144wYQpTz6tEZgSYUnzns2A
What does this PR do?
Adds first-ever test coverage for two previously untested modules, and discovers a real bug in
Locale.duration.1.
resolveConfigPath,addMcpToConfig,removeMcpFromConfig,listMcpInConfig,findAllConfigPaths—src/mcp/config.ts(16 new tests)These functions power all MCP server management via the CLI (
mcp add,mcp remove,mcp list) and the datamate tool integration. Zero tests existed despite being actively used. New coverage includes:.altimate-code/>.opencode/> root-levelglobal=trueflag correctly skips subdirectory configsfalsefor missing file or missing server namelistMcpInConfighandles missing file, missingmcpkey, and multiple serversfindAllConfigPathsreturns paths from both project and global dirsfindAllConfigPathsincludes project subdirs (.altimate-code/,.opencode/) but NOT global subdirs2.
Locale.number,Locale.duration,Locale.truncateMiddle,Locale.pluralize—src/util/locale.ts(13 new tests, 1 skipped)These utilities are used across the TUI for session duration display, token count formatting, and text truncation. Zero direct tests existed. New coverage includes:
number(): millions formatting, thousands formatting, boundary at 999999, small numbersduration(): ms, seconds, minutes+seconds, hours+minutes rangestruncateMiddle(): short string passthrough, long string with ellipsis placementpluralize(): singular (count=1) vs plural (count≠1) template substitutionBug discovered:
Locale.duration()has a real bug in the ≥24h branch — days and hours calculations are swapped.days = Math.floor((input % 3600000) / 86400000)always yields 0 because the hour remainder is always less than one day. For example, 25 hours displays as"0d 25h"instead of"1d 1h". Filed as #368. A skipped test documents the correct expected behavior.Type of change
Issue for this PR
How did you verify your code works?
Checklist
https://claude.ai/code/session_0144wYQpTz6tEZgSYUnzns2A
Summary by CodeRabbit