Skip to content

test: add component view tests for Predict feature (PredictFeed + PredictMarketDetails)#27012

Merged
racitores merged 5 commits into
mainfrom
test/predict-component-view-tests
Mar 6, 2026
Merged

test: add component view tests for Predict feature (PredictFeed + PredictMarketDetails)#27012
racitores merged 5 commits into
mainfrom
test/predict-component-view-tests

Conversation

@racitores
Copy link
Copy Markdown
Contributor

@racitores racitores commented Mar 4, 2026

Summary

First component view tests for the Predict feature area (MMQA-1529). Tests use Engine spies and real user interactions — no mocked hooks or selectors — following the integration-test doctrine: each test models a complete user journey, not an isolated unit behavior.

Infrastructure added

File Purpose
tests/component-view/presets/predict.ts State preset with predictTradingEnabled remote feature flag, PredictController state, PreferencesController.privacyMode, and TransactionController
tests/component-view/renderers/predict.tsx renderPredictFeedView and renderPredictFeedViewWithRoutes, wrapped with QueryClientProvider (required by PredictBalance which uses @tanstack/react-query)
tests/component-view/renderers/predictMarketDetails.tsx renderPredictMarketDetailsView and renderPredictMarketDetailsViewWithRoutes with initialParams support for route params
tests/component-view/fixtures/predict.ts Shared MOCK_PREDICT_MARKET fixture used across both test files
app/components/UI/Predict/Predict.testIds.ts Added PredictSearchSelectorsIDs (SEARCH_BUTTON, CLEAR_BUTTON, ERROR_STATE) and getPredictSearchSelector.resultCard(index) helper; all raw strings replaced with constants
tests/component-view/mocks.ts Updated to support Predict engine context

PredictFeed tests (12)

  • Search overlay opens when the user presses the search icon
  • getMarkets called with the debounced typed query
  • Search overlay closes when the user presses Cancel
  • Clear button hides after user clears the input
  • No-results message includes the typed query
  • Data completeness: result card shows title + Yes/No tokens after getMarkets resolves
  • Tapping a result card navigates to market details
  • Back button navigates to wallet
  • Balance card renders and getBalance is called on mount
  • Add Funds triggers trackGeoBlockTriggered with attemptedAction: deposit
  • Error state shown when all getMarkets retries fail
  • Retry press calls getMarkets again after an error

PredictMarketDetails tests (5)

  • getMarket called with marketId from route params on mount
  • Data completeness: title + Yes/No bet buttons visible after getMarket resolves
  • Pressing a bet button triggers trackGeoBlockTriggered while ineligible
  • trackMarketDetailsOpened called after market and positions load
  • Back button navigates to Predict root

Key implementation constraints

  • The main feed (PagerView + FlashList) never renders in the test environment — it is gated by {layoutReady && <PredictFeedTabs />} and layoutReady stays false without native layout events. Tests focus on the search overlay which does render.
  • Market card navigation targets Routes.PREDICT.ROOT (nested navigator), not MARKET_DETAILS directly.
  • PredictBalance requires QueryClientProvider; renderer wraps with { retry: false } to surface errors immediately.

Test plan

yarn jest -c jest.config.view.js PredictFeed.view.test PredictMarketDetails.view.test --runInBand --silent --coverage=false
  • All 17 tests pass
  • No ESLint errors (yarn eslint app/components/UI/Predict/views/**/*.view.test.tsx)

🤖 Generated with Claude Code


Note

Low Risk
Low risk: changes are primarily test-only infrastructure plus refactors of testID strings in Predict UI components/tests. Main risk is breaking existing E2E/unit tests that rely on previous hard-coded selector strings.

Overview
Adds component view tests for Predict. Introduces new Predict component-view test suites for PredictFeed and PredictMarketDetails that validate real user flows (search, navigation, balance loading, error/retry) via Engine.context.PredictController spies.

Builds supporting test infrastructure and normalizes selectors. Adds Predict-specific component-view renderers, Redux state preset, and a shared MOCK_PREDICT_MARKET fixture; extends component-view Engine mocks with a stubbed PredictController. Updates PredictFeed and multiple unit tests to replace hard-coded testID strings with new constants/helpers in Predict.testIds.ts (feed/search/market-details selectors, skeleton/empty-state IDs).

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

@racitores racitores requested a review from a team as a code owner March 4, 2026 17:53
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 4, 2026

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 Mar 4, 2026
First component view tests for the Predict feature area (MMQA-1529).
Tests use Engine spies and real user interactions — no mocked hooks or
selectors — following the integration-test doctrine established in the
component-view-test skill.

Infrastructure added:
- tests/component-view/presets/predict.ts: state preset with remote
  feature flag predictTradingEnabled, PredictController state,
  PreferencesController.privacyMode, and TransactionController
- tests/component-view/renderers/predict.tsx: renderPredictFeedView and
  renderPredictFeedViewWithRoutes (wraps with QueryClientProvider for
  PredictBalance which uses @tanstack/react-query)
- tests/component-view/renderers/predictMarketDetails.tsx: renderer for
  the market details screen with initialParams support
- tests/component-view/fixtures/predict.ts: shared MOCK_PREDICT_MARKET
  fixture used across both test files
- Predict.testIds.ts: new PredictSearchSelectorsIDs (SEARCH_BUTTON,
  CLEAR_BUTTON, ERROR_STATE) and getPredictSearchSelector.resultCard()
  helper; all raw strings replaced with constants

PredictFeed tests (12):
- Search overlay opens on icon press
- getMarkets called with debounced typed query
- Search overlay closes on Cancel press
- Clear button hides after user clears input
- No-results message includes the typed query
- Search result card completeness: title + Yes/No tokens visible
- Tapping a result card navigates to market details (route probe)
- Back button navigates to wallet
- Balance card renders and getBalance is called on mount
- Add Funds triggers trackGeoBlockTriggered with attemptedAction: deposit
- Error state shown when all getMarkets retries fail
- Retry press calls getMarkets again after error

PredictMarketDetails tests (5):
- getMarket called with marketId from route params on mount
- Market data completeness: title + Yes/No bet buttons visible
- Pressing a bet button triggers trackGeoBlockTriggered while ineligible
- trackMarketDetailsOpened called after market and positions load
- Back button navigates to Predict root (route probe)

Key constraints documented in tests:
- Main feed (PagerView + FlashList) never renders in test env (gated by
  layoutReady which requires native layout events)
- Search overlay FlashList does render and cards are tappable
- Market card navigation target is Routes.PREDICT.ROOT (nested navigator)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@racitores racitores force-pushed the test/predict-component-view-tests branch from f497e8e to b1a3d56 Compare March 4, 2026 18:16
@github-actions github-actions Bot added size-L and removed size-XL labels Mar 4, 2026
Comment thread app/components/UI/Predict/Predict.testIds.ts Outdated
caieu
caieu previously approved these changes Mar 6, 2026
Copy link
Copy Markdown
Contributor

@caieu caieu left a comment

Choose a reason for hiding this comment

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

LGTM

Comment thread app/components/UI/Predict/Predict.testIds.ts
Copy link
Copy Markdown
Contributor

@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 2 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Comment thread app/components/UI/Predict/views/PredictFeed/PredictFeed.tsx
Comment thread app/components/UI/Predict/views/PredictFeed/PredictFeed.test.tsx
@racitores racitores added the no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed label Mar 6, 2026
@github-actions github-actions Bot added size-XL and removed size-L labels Mar 6, 2026
@metamaskbot metamaskbot added the INVALID-PR-TEMPLATE PR's body doesn't match template label Mar 6, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 6, 2026

🔍 Smart E2E Test Selection

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

E2E Test Selection:
This PR contains test infrastructure improvements for the Predict (Predictions) feature:

  1. Test ID Refactoring: The changes in Predict.testIds.ts add new centralized selector IDs and helper functions for dynamic test ID generation. This improves test maintainability but doesn't change any functional behavior.

  2. Component Changes: The only app code change is in PredictFeed.tsx, which replaces hardcoded test ID strings with centralized selector constants. This is a pure refactoring with no logic changes.

  3. Unit Test Updates: Both PredictFeed.test.tsx and PredictMarketDetails.test.tsx are updated to use the new centralized selectors instead of hardcoded strings.

  4. New Component View Tests: New test files (PredictFeed.view.test.tsx, PredictMarketDetails.view.test.tsx) are added for better test coverage.

  5. Test Infrastructure: New files in tests/component-view/ add fixtures, presets, renderers, and mocks specifically for Predict component testing.

Since all changes are confined to the Predictions feature (test IDs and test infrastructure), only SmokePredictions is needed to verify the Predictions functionality still works correctly. The changes are low risk as they are primarily test-related with no functional changes to the app logic.

Per the tag description, SmokePredictions tests the Polymarket prediction market integration including opening positions, cashing out, claiming winnings, and the Positions/Activities tabs - which aligns with the components being modified (PredictFeed, PredictMarketDetails).

Performance Test Selection:
These changes are purely test infrastructure improvements (test ID refactoring, new unit tests, test fixtures/mocks). There are no changes to UI rendering, data loading, state management, or any code paths that would affect app performance. The only app code change is replacing hardcoded test ID strings with centralized constants in PredictFeed.tsx, which has zero performance impact.

View GitHub Actions results

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 6, 2026

⚠️ E2E Fixture Validation — Structural changes detected

Category Count
New keys 68
Missing keys 11
Type mismatches 0
Value mismatches 7 (informational)

The committed fixture schema is out of date. To update, comment:

@metamaskbot update-mobile-fixture

View full details | Download diff report

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Mar 6, 2026

Copy link
Copy Markdown
Contributor

@caieu caieu left a comment

Choose a reason for hiding this comment

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

LGTM

@racitores racitores added this pull request to the merge queue Mar 6, 2026
Merged via the queue into main with commit b7aab19 Mar 6, 2026
86 of 87 checks passed
@racitores racitores deleted the test/predict-component-view-tests branch March 6, 2026 18:01
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 6, 2026
@metamaskbot metamaskbot added the release-7.70.0 Issue or pull request that will be included in release 7.70.0 label Mar 6, 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.70.0 Issue or pull request that will be included in release 7.70.0 size-XL team-qa QA team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants