Skip to content

Conversation

@lobehubbot
Copy link
Member

@lobehubbot lobehubbot commented Dec 26, 2025

Summary

  • Added comprehensive unit tests for packages/const/src/utils/merge
  • Total test files added: 1
  • Test cases added: 37
  • Coverage focus: Both merge and mergeArrayById utility functions with edge cases and error handling

Changes

  • All tests pass successfully (37/37 passing)
  • Business logic coverage improved for merge utilities
  • Edge cases and error handling covered
  • Tests follow existing patterns
  • Type check passes

Module Processed

packages/const/src/utils/merge.ts

Test Coverage

Functions Tested:

  • merge(target, source) - Custom object merge with array replacement
  • mergeArrayById(defaultItems, userItems) - ID-based array merging with metadata preservation

Coverage Type:

Unit tests

Test Approach:

Comprehensive test suite covering:

For merge function:

  • Basic object merging
  • Nested object merging
  • Array replacement behavior (instead of merging)
  • Edge cases (empty objects, null/undefined values)
  • Deep nesting scenarios
  • Mixed data types (booleans, numbers, strings)
  • Non-mutation verification

For mergeArrayById function:

  • Basic ID-based merging with metadata preservation
  • Empty array handling
  • ID matching scenarios (new items, missing items, multiple items)
  • Special value handling (null, undefined, empty objects)
  • Nested object merging within array items
  • Duplicate ID handling
  • No mutation verification
  • Complex real-world scenarios (model configurations)
  • Mixed scenarios with new, updated, and unchanged items

All tests use the Arrange-Act-Assert pattern and follow Vitest best practices.


🤖 Generated with Claude Code

Summary by Sourcery

Tests:

  • Add comprehensive Vitest unit tests for merge and mergeArrayById covering normal behavior, edge cases, and non-mutation guarantees.
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@vercel
Copy link

vercel bot commented Dec 26, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
lobehub Ready Ready Preview, Comment Dec 26, 2025 5:54am
@dosubot dosubot bot added the size:XL This PR changes 500-999 lines, ignoring generated files. label Dec 26, 2025
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Dec 26, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adds a comprehensive Vitest unit test suite for the merge utilities in packages/const/src/utils/merge.ts, focusing on correctness, edge cases, and non-mutation behavior for both merge and mergeArrayById.

File-Level Changes

Change Details Files
Introduce a comprehensive Vitest test suite for merge and mergeArrayById utilities.
  • Add a new test file exercising merge with basic and nested object merging, array replacement semantics, and non-mutation guarantees.
  • Cover edge cases for merge including empty objects, null/undefined values, deep nesting, and mixed primitive types.
  • Add tests for mergeArrayById covering ID-based merging, metadata preservation, empty input handling, new/missing/duplicate IDs, nested object merging within items, and non-mutation.
  • Include complex, realistic scenarios (e.g., model configurations) to validate behavior under mixed new/updated/unchanged items.
  • Ensure tests follow Arrange-Act-Assert structure and existing Vitest conventions used in the repository.
packages/const/src/utils/merge.test.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@gru-agent
Copy link
Contributor

gru-agent bot commented Dec 26, 2025

TestGru Assignment

Summary

Link CommitId Status Reason
Detail e30127e 🚫 Skipped No files need to be tested {"packages/const/src/utils/merge.test.ts":"File path does not match include patterns."}

History Assignment

Tip

You can @gru-agent and leave your feedback. TestGru will make adjustments based on your input

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
@codecov
Copy link

codecov bot commented Dec 26, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.31%. Comparing base (c00dbeb) to head (e30127e).

Additional details and impacted files
@@           Coverage Diff            @@
##             next   #10987    +/-   ##
========================================
  Coverage   80.31%   80.31%            
========================================
  Files         980      980            
  Lines       66983    66983            
  Branches     8780     9151   +371     
========================================
  Hits        53800    53800            
  Misses      13183    13183            
Flag Coverage Δ
app 73.10% <ø> (ø)
database 98.25% <ø> (ø)
packages/agent-runtime 98.08% <ø> (ø)
packages/context-engine 91.61% <ø> (ø)
packages/conversation-flow 98.05% <ø> (ø)
packages/electron-server-ipc 93.76% <ø> (ø)
packages/file-loaders 92.21% <ø> (ø)
packages/model-bank 100.00% <ø> (ø)
packages/model-runtime 89.60% <ø> (ø)
packages/prompts 79.17% <ø> (ø)
packages/python-interpreter 96.50% <ø> (ø)
packages/utils 95.31% <ø> (ø)
packages/web-crawler 96.81% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
Store 73.05% <ø> (ø)
Services 56.44% <ø> (ø)
Server 75.19% <ø> (ø)
Libs 39.30% <ø> (ø)
Utils 82.05% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XL This PR changes 500-999 lines, ignoring generated files.

2 participants