Commit 2692fda
authored
chore(predict): add world cup tab to main predict feed (#30205)
## **Description**
This PR adds the World Cup tab to the main Predict feed behind the
existing `predictWorldCup.enabled && showMainFeedTab` configuration.
It does this by:
- adding `world-cup` as a Predict tab/category key and rendering it
before Hot and Trending when enabled
- moving tab-specific query params onto each `FeedTab`, so Hot and World
Cup can coexist without special casing Hot in `PredictFeed`
- using `buildPredictWorldCupAllQuery` for the main feed World Cup tab
so it mirrors the dedicated World Cup screen All tab market universe
- extending Polymarket event query handling so exact custom params are
respected for Hot and World Cup categories
- preserving existing tab behavior by falling back to the first visible
tab when a requested tab is hidden
Automated coverage was added or updated for tab injection/order,
disabled behavior, custom query params, and World Cup event query
generation.
Verified with:
- `yarn jest app/components/UI/Predict/hooks/usePredictTabs.test.ts`
- `yarn jest
app/components/UI/Predict/views/PredictFeed/PredictFeed.test.tsx`
- `yarn jest
app/components/UI/Predict/providers/polymarket/utils.test.ts`
## **Changelog**
CHANGELOG entry: Added a World Cup tab to the Predict feed when enabled.
## **Related issues**
Fixes:
[PRED-874](https://consensyssoftware.atlassian.net/browse/PRED-874)
## **Manual testing steps**
```gherkin
Feature: Predict World Cup main feed tab
Scenario: World Cup tab appears first when enabled
Given Predict is available
And the predictWorldCup flag is enabled with showMainFeedTab true
When user opens the main Predict feed
Then the World Cup tab appears before Trending
And World Cup markets load from the World Cup All tab query
Scenario: World Cup and Hot tabs coexist when both flags are enabled
Given predictWorldCup is enabled with showMainFeedTab true
And predictHotTab is enabled
When user opens the main Predict feed
Then World Cup appears first
And Hot appears after World Cup
And selecting Hot loads Hot tab markets
Scenario: World Cup tab remains hidden when disabled
Given predictWorldCup is disabled or showMainFeedTab is false
When user opens the main Predict feed
Then the World Cup tab is not shown
And Trending is the first standard tab
Scenario: World Cup tab can be opened from the main feed tab deeplink
Given predictWorldCup is enabled with showMainFeedTab true
When user opens https://link.metamask.io/predict?tab=world-cup
Then the main Predict feed opens with the World Cup tab selected
```
## **Screenshots/Recordings**
https://github.com/user-attachments/assets/f499a887-a570-40c0-b7e8-f434f878beac
### **Before**
N/A
### **After**
To be added after manual testing.
## **Pre-merge author checklist**
- [ ] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [ ] I've completed the PR template to the best of my ability
- [ ] I've included tests if applicable
- [ ] I've documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] I've applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.
#### Performance checks (if applicable)
- [ ] I've tested on Android
- Ideally on a mid-range device; emulator is acceptable
- [ ] I've tested with a power user scenario
- Use these [power-user
SRPs](https://consensyssoftware.atlassian.net/wiki/spaces/TL1/pages/edit-v2/401401446401?draftShareId=9d77e1e1-4bdc-4be1-9ebb-ccd916988d93)
to import wallets with many accounts and tokens
- [ ] I've instrumented key operations with Sentry traces for production
performance metrics
- See [`trace()`](/app/util/trace.ts) for usage and
[`addToken`](/app/components/Views/AddAsset/components/AddCustomToken/AddCustomToken.tsx#L274)
for an example
For performance guidelines and tooling, see the [Performance
Guide](https://consensyssoftware.atlassian.net/wiki/spaces/TL1/pages/400085549067/Performance+Guide+for+Engineers).
## **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.
[PRED-874]:
https://consensyssoftware.atlassian.net/browse/PRED-874?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Changes tab composition and Polymarket event query generation for new
`world-cup` category, which can affect which markets are fetched and
shown when feature flags/deeplinks are used.
>
> **Overview**
> Adds a new `world-cup` category/tab to the main Predict feed (gated by
`selectPredictWorldCupMainFeedTabEnabledFlag`), rendered ahead of
Hot/Trending and selectable via deeplink when available.
>
> Refactors tab handling so each `FeedTab` carries optional
`customQueryParams`, letting Hot and World Cup supply their own
Polymarket query strings without `PredictFeed` special-casing.
>
> Updates `fetchEventsFromPolymarketApi` to treat Hot and World Cup as
*exact-query* categories (skip default liquidity/volume filters when
`customQueryParams` are provided) and adds a World Cup default query
fallback using `PREDICT_WORLD_CUP_DEFAULT_TAG_SLUG`. Tests are expanded
across `usePredictTabs`, `PredictFeed`, and Polymarket utils to cover
ordering, deeplink fallback when tabs are hidden, and query param
behavior.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
94108b7. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent c1071c4 commit 2692fda
8 files changed
Lines changed: 398 additions & 57 deletions
File tree
- app/components/UI/Predict
- constants
- hooks
- providers/polymarket
- types
- views/PredictFeed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
24 | 30 | | |
25 | 31 | | |
26 | 32 | | |
| 33 | + | |
27 | 34 | | |
28 | 35 | | |
29 | 36 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
| 3 | + | |
2 | 4 | | |
3 | 5 | | |
4 | 6 | | |
| |||
13 | 15 | | |
14 | 16 | | |
15 | 17 | | |
| 18 | + | |
| 19 | + | |
16 | 20 | | |
17 | 21 | | |
18 | | - | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
19 | 41 | | |
20 | 42 | | |
21 | 43 | | |
| |||
28 | 50 | | |
29 | 51 | | |
30 | 52 | | |
| 53 | + | |
| 54 | + | |
31 | 55 | | |
32 | 56 | | |
33 | 57 | | |
| |||
47 | 71 | | |
48 | 72 | | |
49 | 73 | | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
50 | 110 | | |
51 | 111 | | |
52 | 112 | | |
| |||
56 | 116 | | |
57 | 117 | | |
58 | 118 | | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
59 | 128 | | |
60 | 129 | | |
61 | 130 | | |
| |||
72 | 141 | | |
73 | 142 | | |
74 | 143 | | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
75 | 163 | | |
76 | 164 | | |
77 | 165 | | |
| |||
184 | 272 | | |
185 | 273 | | |
186 | 274 | | |
187 | | - | |
188 | | - | |
| 275 | + | |
| 276 | + | |
189 | 277 | | |
190 | 278 | | |
191 | | - | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
192 | 282 | | |
193 | 283 | | |
194 | | - | |
| 284 | + | |
195 | 285 | | |
196 | 286 | | |
197 | 287 | | |
198 | 288 | | |
199 | 289 | | |
200 | | - | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
201 | 313 | | |
202 | 314 | | |
203 | 315 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
6 | 10 | | |
7 | 11 | | |
8 | 12 | | |
| 13 | + | |
9 | 14 | | |
10 | 15 | | |
11 | 16 | | |
12 | 17 | | |
| 18 | + | |
13 | 19 | | |
14 | 20 | | |
15 | 21 | | |
16 | 22 | | |
| 23 | + | |
17 | 24 | | |
18 | 25 | | |
19 | 26 | | |
20 | 27 | | |
21 | 28 | | |
22 | 29 | | |
23 | 30 | | |
24 | | - | |
25 | 31 | | |
26 | 32 | | |
27 | 33 | | |
28 | 34 | | |
29 | 35 | | |
30 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
31 | 41 | | |
32 | 42 | | |
33 | 43 | | |
| |||
39 | 49 | | |
40 | 50 | | |
41 | 51 | | |
| 52 | + | |
42 | 53 | | |
43 | 54 | | |
44 | 55 | | |
45 | | - | |
46 | | - | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
47 | 63 | | |
48 | | - | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
49 | 73 | | |
50 | 74 | | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
51 | 78 | | |
52 | 79 | | |
53 | 80 | | |
| |||
109 | 136 | | |
110 | 137 | | |
111 | 138 | | |
112 | | - | |
113 | 139 | | |
114 | 140 | | |
Lines changed: 59 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
204 | 205 | | |
205 | 206 | | |
206 | 207 | | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
207 | 266 | | |
208 | 267 | | |
209 | 268 | | |
| |||
0 commit comments