Skip to content

✅ test: add unit test for src/store/aiInfra/slices/aiProvider/selectors.ts #6877

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

Conversation

gru-agent[bot]
Copy link
Contributor

@gru-agent gru-agent bot commented Mar 10, 2025

Trigger Info

Trigger Type Triggered By Source Pull Request Assignment
PR Created curtisrecords 6876 Detail

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:

  1. enabledAiProviderList: Verifies that the selector returns a sorted list of enabled AI providers.

  2. disabledAiProviderList: Ensures the selector correctly identifies disabled providers.

  3. isProviderEnabled: Confirms whether a specific provider is enabled.

  4. isProviderLoading: Checks if a provider is currently in a loading state.

  5. activeProviderConfig: Validates retrieval of the active provider's configuration.

  6. isAiProviderConfigLoading: Determines if a provider's configuration is being loaded.

  7. isActiveProviderEndpointNotEmpty: Ensures the active provider has a non-empty endpoint.

  8. isActiveProviderApiKeyNotEmpty: Verifies the presence of API keys or access credentials for the active provider.

  9. providerConfigById: Retrieves the configuration for a provider by its ID.

  10. isProviderConfigUpdating: Checks if a provider's configuration is being updated.

  11. isProviderFetchOnClient: Validates whether a provider fetches data on the client side.

  12. providerKeyVaults: Retrieves key vaults for a specific provider.

  13. isProviderHasBuiltinSearch: Confirms if a provider supports built-in search functionality.

  14. 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 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

Copy link

vercel bot commented Mar 10, 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) Mar 10, 2025 5:21pm

@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Mar 10, 2025
Copy link

codecov bot commented Mar 10, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.43%. Comparing base (76e1327) to head (00b409d).
Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6877      +/-   ##
==========================================
+ Coverage   91.36%   91.43%   +0.06%     
==========================================
  Files         729      729              
  Lines       68681    68681              
  Branches     3344     3361      +17     
==========================================
+ Hits        62751    62799      +48     
+ Misses       5930     5882      -48     
Flag Coverage Δ
app 91.43% <ø> (+0.06%) ⬆️
server 97.57% <ø> (ø)

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.

🚀 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.

@arvinxx arvinxx closed this Mar 11, 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.

1 participant