Skip to content

test: mUSD conversion component view test#25169

Merged
racitores merged 13 commits intomainfrom
raci/musd-conversion-component-view-test
Jan 30, 2026
Merged

test: mUSD conversion component view test#25169
racitores merged 13 commits intomainfrom
raci/musd-conversion-component-view-test

Conversation

@racitores
Copy link
Copy Markdown
Contributor

@racitores racitores commented Jan 26, 2026

Description

Added comprehensive component view tests for the following mUSD conversion components:

  1. MusdConversionAssetListCta (3 test cases)

    • Feature flag visibility logic (earnMusdCtaEnabled and earnMusdConversionFlowEnabled)
    • Component behavior when visibility conditions are not met
    • Graceful handling when component returns null
  2. MusdConversionAssetOverviewCta (15 test cases)

    • Component rendering with different asset configurations (USDC, DAI, USDT)
    • CTA text content verification (title and description)
    • Close button visibility and interaction (onDismiss callback)
    • Presentational component behavior (renders regardless of allowlist - logic handled by parent)
    • Asset balance scenarios (above minimum, low balance)
    • Multi-chain support (different chainIds)
    • Edge cases (missing asset address, assets not in allowlist)
    • Feature flag configuration (earnMusdConversionAssetOverviewCtaEnabled, earnMusdConversionFlowEnabled, earnMusdConversionCtaTokens)
  3. EarnMusdConversionEducationView (12 test cases)

    • Complete UI rendering (heading, description, primary and secondary buttons)
    • APY percentage display in heading and description
    • Button interaction states (go back and continue buttons remain visible after press)
    • Route parameter handling (missing params, partial params, complete params)
    • Education seen state management (musdConversionEducationSeen)
    • Feature flag configuration (earnMusdConversionFlowEnabled)

Changelog

CHANGELOG entry:

Related issues

Fixes:

Manual testing steps

Feature: my feature name

  Scenario: user [verb for user action]
    Given [describe expected initial app state]

    When user [verb for user action]
    Then [describe expected outcome]

Screenshots/Recordings

Before

After

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Note

Adds comprehensive component-view tests for mUSD conversion UI and strengthens the test harness/mocks for stable execution.

  • New tests cover EarnMusdConversionEducationView, MusdConversionAssetListCta, and MusdConversionAssetOverviewCta including feature flag gating, visibility conditions, APY text, route params handling, and interaction (press/close)
  • Test utilities enhanced: Engine mock gains controllerMessenger.call; state fixture builder adds withMinimalAnalyticsController; wallet/bridge presets include minimal analytics and TokensController defaults; expanded RN/analytics/filesystem mocks in testSetupView

Written by Cursor Bugbot for commit 0a53be7. This will update automatically on new commits. Configure here.

- 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)
@racitores racitores requested a review from a team as a code owner January 26, 2026 11:35
@github-actions
Copy link
Copy Markdown
Contributor

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.

@metamaskbot metamaskbot added the team-qa QA team label Jan 26, 2026
- 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
@racitores racitores added the skip-e2e skip E2E test jobs label Jan 26, 2026
@racitores racitores added the no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed label Jan 26, 2026
- 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.
@github-actions github-actions bot added size-XL and removed size-L labels Jan 26, 2026
…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
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

@racitores racitores force-pushed the raci/musd-conversion-component-view-test branch from deeb0b2 to 3e7cb46 Compare January 26, 2026 17:30
- 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
@github-actions
Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: None (no tests recommended)
  • Risk Level: low
  • AI Confidence: 95%
click to see 🤖 AI reasoning details

All changes in this PR are related to unit testing infrastructure and new unit tests for the MUSD conversion feature:

  1. New Unit Test Files (3 files): These are new .view.test.tsx files that test MUSD conversion components (EarnMusdConversionEducationView, MusdConversionAssetListCta, MusdConversionAssetOverviewCta). These are Jest unit tests, not Detox E2E tests.

  2. Unit Test Infrastructure Updates (5 files): Changes to app/util/test/component-view/ utilities:

    • mocks.ts: Added call method to Engine mock for analytics
    • stateFixture.ts: Added withMinimalAnalyticsController() builder method
    • presets/wallet.ts and presets/bridge.ts: Added analytics controller and TokensController state
    • testSetupView.js: Trivial whitespace change

Key findings:

  • The component-view test utilities are only imported by unit test files (.test.tsx), not E2E tests
  • No E2E tests exist for MUSD/Earn features (verified via grep)
  • No production application code was modified
  • All changes are isolated to the unit testing layer

Since these changes don't affect any production code or E2E test infrastructure, no E2E test tags need to be run.

View GitHub Actions results

@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown
Contributor

@Matt561 Matt561 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This entire file has also been replaced and the tests in this version mostly duplicate what we had before.

@racitores
Copy link
Copy Markdown
Contributor Author

racitores commented Jan 28, 2026

@racitores This PR recreates existing test files and practically duplicates all tests. What exactly is the purpose of this PR?

@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.
Beside that, a unified Jest testing approach for view-level tests (the component-view framework) simplifies maintenance and gives the project a common way to write and reason about tests at scale. Unit tests still have a clear role for scenarios where component-view isn’t suitable—for example when we need to mock hooks or selectors, or test logic in isolation that the component-view rules don’t allow.

I hope this make sense

@racitores racitores requested a review from Matt561 January 28, 2026 17:59
@racitores racitores added this pull request to the merge queue Jan 30, 2026
Merged via the queue into main with commit 3075736 Jan 30, 2026
61 of 62 checks passed
@racitores racitores deleted the raci/musd-conversion-component-view-test branch January 30, 2026 09:55
@github-actions github-actions bot locked and limited conversation to collaborators Jan 30, 2026
@metamaskbot metamaskbot added the release-7.65.0 Issue or pull request that will be included in release 7.65.0 label Jan 30, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed release-7.65.0 Issue or pull request that will be included in release 7.65.0 size-XL skip-e2e skip E2E test jobs team-qa QA team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants