test: Add full unit coverage for MongoTransform#10560
Conversation
Bring src/Adapters/Storage/Mongo/MongoTransform.js from 88.61% to 100%. Adds unit tests to spec/MongoTransform.spec.js exercising the previously uncovered reachable paths across every exported function: built-in key mapping, date-field coercion in transformWhere / parseObjectToMongoObjectForCreate, transformConstraint error and geo/maxDistance branches, transformUpdate operator validation, and mongoObjectToParseObject atom/pointer/Polygon edge cases. The remaining lines are genuinely unreachable and are marked with /* istanbul ignore */ (code left unchanged): transformInteriorAtom never returns the CannotTransform sentinel, so transformInteriorValue's array/op tail is dead, which in turn makes transformUpdateOperator's flatten=true branches unreachable; and isAllValuesRegexOrNone's empty guard is short-circuited by its only caller.
|
🚀 Thanks for opening this pull request! We appreciate your effort in improving the project. Please let us know once your pull request is ready for review. Tip
Note Please respond to review comments from AI agents just like you would to comments from a human reviewer. Let the reviewer resolve their own comments, unless they have reviewed and accepted your commit, or agreed with your explanation for why the feedback was incorrect. Caution Pull requests must be written using an AI agent with human supervision. Pull requests written entirely by a human will likely be rejected, because of lower code quality, higher review effort and the higher risk of introducing bugs. Please note that AI review comments on this pull request alone do not satisfy this requirement. Our CI and AI review are safeguards, not development tools. If many issues are flagged, rethink your development approach. Invest more effort in planning and design rather than using review cycles to fix low-quality code. |
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 30 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## alpha #10560 +/- ##
==========================================
+ Coverage 92.66% 93.09% +0.43%
==========================================
Files 193 193
Lines 16981 16970 -11
Branches 248 248
==========================================
+ Hits 15736 15799 +63
+ Misses 1224 1150 -74
Partials 21 21 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Issue
src/Adapters/Storage/Mongo/MongoTransform.jssat at 88.61% coverage (74 uncovered lines).Approach
Brings it to 100%, split into two parts:
Real tests for the reachable code (63 lines) - added unit tests to
spec/MongoTransform.spec.js, which already unit-tests the exported transform functions directly. Covers the previously-missed paths across every export: built-in key mapping (sessionToken/lastUsed/timesUsed), date-field coercion intransformWhereandparseObjectToMongoObjectForCreate,transformConstrainterror + geo/$maxDistancebranches,transformUpdateoperator validation, andmongoObjectToParseObjectatom/pointer/Polygon edge cases.istanbul ignorefor the genuinely unreachable code (11 lines, no runtime change).transformInteriorAtomnever returns theCannotTransformsentinel, so the array/__optail oftransformInteriorValueis dead - which in turn makestransformUpdateOperator'sflatten=truebranches unreachable (their only caller is that dead tail).isAllValuesRegexOrNone's empty guard is short-circuited by its only caller (isAnyValueRegex). These are marked withignore if/ignore nextand a reason, leaving the coveredelsebranches still tracked. Verified locally: MongoTransform.js reports 100% (639/639) in the full suite.Tasks