test(policy): add unit tests for extractPresetEntries and parseCurrentPolicy#636
test(policy): add unit tests for extractPresetEntries and parseCurrentPolicy#636pjt222 wants to merge 1 commit intoNVIDIA:mainfrom
Conversation
…tPolicy These two exported functions in bin/lib/policies.js had zero test coverage despite being used in the merge path of applyPreset(). Adds 8 tests in 2 new describe blocks: extractPresetEntries (4 tests): - Extracts entries from a real preset (telegram) - Returns null when no network_policies key - Trims trailing whitespace - Returns empty string for empty network_policies section parseCurrentPolicy (4 tests): - Returns empty string for falsy input - Returns raw content when no --- separator - Strips metadata header before --- separator - Splits on first --- only Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdded test coverage for two policy-related functions: Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Summary
extractPresetEntriesandparseCurrentPolicyintest/policies.test.jsapplyPreset()Test plan
node --test test/policies.test.js— 23 tests pass (15 existing + 8 new)Note: The inline merge logic inside
applyPreset()(lines 125-170) is not directly testable without mockingrunCapture/run/registry. Extracting it into amergePresetEntries()helper would enable full coverage — happy to follow up if maintainers are interested.Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com
Summary by CodeRabbit