✅ test: add unit test for src/store/aiInfra/slices/aiProvider/selectors.ts #6877
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
aiProviderSelectors
module, ensuring robust validation of its functionality. The tests cover a wide range of scenarios and edge cases, providing confidence in the correctness of the selectors. Below is a summary of the key additions:Added Tests:
enabledAiProviderList
: Verifies that the selector returns a sorted list of enabled AI providers.disabledAiProviderList
: Ensures the selector correctly identifies disabled providers.isProviderEnabled
: Confirms whether a specific provider is enabled.isProviderLoading
: Checks if a provider is currently in a loading state.activeProviderConfig
: Validates retrieval of the active provider's configuration.isAiProviderConfigLoading
: Determines if a provider's configuration is being loaded.isActiveProviderEndpointNotEmpty
: Ensures the active provider has a non-empty endpoint.isActiveProviderApiKeyNotEmpty
: Verifies the presence of API keys or access credentials for the active provider.providerConfigById
: Retrieves the configuration for a provider by its ID.isProviderConfigUpdating
: Checks if a provider's configuration is being updated.isProviderFetchOnClient
: Validates whether a provider fetches data on the client side.providerKeyVaults
: Retrieves key vaults for a specific provider.isProviderHasBuiltinSearch
: Confirms if a provider supports built-in search functionality.isProviderHasBuiltinSearchConfig
: Checks if a provider has an external search configuration.Mock State:
A mock state object was created to simulate various scenarios, including enabled/disabled providers, loading states, and runtime configurations. This ensures the tests are comprehensive and realistic.
Edge Cases:
Providers with missing configurations.
Providers with partial or no key vaults.
Providers with different search modes (
internal
,params
, or none).These tests enhance the reliability of the
aiProviderSelectors
module by ensuring its behavior aligns with expected outcomes across diverse scenarios.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