Skip to content

test: Bridge expand component view tests coverage - Metamask Issues#25908

Merged
racitores merged 18 commits intomainfrom
cursor/metamask-mobile-bugs-detecci-n-tests-51ce
Feb 18, 2026
Merged

test: Bridge expand component view tests coverage - Metamask Issues#25908
racitores merged 18 commits intomainfrom
cursor/metamask-mobile-bugs-detecci-n-tests-51ce

Conversation

@racitores
Copy link
Contributor

@racitores racitores commented Feb 10, 2026

This PR adds improved test scripts, CI optimizations and test coverage.

Test Updates

  • BridgeView Tests: Added issue regression test coverage and created bridgeViewTestConstants.ts with reusable test constants (ETH_SOURCE, USDC_DEST, DEFAULT_BRIDGE).

  • MusdConversionAssetListCta Tests: Updated to use describeForPlatforms and improved test setup with proper version-gated feature flags and fiatOrders state handling.

New Test Scripts (package.json)

  • test:view:base: New base script providing a common foundation for all component-view test commands. Runs Jest with view config, in-band execution, and silent output by default.

  • test:view: Refactored to use test:view:base with coverage disabled and test path pattern matching.

  • test:view:one: New script for running a single component-view test file with verbose output and extended timeout (30s). Useful for debugging individual test files.

  • test:view:coverage: New script for running all component-view tests with coverage reporting enabled.

  • test:view:coverage:folder: New script for generating coverage reports for tests in a specific folder. Accepts a folder path as an argument and generates both text-summary and lcov coverage reports.

  • test:view:ci: New script optimized for CI environments. Runs tests with iOS platform targeting, coverage reporting in JSON format, and force exit for clean CI runs. Supports sharding via --shard parameter.

Jest Configuration (jest.config.view.js)

  • Added testTimeout: 30000 for longer-running component-view tests
  • Added forceExit: true to ensure clean test execution
  • Added maxWorkers: 1 to prevent race conditions in component-view tests

CI/CD Improvements (.github/workflows/ci.yml)

  • Implemented test sharding: Component-view tests now run in 2 parallel shards for faster CI execution
  • Updated to use test:view:ci script with shard support (--shard=${{ matrix.shard }}/2)
  • Updated CI to unly run tests as iOS. By default both iOS and Android will be run in local. It hasn't been probed this value hence the removal in the pipeline.
  • Added component view tests as part of the global unit tests coverage.
  • Ad hoc html coverage report generated for component view test to be download from ci artifacts.

Testing Framework Enhancements

  • stateFixture.ts: Added withMinimalTokensController() method to properly initialize TokensController state for tests that depend on token data (e.g., BridgeTokenSelector, useTokensWithBalance). Supports multiple chainIds (defaults to mainnet '0x1').

  • mocks.ts: Added BridgeController mocks (updateBridgeQuoteRequestParams, resetState, stopAllPolling) to support Bridge component testing.

  • presets/bridge.ts: Updated initialStateBridge preset to include withMinimalTokensController() for proper token state initialization.

Documentation Updates

  • COMPONENT_VIEW_TEST_RULES.md: Added guidance to avoid fake timers (jest.useFakeTimers, jest.advanceTimersByTime, jest.useRealTimers) in component-view tests.

  • component-view-testing.mdc: Updated rules to mention the no fake timers policy.

  • tests/AGENTS.md: Updated documentation to reference the no fake timers guidance for component-view tests.


Open in Cursor Open in Web


Note

Medium Risk
Medium risk because CI workflow and Jest configuration changes can affect test stability/coverage reporting and potentially increase flakiness or runtime if sharding/merging is misconfigured, though production code paths are not modified.

Overview
Component-view tests now run faster and integrate into overall coverage. CI renames the component-view job to cv-test, runs it in 2 shards, uploads per-shard JSON coverage, generates a merged HTML coverage artifact, and merges component-view coverage with unit-test coverage before Sonar.

Component-view test infrastructure is hardened. jest.config.view.js adds a 30s timeout, forceExit, and maxWorkers: 1; package.json introduces a set of test:view:* scripts including a CI-optimized runner.

Bridge/Earn component-view coverage is expanded and made more deterministic. BridgeView.view.test.tsx is refactored with shared token constants and adds regression tests (gas-included label, custom slippage propagation, token search returning duplicates, native-token display, no-crash/CTA visibility without quotes); the state fixture/preset is extended with withMinimalTokensController() and Engine mocks add BridgeController.updateBridgeQuoteRequestParams. Earn CTA tests are updated to use version-gated flag shapes and stable fiatOrders state.

Testing guidance is updated/enforced. Component-view rules now always apply and explicitly prohibit Jest fake timers (documented in both rule docs and tests/AGENTS.md).

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

@github-actions
Copy link
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.

@github-actions github-actions bot added size-L and removed size-M labels Feb 11, 2026
@racitores racitores force-pushed the cursor/metamask-mobile-bugs-detecci-n-tests-51ce branch from 12174f0 to f162e18 Compare February 12, 2026 15:45
@github-actions github-actions bot added size-XL and removed size-L labels Feb 12, 2026
@racitores racitores added no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed skip-e2e skip E2E test jobs labels Feb 12, 2026
@metamaskbot metamaskbot added the INVALID-PR-TEMPLATE PR's body doesn't match template label Feb 12, 2026
@racitores racitores changed the title Metamask-mobile bugs detección tests Metamask-mobile issues list and tests Feb 13, 2026
cursoragent and others added 10 commits February 13, 2026 13:19
Co-authored-by: Ramon AC <racitores@users.noreply.github.com>
Co-authored-by: Ramon AC <racitores@users.noreply.github.com>
Co-authored-by: Ramon AC <racitores@users.noreply.github.com>
Co-authored-by: Ramon AC <racitores@users.noreply.github.com>
Co-authored-by: Ramon AC <racitores@users.noreply.github.com>
Co-authored-by: Ramon AC <racitores@users.noreply.github.com>
@racitores racitores force-pushed the cursor/metamask-mobile-bugs-detecci-n-tests-51ce branch from 20fc88a to d222d3c Compare February 13, 2026 12:24
@racitores racitores marked this pull request as ready for review February 13, 2026 15:49
@racitores racitores requested review from a team as code owners February 13, 2026 15:49
@github-actions github-actions bot added size-L and removed size-XL labels Feb 13, 2026
@racitores racitores changed the title Metamask-mobile issues list and tests Bridge expand component view tests coverage - Metamask Issues Feb 16, 2026
@racitores racitores changed the title Bridge expand component view tests coverage - Metamask Issues test: Bridge expand component view tests coverage - Metamask Issues Feb 16, 2026
@tommasini
Copy link
Contributor

Hey @racitores can we add a description on what we are accomplishing regarding the ci.yml changes and the new scripts on the package json?

Also I see that the new report do not have only coverage by component but also redux actions. I believe this is intentional but the name of the CI step do not reflect it, would it be more unit-test-merge-coverage? Since it englobes everything?

Let me know your thoughts

Matt561
Matt561 previously approved these changes Feb 16, 2026
Copy link
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.

Approving for the Earn file change 👍

@racitores
Copy link
Contributor Author

Hey @racitores can we add a description on what we are accomplishing regarding the ci.yml changes and the new scripts on the package json?

Also I see that the new report do not have only coverage by component but also redux actions. I believe this is intentional but the name of the CI step do not reflect it, would it be more unit-test-merge-coverage? Since it englobes everything?

Let me know your thoughts

I'll update the description, thanks for the feedback 👍

In regards the new merge of component view tests and unit tests coverage, you are right. They are merged to compute together for sonarcloud metrics. I'll update the step accordingly

@racitores racitores enabled auto-merge February 17, 2026 17:27
@racitores racitores requested a review from Matt561 February 17, 2026 17:28
Copy link
Contributor

@MarioAslau MarioAslau left a comment

Choose a reason for hiding this comment

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

LGTM

@github-actions
Copy link
Contributor

🔍 Smart E2E Test Selection

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

E2E Test Selection:
This PR focuses entirely on CI infrastructure and component-view test framework improvements, with no changes to production app code or E2E test infrastructure:

  1. CI Workflow Changes: The .github/workflows/ci.yml changes only affect the cv-test (component-view test) job - adding sharding for parallel execution and a coverage merge step. These are Jest-based tests, not Detox E2E tests. The E2E test jobs are untouched.

  2. Package.json Script Changes: New test:view:* script variants for component-view tests only. The E2E test scripts (test:e2e:*) are unchanged.

  3. Jest Config Changes: jest.config.view.js changes only affect component-view test execution (timeout, forceExit, maxWorkers).

  4. Test Framework Updates:

    • mocks.ts adds BridgeController mock methods
    • stateFixture.ts adds withMinimalTokensController builder
    • bridge.ts preset updated
    • New test constants file added
  5. Test File Changes:

    • BridgeView.view.test.tsx - Jest component-view tests (not E2E)
    • MusdConversionAssetListCta.view.test.tsx - Jest component-view tests (not E2E)
  6. Documentation: Rules updates about fake timers in component-view tests.

None of these changes affect:

  • Production app code
  • Detox E2E test infrastructure
  • E2E test page objects, selectors, or specs
  • App components, controllers, or core functionality

The changes are isolated to Jest-based component-view testing infrastructure, which runs separately from Detox E2E tests. No E2E tags are needed.

Performance Test Selection:
This PR contains no changes that could impact app performance. All changes are to CI workflows, Jest test configuration, component-view test framework utilities, and documentation. No production app code, UI components, data loading logic, or rendering code is modified. The changes are entirely focused on how component-view tests are executed in CI (sharding) and test framework improvements.

View GitHub Actions results

Copy link

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

const { getByTestId, queryByTestId } = defaultBridgeWithTokens({
bridge: {
sourceAmount: '100',
sourceToken: USDC_DEST,
Copy link

Choose a reason for hiding this comment

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

Destination constant USDC_DEST used as source token

Low Severity

The USDC_DEST constant, explicitly documented as "USDC (mainnet) token used as default destination in Bridge view tests," is used here as sourceToken. While the token metadata is direction-agnostic so the test functions correctly, the naming actively contradicts its usage, which is confusing for future maintainers. A direction-neutral name like USDC_TOKEN or a separate USDC_SOURCE constant would better express intent.

Additional Locations (1)

Fix in Cursor Fix in Web

@sonarqubecloud
Copy link

@racitores racitores added this pull request to the merge queue Feb 18, 2026
Merged via the queue into main with commit 7f29e41 Feb 18, 2026
79 of 113 checks passed
@racitores racitores deleted the cursor/metamask-mobile-bugs-detecci-n-tests-51ce branch February 18, 2026 09:13
@github-actions github-actions bot locked and limited conversation to collaborators Feb 18, 2026
@metamaskbot metamaskbot added the release-7.67.0 Issue or pull request that will be included in release 7.67.0 label Feb 18, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

INVALID-PR-TEMPLATE PR's body doesn't match template no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed release-7.67.0 Issue or pull request that will be included in release 7.67.0 size-L skip-e2e skip E2E test jobs team-qa QA team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants