Skip to content

Conversation

@lobehubbot
Copy link
Member

@lobehubbot lobehubbot commented Dec 25, 2025

💻 Change Type

  • ✨ feat
  • 🐛 fix
  • ♻️ refactor
  • 💄 style
  • 👷 build
  • ⚡️ perf
  • ✅ test
  • 📝 docs
  • 🔨 chore

🔗 Related Issue

Part of ongoing test coverage improvements.

🔀 Description of Change

Added comprehensive unit tests for the StrCompressor class in packages/utils/src/compass.ts.

Summary:

  • Added unit tests for packages/utils/src/compass.ts (String Compressor utility)
  • Total test files added: 1 (compass.test.ts)
  • Test cases added: 35
  • Coverage focus: Compression/decompression functionality, URL-safe base64 encoding, async/sync methods, edge cases

Changes:

  • All tests pass successfully (35/35 passing)
  • Business logic coverage improved
  • Edge cases and error handling covered
  • Tests follow existing patterns in packages/utils
  • Type check passes with no errors

🧪 How to Test

Run the tests:

cd packages/utils && bunx vitest run --silent='passed-only' 'compass.test.ts'

Test coverage includes:

  • Initialization and setup

  • Synchronous compression and decompression

  • Asynchronous compression and decompression

  • Round-trip data integrity (sync and async)

  • URL-safe base64 encoding (no +, /, or = characters)

  • Cross-method compatibility (sync compress + async decompress, etc.)

  • Edge cases: empty strings, Unicode characters, special characters, very long strings, JSON strings

  • Compression effectiveness with various input types

  • Tested locally

  • Added/updated tests

  • No tests needed

📸 Screenshots / Videos

N/A - Test coverage only, no UI changes.

📝 Additional Information

Module Processed: packages/utils/src/compass.ts

Test Approach:

  • Mocked brotli-wasm module to avoid WASM loading issues in test environment
  • Used simple mock compression that preserves data integrity for testing
  • Followed existing test patterns from base64.test.ts and format.test.ts
  • All tests use Vitest with descriptive test names following Arrange-Act-Assert pattern
  • Tests are isolated and independent

Functions tested:

  • init() - Instance initialization
  • compress() - Synchronous compression with URL-safe encoding
  • decompress() - Synchronous decompression
  • compressAsync() - Asynchronous compression
  • decompressAsync() - Asynchronous decompression
  • URL-safe base64 encoding/decoding (private methods tested via public API)
  • Compressor singleton instance

🤖 Generated with Claude Code

Summary by Sourcery

Tests:

  • Introduce compass.test.ts with comprehensive tests for StrCompressor covering sync/async compression and decompression, URL-safe base64 handling, edge cases, and singleton behavior.
🤖 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 25, 2025
@vercel
Copy link

vercel bot commented Dec 25, 2025

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

Project Deployment Review Updated (UTC)
lobehub Error Error Dec 25, 2025 5:48am
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Dec 25, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adds a new Vitest test suite covering the StrCompressor/Compressor utilities in compass.ts, including sync/async compression and decompression, URL-safe base64 behavior, edge cases, and mocking of the underlying brotli-wasm dependency.

File-Level Changes

Change Details Files
Introduce Vitest unit tests for the StrCompressor/Compressor API in compass.ts with a mocked brotli-wasm backend.
  • Create compass.test.ts exercising init, sync compress/decompress, and async compressAsync/decompressAsync flows
  • Verify URL-safe base64 output characteristics and decoding via the public compression API
  • Add round-trip integrity tests across sync/async combinations (e.g., sync compress + async decompress)
  • Cover edge cases like empty strings, long strings, special/unicode characters, and JSON payloads
  • Mock brotli-wasm to provide deterministic, lightweight compression semantics suitable for unit testing
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

@gru-agent
Copy link
Contributor

gru-agent bot commented Dec 25, 2025

TestGru Assignment

Summary

Link CommitId Status Reason
Detail f83813d 🚫 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 - 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 25, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.33%. Comparing base (7a83739) to head (f83813d).
⚠️ Report is 3 commits behind head on next.

Additional details and impacted files
@@            Coverage Diff             @@
##             next   #10958      +/-   ##
==========================================
+ Coverage   75.55%   80.33%   +4.77%     
==========================================
  Files         667      981     +314     
  Lines       46377    67024   +20647     
  Branches     5971    10592    +4621     
==========================================
+ Hits        35041    53841   +18800     
- Misses      11336    13183    +1847     
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.47% <ø> (?)
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% <ø> (+0.59%) ⬆️
🚀 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:L This PR changes 100-499 lines, ignoring generated files.

2 participants