test: mUSD conversion component view test#25169
Conversation
- Add basic component view tests for MusdConversionAssetListCta - Tests verify CTA visibility based on feature flags - Follow component-view testing guidelines (no hook mocking) - Add mock for @metamask/analytics-controller in testSetupView - Add TokensController to wallet preset for asset selector support
- Add component view tests for MusdConversionAssetOverviewCta - Tests verify CTA rendering, text display, and close button behavior - Follow component-view testing guidelines (no hook mocking) - All 10 tests passing (5 for iOS, 5 for Android)
- Add component view tests for EarnMusdConversionEducationView - Tests verify rendering, button interactions, and navigation - Follow component-view testing guidelines (no hook mocking) - All 8 tests passing (4 for iOS, 4 for Android)
- Add tests for MusdConversionAssetOverviewCta: asset allowlist, balance checks, error handling - Add tests for EarnMusdConversionEducationView: navigation, missing params, education state - All 34 tests passing (17 for iOS, 17 for Android) - Follow component-view testing guidelines (no hook mocking)
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
.../components/Musd/MusdConversionAssetOverviewCta/MusdConversionAssetOverviewCta.view.test.tsx
Show resolved
Hide resolved
.../UI/Earn/Views/EarnMusdConversionEducationView/EarnMusdConversionEducationView.view.test.tsx
Outdated
Show resolved
Hide resolved
.../UI/Earn/Views/EarnMusdConversionEducationView/EarnMusdConversionEducationView.view.test.tsx
Outdated
Show resolved
Hide resolved
.../UI/Earn/Views/EarnMusdConversionEducationView/EarnMusdConversionEducationView.view.test.tsx
Show resolved
Hide resolved
.../UI/Earn/Views/EarnMusdConversionEducationView/EarnMusdConversionEducationView.view.test.tsx
Outdated
Show resolved
Hide resolved
- Fix test name that contradicts assertion for allowlist check - Replace weak matcher toBeDefined with proper assertion - Remove weasel word 'handles' from test names - Fix tests that claim to verify dispatch but only check visibility - Add act() wrapper for async button handlers to prevent flaky tests
.../UI/Earn/Views/EarnMusdConversionEducationView/EarnMusdConversionEducationView.view.test.tsx
Show resolved
Hide resolved
.../UI/Earn/Views/EarnMusdConversionEducationView/EarnMusdConversionEducationView.view.test.tsx
Show resolved
Hide resolved
.../UI/Earn/components/Musd/MusdConversionAssetListCta/MusdConversionAssetListCta.view.test.tsx
Show resolved
Hide resolved
.../UI/Earn/Views/EarnMusdConversionEducationView/EarnMusdConversionEducationView.view.test.tsx
Show resolved
Hide resolved
.../UI/Earn/Views/EarnMusdConversionEducationView/EarnMusdConversionEducationView.view.test.tsx
Show resolved
Hide resolved
- Add tests for EarnMusdConversionEducationView component - Add tests for MusdConversionAssetListCta component - Add tests for MusdConversionAssetOverviewCta component All tests validated with mutation testing to ensure assertions are meaningful.
.../UI/Earn/components/Musd/MusdConversionAssetListCta/MusdConversionAssetListCta.view.test.tsx
Outdated
Show resolved
Hide resolved
.../UI/Earn/Views/EarnMusdConversionEducationView/EarnMusdConversionEducationView.view.test.tsx
Outdated
Show resolved
Hide resolved
.../UI/Earn/Views/EarnMusdConversionEducationView/EarnMusdConversionEducationView.view.test.tsx
Outdated
Show resolved
Hide resolved
…support - Remove mocks for @metamask/analytics-controller, analytics utility, and MetaMetrics - Remove mock for @metamask/smart-transactions-controller selector - Add withMinimalAnalyticsController() method to stateFixture - Add AnalyticsController to wallet and bridge presets - Add call() method to controllerMessenger mock for analytics side effects - All controllers now provided via Redux state following component-view test principles
- Rename test to clarify it verifies presentational component behavior - Test name now explicitly states component renders regardless of allowlist - Addresses Cursor Bot feedback about test name clarity
.../components/Musd/MusdConversionAssetOverviewCta/MusdConversionAssetOverviewCta.view.test.tsx
Outdated
Show resolved
Hide resolved
deeb0b2 to
3e7cb46
Compare
- Remove duplicate test 'renders CTA without close button when onDismiss is undefined' - Test 'does not render close button when onDismiss is not provided' already covers this behavior - Addresses Cursor Bot feedback about test duplication
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsAll changes in this PR are related to unit testing infrastructure and new unit tests for the MUSD conversion feature:
Key findings:
Since these changes don't affect any production code or E2E test infrastructure, no E2E test tags need to be run. |
|
Matt561
left a comment
There was a problem hiding this comment.
@racitores This PR recreates existing test files and practically duplicates all tests. What exactly is the purpose of this PR?
| @@ -0,0 +1,487 @@ | |||
| import '../../../../../util/test/component-view/mocks'; | |||
There was a problem hiding this comment.
We have tests for the education view already in app/components/UI/Earn/Views/EarnMusdConversionEducationView/index.test.tsx. Let's move tests from this file that aren't already covered there.
| @@ -0,0 +1,117 @@ | |||
| import '../../../../../../util/test/component-view/mocks'; | |||
There was a problem hiding this comment.
@racitores I noticed you rewrote this file when we already had a test file for the MusdConversionAssetListCta component. What is the reasoning for this?
I think the feature flag gating test cases are new and could be merged into the existing test file.
| @@ -0,0 +1,577 @@ | |||
| import '../../../../../../util/test/component-view/mocks'; | |||
There was a problem hiding this comment.
This entire file has also been replaced and the tests in this version mostly duplicate what we had before.
@Matt561 component-view tests exercise the full view with real Redux/Engine integration (minimal, controlled mocks) and no hook/selector mocking, so they stay closer to real behaviour and are easier to maintain. The overlap with existing unit tests may happen as they were not done previously. We can trim or remove redundant cases from the unit test files once we’re confident in the new coverage from the component view. I hope this make sense |



Description
Added comprehensive component view tests for the following mUSD conversion components:
MusdConversionAssetListCta (3 test cases)
earnMusdCtaEnabledandearnMusdConversionFlowEnabled)MusdConversionAssetOverviewCta (15 test cases)
onDismisscallback)earnMusdConversionAssetOverviewCtaEnabled,earnMusdConversionFlowEnabled,earnMusdConversionCtaTokens)EarnMusdConversionEducationView (12 test cases)
musdConversionEducationSeen)earnMusdConversionFlowEnabled)Changelog
CHANGELOG entry:
Related issues
Fixes:
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Adds comprehensive component-view tests for mUSD conversion UI and strengthens the test harness/mocks for stable execution.
EarnMusdConversionEducationView,MusdConversionAssetListCta, andMusdConversionAssetOverviewCtaincluding feature flag gating, visibility conditions, APY text, route params handling, and interaction (press/close)controllerMessenger.call; state fixture builder addswithMinimalAnalyticsController; wallet/bridge presets include minimal analytics andTokensControllerdefaults; expanded RN/analytics/filesystem mocks intestSetupViewWritten by Cursor Bugbot for commit 0a53be7. This will update automatically on new commits. Configure here.