Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✅ test: add unit test for src/services/session/server.ts #6262

Closed

Conversation

gru-agent[bot]
Copy link
Contributor

@gru-agent gru-agent bot commented Feb 17, 2025

Trigger Info

Trigger Type Triggered By Source File Assignment
Push arvinxx src/services/session/server.ts Detail

Summary

This PR introduces comprehensive unit tests for the ServerService class, ensuring robust coverage of its methods and interactions with the lambdaClient. The key highlights include:

  • Mocking Dependencies: The lambdaClient and its methods are mocked using vitest to isolate the ServerService logic and test its behavior independently.

  • Test Coverage:

    • Session Management:

      • hasSessions: Verifies if sessions exist.

      • createSession and batchCreateSessions: Tests session creation and batch creation functionality.

      • cloneSession: Ensures sessions can be cloned with a new title.

      • getGroupedSessions, countSessions, rankSessions: Validates session retrieval, counting, and ranking.

      • updateSession: Confirms session updates, including metadata and group changes.

      • getSessionConfig, updateSessionConfig, updateSessionChatConfig: Tests retrieval and updates of session configurations.

      • searchSessions: Ensures sessions can be searched by keywords.

      • removeSession and removeAllSessions: Validates session deletion functionality.

    • Session Group Management:

      • createSessionGroup: Tests creation of session groups with name and sort order.

      • getSessionGroups: Verifies retrieval of session groups.

      • removeSessionGroup and removeAllSessionGroups: Ensures session groups can be deleted, with or without their children.

      • updateSessionGroup and updateSessionGroupOrder: Confirms updates to session group details and order.

  • Parameter Validation: Ensures correct parameters are passed to the mocked lambdaClient methods.

  • Signal Handling: Tests methods that accept an AbortController signal for request cancellation.

This PR ensures the ServerService class is well-tested, improving reliability and maintainability.

Tip

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

Tip

You can @gru-agent rebase to rebase the PR.

Tip

You can @gru-agent redo to reset or rebase before redoing the PR.

Tip

To modify the test code yourself, click here Edit Test Code

@gru-agent gru-agent bot requested a review from arvinxx February 17, 2025 10:34
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Feb 17, 2025
Copy link

vercel bot commented Feb 17, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Updated (UTC)
lobe-chat-preview ⬜️ Ignored (Inspect) Feb 17, 2025 10:34am

@lobehubbot
Copy link
Member

👍 @gru-agent[bot]

Thank you for raising your pull request and contributing to our Community
Please make sure you have followed our contributing guidelines. We will review it as soon as possible.
If you encounter any problems, please feel free to connect with us.
非常感谢您提出拉取请求并为我们的社区做出贡献,请确保您已经遵循了我们的贡献指南,我们会尽快审查它。
如果您遇到任何问题,请随时与我们联系。

Copy link

codecov bot commented Feb 17, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.87%. Comparing base (1fc7ca6) to head (6d2af5e).
Report is 13 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6262      +/-   ##
==========================================
+ Coverage   91.69%   91.87%   +0.17%     
==========================================
  Files         681      681              
  Lines       62120    62120              
  Branches     2886     3086     +200     
==========================================
+ Hits        56964    57071     +107     
+ Misses       5156     5049     -107     
Flag Coverage Δ
app 91.87% <ø> (+0.17%) ⬆️
server 97.90% <ø> (ø)

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@arvinxx arvinxx closed this Feb 17, 2025
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants