Skip to content

Conversation

@lobehubbot
Copy link
Member

@lobehubbot lobehubbot commented Dec 9, 2025

Summary

  • Added comprehensive unit tests for multimodalContent utility module
  • Total test files added: 1
  • Test cases added: 25
  • Coverage focus: Serialization/deserialization of multimodal message content parts (text and image)

Changes

  • All tests pass successfully
  • Business logic coverage improved
  • Edge cases and error handling covered
  • Tests follow existing patterns

Module Processed

packages/utils/src/multimodalContent.ts

Test Coverage

  • Functions tested:
    • serializePartsForStorage() - Serializes message content parts to JSON string
    • deserializeParts() - Deserializes JSON string to message content parts
  • Coverage type: Unit tests
  • Test approach:
    • Testing serialization with various content types (text, image, mixed)
    • Testing deserialization with valid and invalid inputs
    • Testing edge cases (empty arrays, special characters, unicode, invalid JSON)
    • Testing round-trip serialization to ensure data integrity
    • Testing error handling for malformed inputs

Key Test Scenarios Covered:

Serialization:

  • Text content parts
  • Image content parts (including long base64 data)
  • Mixed content (text and image)
  • Content with thoughtSignature metadata
  • Empty arrays
  • Special characters and unicode

Deserialization:

  • Valid JSON arrays of text and image parts
  • Invalid inputs (plain text, empty strings, invalid JSON)
  • JSON objects/primitives (not arrays)
  • Empty arrays
  • Arrays without proper type property
  • Special characters and unicode preservation

Round-trip Testing:

  • Data integrity through multiple serialize/deserialize cycles
  • No data loss across transformations

🤖 Generated with Claude Code

Summary by Sourcery

Tests:

  • Add comprehensive unit tests for multimodalContent covering serializePartsForStorage and deserializeParts for text, image, mixed, and edge-case inputs, including invalid and malformed data.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Dec 9, 2025
@vercel
Copy link

vercel bot commented Dec 9, 2025

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

Project Deployment Preview Comments Updated (UTC)
lobehub Ready Ready Preview Comment Dec 9, 2025 5:55am

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Dec 9, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adds a new Jest unit test suite for the multimodalContent utilities, focusing on serialization/deserialization behavior and edge cases for text and image content parts.

File-Level Changes

Change Details Files
Add comprehensive unit tests for multimodal content serialization and deserialization, including edge cases and error handling.
  • Introduce a new test file defining test cases for serializePartsForStorage and deserializeParts covering text, image, mixed, and empty content arrays
  • Verify handling of special characters, unicode, and long base64 image data during serialization and deserialization
  • Add tests for invalid inputs such as non-JSON strings, invalid JSON, non-array JSON values, and arrays with missing or incorrect type fields
  • Include round-trip tests to ensure data integrity across multiple serialize/deserialize cycles and proper error handling for malformed inputs
packages/utils/src/multimodalContent.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 9, 2025

TestGru Assignment

Summary

Link CommitId Status Reason
Detail db110f1 🚫 Skipped No files need to be tested {"packages/utils/src/multimodalContent.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

@dosubot dosubot bot added the javascript Pull requests that update Javascript code label Dec 9, 2025
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 there - 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 9, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.61%. Comparing base (a775f65) to head (db110f1).

Additional details and impacted files
@@           Coverage Diff           @@
##             next   #10689   +/-   ##
=======================================
  Coverage   80.61%   80.61%           
=======================================
  Files         977      978    +1     
  Lines       66574    66587   +13     
  Branches     8769     8809   +40     
=======================================
+ Hits        53667    53680   +13     
  Misses      12907    12907           
Flag Coverage Δ
app 73.06% <ø> (ø)
database 98.32% <ø> (ø)
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 91.66% <ø> (ø)
packages/prompts 79.17% <ø> (ø)
packages/python-interpreter 96.50% <ø> (ø)
packages/utils 95.36% <ø> (+0.05%) ⬆️
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.34% <ø> (ø)
Libs 38.57% <ø> (ø)
Utils 83.36% <ø> (ø)
🚀 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

javascript Pull requests that update Javascript code size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants