Skip to content

Conversation

use-tusk[bot]
Copy link
Contributor

@use-tusk use-tusk bot commented Aug 25, 2025

This PR contains 37 unit tests across 4 test files.

Test execution environment: src/app vitest unit tests

These store files and report components handle critical user state and red team reporting UI. The stores manage application-wide state while the report components handle user interactions for security reporting features.

Files tested

  • src/app/src/store/providersStore.ts
  • src/app/src/stores/userStore.ts
  • src/app/src/pages/redteam/report/components/ReportSettingsDialogButton.tsx
  • src/app/src/pages/redteam/report/components/RiskCard.tsx

📈 Coverage gains

Line coverage - avg 98% gain for 4 files
Source file Original After Tusk Gain
src/app/src/store/providersStore.ts 0.00% 100.00% +100.00%
src/app/src/stores/userStore.ts 0.00% 92.50% +92.50%
src/app/src/pages/redteam/report/components/ReportSettingsDialogButton.tsx 0.00% 100.00% +100.00%
src/app/src/pages/redteam/report/components/RiskCard.tsx 0.00% 100.00% +100.00%
Branch coverage - avg 96% gain for 4 files
Source file Original After Tusk Gain
src/app/src/store/providersStore.ts 0.00% 100.00% +100.00%
src/app/src/stores/userStore.ts 0.00% 92.85% +92.85%
src/app/src/pages/redteam/report/components/ReportSettingsDialogButton.tsx 0.00% 100.00% +100.00%
src/app/src/pages/redteam/report/components/RiskCard.tsx 0.00% 92.59% +92.59%

✅ Passing tests (included in this PR)

src/app/src/store/providersStore.test.ts - 8 tests

useProvidersStore

  • useProvidersStore should add a custom provider to customProviders when addCustomProvider is called with a valid ProviderOptions object.
  • useProvidersStore should remove a custom provider from customProviders when removeCustomProvider is called with the provider's id.
  • Consider what happens to custom providers when the application is refreshed or when the store is recreated.
  • Verify that removeCustomProvider behaves correctly when called with an ID that doesn't exist in the customProviders array.
  • Consider what happens when addCustomProvider is called with a provider object that doesn't have an ID property.
  • Verify that addCustomProvider correctly handles a provider with minimal required properties (just an ID) and the UI components can still render it properly.
  • useProvidersStore should have an empty customProviders array on initial state.
  • Consider what happens when addCustomProvider is called with a provider that has the same ID as an existing provider in the customProviders array.
src/app/src/pages/redteam/report/components/ReportSettingsDialogButton.test.tsx - 6 tests

ReportSettingsDialogButton

  • ReportSettingsDialogButton should open the settings dialog when the settings icon button is clicked, displaying the dialog with the title 'Report Settings'.
  • ReportSettingsDialogButton should call setPluginPassRateThreshold with the new value when the slider is moved.
  • ReportSettingsDialogButton should close the settings dialog when the 'Close' button is clicked.
  • ReportSettingsDialogButton should display the current pluginPassRateThreshold value as a percentage in the dialog label.
  • ReportSettingsDialogButton should render the 'Show percentages on risk cards' checkbox as checked or unchecked based on the value of showPercentagesOnRiskCards from the store.
  • Consider what happens when pluginPassRateThreshold is NaN or not a number
src/app/src/pages/redteam/report/components/RiskCard.test.tsx - 13 tests

RiskCard

  • RiskCard should render nothing (return null) if all testTypes have numPassed and numFailed equal to 0.
  • RiskCard should display the provided title, subtitle, and a Gauge with the correct progressValue when given valid testTypes with at least one test.
  • RiskCard should display the correct number of failed probes and the correct passed/total count based on numTestsPassed and numTestsFailed props.
  • RiskCard should render a list of test types with their display names and pass/fail indicators for each filtered testType.
  • RiskCard should open the RiskCategoryDrawer with the correct category and test data when a test type list item is clicked.
  • RiskCard should display a percentage for each test type if showPercentagesOnRiskCards is true, according to the pass rate and pluginPassRateThreshold.
  • RiskCard should apply 'risk-card-percentage-high' class when percentage is greater than or equal to 0.8 and showPercentagesOnRiskCards is true
  • Verify that RiskCard renders correctly when failuresByPlugin and passesByPlugin are empty objects.
  • Verify that clicking on a test type with no failures (numFailed = 0) still opens the RiskCategoryDrawer with appropriate content.
  • Verify that RiskCard renders test types with extremely long names and that these names appear in the document.
  • Verify that RiskCard handles strategyStats containing strategies that don't match any testType names.
  • Consider when progressValue is NaN, verify that the Gauge component displays '-' instead of a percentage.
  • Consider when a test type has a name that doesn't exist in subCategoryDescriptions, verify that the tooltip falls back to 'Click to view details'.
src/app/src/stores/userStore.test.ts - 10 tests

useUserStore

  • useUserStore should set email and isLoading to false when fetchEmail is called and the API returns a successful response with an email.
  • useUserStore should set email to null and isLoading to false when fetchEmail is called and the API returns a 404 response.
  • useUserStore should set userId when fetchUserId is called and fetchUserId resolves successfully.
  • Verify that fetchUserId doesn't make an API call when userId is already present in the state.
  • useUserStore.fetchEmail should return early when email is already set
  • useUserStore should update the email state when setEmail is called with a valid email string.
  • useUserStore should update the userId state when setUserId is called with a valid userId string.
  • Consider what happens when fetchEmail receives a successful response (response.ok is true) but the response contains invalid JSON that cannot be parsed.
  • Verify that fetchEmail sets email to null and isLoading to false when it encounters any error, regardless of error type.
  • useUserStore.fetchEmail should throw and handle an error when API response is not ok and not 404

⚠️ Potential bugs detected

During test generation, CoverBot detected 3 potential bugs in the following files:

src/app/src/pages/redteam/report/components/ReportSettingsDialogButton.tsx

ReportSettingsDialogButton

  • ❌ Verify that the component handles out-of-range values for pluginPassRateThreshold (less than 0 or greater than 1)
    • The ReportSettingsDialogButton component lacks input validation or clamping for the pluginPassRateThreshold value. When a value outside the 0-1 range is provided, it should automatically cap the displayed and stored value to the maximum of 100% (1.0), but instead, it's directly rendering the out-of-range value.
src/app/src/pages/redteam/report/components/RiskCard.tsx

RiskCard

  • ❌ Consider when a category is selected that doesn't exist in the testTypes array, verify that the RiskCategoryDrawer receives appropriate fallback values for numPassed and numFailed.
    • The RiskCard component fails to provide fallback values (0 for numPassed and numFailed) when a selected category is not found in the testTypes array. Instead, it appears to be using the first available test type's values as a default, which is incorrect behavior.
src/app/src/stores/userStore.ts

useUserStore

  • ❌ Verify that fetchUserId correctly handles the case when the external fetchUserId function returns undefined instead of a string or null.
    • The fetchUserId method in the user store lacks proper handling for undefined return values. It should explicitly set userId to null when the external fetchUserId function returns undefined.

Note: The failing tests that surfaced these potential bugs are not included in this PR.


These tests were automatically generated as part of Tusk's coverage-guided testing to increase test coverage for your codebase.

Copy link
Contributor

gru-agent bot commented Aug 25, 2025

TestGru Assignment

Summary

Link CommitId Status Reason
Detail 46ca21c 🚫 Skipped No files need to be tested {"src/app/src/pages/redteam/report/components/ReportSettingsDialogButton.test.tsx":"File path does not match include patterns.","src/app/src/pages/redteam/report/components/RiskCard.test.tsx":"File path does not match include patterns.","src/app/src/store/providersStore.test.ts":"File path does not match include patterns.","src/app/src/stores/userStore.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

mldangelo and others added 4 commits August 25, 2025 17:20
- Add input validation for pluginPassRateThreshold in ReportSettingsDialogButton
- Handle NaN values and clamp out-of-range threshold values (0-1)
- Improve fallback handling for undefined testTypes in RiskCard
- Ensure fetchUserId returns null instead of undefined in userStore
Fix formatting issues in ReportSettingsDialogButton component:
- Format JSX label with proper line breaks and indentation
- Split complex ternary operator in Slider value prop across multiple lines

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@mldangelo mldangelo merged commit 52a2547 into main Aug 27, 2025
34 checks passed
@mldangelo mldangelo deleted the tusk-coverbot-run-src-app-08-25-25-200030 branch August 27, 2025 22:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant