test: CoverBot: Added tests for store management and red team reporting components (src/app
)
#5372
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.
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
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
Branch coverage - avg 96% gain for 4 files
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
✅ Passing tests (included in this PR)
src/app/src/store/providersStore.test.ts
- 8 testsuseProvidersStore
useProvidersStore
should add a custom provider tocustomProviders
whenaddCustomProvider
is called with a validProviderOptions
object.useProvidersStore
should remove a custom provider fromcustomProviders
whenremoveCustomProvider
is called with the provider's id.removeCustomProvider
behaves correctly when called with an ID that doesn't exist in the customProviders array.addCustomProvider
is called with a provider object that doesn't have an ID property.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 emptycustomProviders
array on initial state.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 testsReportSettingsDialogButton
ReportSettingsDialogButton
should open the settings dialog when the settings icon button is clicked, displaying the dialog with the title 'Report Settings'.ReportSettingsDialogButton
should callsetPluginPassRateThreshold
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 currentpluginPassRateThreshold
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 ofshowPercentagesOnRiskCards
from the store.src/app/src/pages/redteam/report/components/RiskCard.test.tsx
- 13 testsRiskCard
src/app/src/stores/userStore.test.ts
- 10 testsuseUserStore
During test generation, CoverBot detected 3 potential bugs in the following files:
src/app/src/pages/redteam/report/components/ReportSettingsDialogButton.tsx
ReportSettingsDialogButton
src/app/src/pages/redteam/report/components/RiskCard.tsx
RiskCard
src/app/src/stores/userStore.ts
useUserStore
fetchUserId
method in the user store lacks proper handling forundefined
return values. It should explicitly setuserId
tonull
when the externalfetchUserId
function returnsundefined
.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.