✅ test: add unit test for src/services/session/server.ts #6262
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Trigger Info
Summary
This PR introduces comprehensive unit tests for the
ServerService
class, ensuring robust coverage of its methods and interactions with thelambdaClient
. The key highlights include:Mocking Dependencies: The
lambdaClient
and its methods are mocked usingvitest
to isolate theServerService
logic and test its behavior independently.Test Coverage:
Session Management:
hasSessions
: Verifies if sessions exist.createSession
andbatchCreateSessions
: 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
andremoveAllSessions
: 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
andremoveAllSessionGroups
: Ensures session groups can be deleted, with or without their children.updateSessionGroup
andupdateSessionGroupOrder
: 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 inputTip
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