test: add component view tests for Predict feature (PredictFeed + PredictMarketDetails)#27012
Conversation
|
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. |
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>
f497e8e to
b1a3d56
Compare
There was a problem hiding this comment.
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.
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
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: |
The committed fixture schema is out of date. To update, comment: |
|



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
tests/component-view/presets/predict.tspredictTradingEnabledremote feature flag,PredictControllerstate,PreferencesController.privacyMode, andTransactionControllertests/component-view/renderers/predict.tsxrenderPredictFeedViewandrenderPredictFeedViewWithRoutes, wrapped withQueryClientProvider(required byPredictBalancewhich uses@tanstack/react-query)tests/component-view/renderers/predictMarketDetails.tsxrenderPredictMarketDetailsViewandrenderPredictMarketDetailsViewWithRouteswithinitialParamssupport for route paramstests/component-view/fixtures/predict.tsMOCK_PREDICT_MARKETfixture used across both test filesapp/components/UI/Predict/Predict.testIds.tsPredictSearchSelectorsIDs(SEARCH_BUTTON,CLEAR_BUTTON,ERROR_STATE) andgetPredictSearchSelector.resultCard(index)helper; all raw strings replaced with constantstests/component-view/mocks.tsPredictFeed tests (12)
getMarketscalled with the debounced typed querygetMarketsresolvesgetBalanceis called on mounttrackGeoBlockTriggeredwithattemptedAction: depositgetMarketsretries failgetMarketsagain after an errorPredictMarketDetails tests (5)
getMarketcalled withmarketIdfrom route params on mountgetMarketresolvestrackGeoBlockTriggeredwhile ineligibletrackMarketDetailsOpenedcalled after market and positions loadKey implementation constraints
PagerView+FlashList) never renders in the test environment — it is gated by{layoutReady && <PredictFeedTabs />}andlayoutReadystays false without native layout events. Tests focus on the search overlay which does render.Routes.PREDICT.ROOT(nested navigator), notMARKET_DETAILSdirectly.PredictBalancerequiresQueryClientProvider; renderer wraps with{ retry: false }to surface errors immediately.Test plan
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
testIDstrings 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
PredictFeedandPredictMarketDetailsthat validate real user flows (search, navigation, balance loading, error/retry) viaEngine.context.PredictControllerspies.Builds supporting test infrastructure and normalizes selectors. Adds Predict-specific component-view renderers, Redux state preset, and a shared
MOCK_PREDICT_MARKETfixture; extends component-viewEnginemocks with a stubbedPredictController. UpdatesPredictFeedand multiple unit tests to replace hard-codedtestIDstrings with new constants/helpers inPredict.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.