Skip to content

Conversation

@lobehubbot
Copy link
Member

@lobehubbot lobehubbot commented Dec 5, 2025

Summary

  • Added unit tests for StrCompressor class in packages/utils/src/compass.ts
  • Total test files added: 1
  • Test cases added: 32
  • Coverage focus: Comprehensive testing of brotli compression with URL-safe base64 encoding

Changes

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

Module Processed

packages/utils/src/compass.ts

Test Coverage

Functions tested:

  • compress() - Synchronous string compression
  • decompress() - Synchronous string decompression
  • compressAsync() - Asynchronous string compression
  • decompressAsync() - Asynchronous string decompression
  • urlSafeBase64Encode() - URL-safe base64 encoding (private)
  • urlSafeBase64Decode() - URL-safe base64 decoding (private)
  • init() - WASM module initialization
  • Compressor singleton instance

Coverage type:

Unit tests with mocked brotli-wasm dependency

Test approach:

  • Arrange-Act-Assert pattern for clear test structure
  • Mocked WASM dependency using Node.js zlib for reliable testing
  • Comprehensive edge cases: empty strings, unicode, special characters, large data, binary data
  • Round-trip verification: ensure data integrity through compress/decompress cycles
  • Cross-method compatibility: verify sync and async methods produce compatible results
  • URL-safe encoding validation: verify no +, /, or = characters in output

Test categories:

  1. Basic compression/decompression (9 tests) - Simple strings, JSON, unicode, special chars
  2. Async operations (6 tests) - Async compression with various data types
  3. URL-safe base64 encoding (4 tests) - Encoding edge cases and padding
  4. Cross-method compatibility (2 tests) - Sync/async interoperability
  5. Edge cases (6 tests) - Single char, very long strings, binary data, repeated cycles
  6. Initialization (2 tests) - WASM module initialization
  7. Singleton (2 tests) - Singleton instance behavior
  8. Round-trip (1 test) - Comprehensive data preservation test

🤖 Generated with Claude Code

Summary by Sourcery

Add comprehensive unit tests for the Compass string compressor utilities to validate compression, decompression, initialization, and singleton behavior using a mocked brotli-WASM dependency.

Tests:

  • Add a new test suite for Compass string compression utilities covering sync/async compression and decompression, URL-safe base64 encoding/decoding, and round-trip data integrity.
  • Verify edge cases including empty input, unicode and special characters, large and binary payloads, and cross-compatibility between sync and async methods.
  • Test WASM module initialization and the Compressor singleton instance behavior to ensure consistent setup across usages.

Added comprehensive unit tests for the StrCompressor class in packages/utils/src/compass.ts covering:
- Synchronous compress/decompress operations
- Asynchronous compress/decompress operations
- URL-safe base64 encoding/decoding
- Cross-method compatibility
- Edge cases (empty strings, unicode, large data, binary data)
- Round-trip encoding/decoding verification

32 test cases added with 100% coverage of the module's public API.

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

Co-Authored-By: Claude <[email protected]>
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Dec 5, 2025
@vercel
Copy link

vercel bot commented Dec 5, 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 5, 2025 5:52am

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Dec 5, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adds a new Jest test suite for the Compass StrCompressor to exercise all sync/async compression/decompression paths, URL-safe base64 helpers, initialization logic, and singleton behavior using a mocked brotli-wasm dependency for deterministic coverage.

File-Level Changes

Change Details Files
Introduce comprehensive unit tests for StrCompressor covering sync/async compression, URL-safe base64 helpers, initialization, and singleton behavior.
  • Add a Jest test suite that uses Arrange-Act-Assert structure and follows existing project test conventions.
  • Mock the brotli-wasm dependency (backed by Node.js zlib) to make compression/decompression deterministic and independent of the real WASM module.
  • Test compress/decompress and compressAsync/decompressAsync round-trips across basic, Unicode, special-character, JSON, and large-string payloads.
  • Verify URL-safe base64 encoding/decoding guarantees no '+', '/', or '=' characters, including padding and edge cases.
  • Cover edge cases such as empty strings, single characters, very long inputs, binary-like data, and repeated compression/decompression cycles.
  • Exercise init() behavior and the Compressor singleton instance to ensure proper initialization and reuse semantics.
packages/utils/src/compass.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

@dosubot dosubot bot added the javascript Pull requests that update Javascript code label Dec 5, 2025
@gru-agent
Copy link
Contributor

gru-agent bot commented Dec 5, 2025

TestGru Assignment

Summary

Link CommitId Status Reason
Detail 10c0cd2 🚫 Skipped No files need to be tested {"packages/utils/src/compass.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 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 5, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.68%. Comparing base (068d5d3) to head (10c0cd2).
⚠️ Report is 14 commits behind head on next.

Additional details and impacted files
@@            Coverage Diff             @@
##             next   #10615      +/-   ##
==========================================
+ Coverage   80.67%   80.68%   +0.01%     
==========================================
  Files         971      972       +1     
  Lines       66059    66100      +41     
  Branches     8739    10156    +1417     
==========================================
+ Hits        53292    53333      +41     
  Misses      12767    12767              
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.47% <ø> (+0.16%) ⬆️
packages/web-crawler 96.81% <ø> (ø)

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

Components Coverage Δ
Store 73.15% <ø> (ø)
Services 56.44% <ø> (ø)
Server 75.27% <ø> (ø)
Libs 38.40% <ø> (ø)
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