Commit 4d28c04
authored
fix(predict): chart only display active (MetaMask#22677)
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->
## **Description**
- Refactors the details screen so that it only passed active outcomes to
the chart (or hides it)
<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->
## **Changelog**
<!--
If this PR is not End-User-Facing and should not show up in the
CHANGELOG, you can choose to either:
1. Write `CHANGELOG entry: null`
2. Label with `no-changelog`
If this PR is End-User-Facing, please write a short User-Facing
description in the past tense like:
`CHANGELOG entry: Added a new tab for users to see their NFTs`
`CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker`
(This helps the Release Engineer do their job more quickly and
accurately)
-->
CHANGELOG entry: null
## **Related issues**
Fixes: NA
## **Manual testing steps**
```gherkin
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**
<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->
### **Before**
<!-- [screenshots/recordings] -->
### **After**
https://github.com/user-attachments/assets/22900f2b-988e-496a-a554-59562d2caafc
<!-- [screenshots/recordings] -->
## **Pre-merge author checklist**
- [x] 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).
- [x] I've completed the PR template to the best of my ability
- [x] I’ve included tests if applicable
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] 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.
## **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.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Restricts the market details chart to open outcomes (max 3), updates
price history inputs and render conditions, and adds/updates tests to
cover these cases.
>
> - **PredictMarketDetails** (`PredictMarketDetails.tsx`)
> - Prepare chart data from only open outcomes via `chartOpenOutcomes`
(capped at 3) and derive `chartOutcomeTokenIds`.
> - Use `chartOutcomeTokenIds` for `usePredictPriceHistory` and enable
only when non-empty.
> - Build `chartData` labels/colors from `chartOpenOutcomes` and render
chart only when `chartOpenOutcomes.length > 0` (instead of checking
partial resolution state).
> - Keep real-time price updates for open outcomes; no functional
changes elsewhere.
> - **Tests** (`PredictMarketDetails.test.tsx`)
> - Add/adjust cases to verify: no chart when no open outcomes; chart
when at least one open; closed outcomes filtered; limit to first 3 open
outcomes.
> - Update mocks/fixtures to include `status` fields; add
`usePredictMeasurement` mock; minor expectations aligned with new
outcomes tab and chart behavior.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
6974586. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent ee0a135 commit 4d28c04
2 files changed
Lines changed: 269 additions & 17 deletions
File tree
- app/components/UI/Predict/views/PredictMarketDetails
Lines changed: 242 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
228 | 228 | | |
229 | 229 | | |
230 | 230 | | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
231 | 235 | | |
232 | 236 | | |
233 | 237 | | |
| |||
425 | 429 | | |
426 | 430 | | |
427 | 431 | | |
| 432 | + | |
428 | 433 | | |
429 | 434 | | |
430 | 435 | | |
431 | 436 | | |
432 | 437 | | |
433 | 438 | | |
| 439 | + | |
434 | 440 | | |
435 | 441 | | |
436 | 442 | | |
| |||
836 | 842 | | |
837 | 843 | | |
838 | 844 | | |
| 845 | + | |
839 | 846 | | |
840 | 847 | | |
841 | 848 | | |
842 | 849 | | |
843 | | - | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
844 | 855 | | |
845 | 856 | | |
846 | 857 | | |
| |||
863 | 874 | | |
864 | 875 | | |
865 | 876 | | |
| 877 | + | |
866 | 878 | | |
867 | 879 | | |
868 | 880 | | |
869 | 881 | | |
870 | 882 | | |
871 | 883 | | |
| 884 | + | |
872 | 885 | | |
873 | 886 | | |
874 | 887 | | |
875 | 888 | | |
876 | 889 | | |
877 | 890 | | |
| 891 | + | |
878 | 892 | | |
879 | 893 | | |
880 | 894 | | |
| |||
885 | 899 | | |
886 | 900 | | |
887 | 901 | | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
| 1086 | + | |
| 1087 | + | |
| 1088 | + | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
| 1098 | + | |
| 1099 | + | |
| 1100 | + | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
888 | 1111 | | |
889 | 1112 | | |
890 | 1113 | | |
| |||
1340 | 1563 | | |
1341 | 1564 | | |
1342 | 1565 | | |
| 1566 | + | |
1343 | 1567 | | |
1344 | 1568 | | |
1345 | 1569 | | |
1346 | 1570 | | |
| 1571 | + | |
1347 | 1572 | | |
1348 | 1573 | | |
1349 | 1574 | | |
1350 | 1575 | | |
1351 | 1576 | | |
1352 | 1577 | | |
| 1578 | + | |
1353 | 1579 | | |
1354 | 1580 | | |
1355 | 1581 | | |
1356 | 1582 | | |
1357 | 1583 | | |
1358 | 1584 | | |
| 1585 | + | |
1359 | 1586 | | |
1360 | 1587 | | |
1361 | 1588 | | |
| |||
1365 | 1592 | | |
1366 | 1593 | | |
1367 | 1594 | | |
1368 | | - | |
| 1595 | + | |
| 1596 | + | |
| 1597 | + | |
1369 | 1598 | | |
1370 | 1599 | | |
1371 | 1600 | | |
| |||
1909 | 2138 | | |
1910 | 2139 | | |
1911 | 2140 | | |
| 2141 | + | |
1912 | 2142 | | |
1913 | 2143 | | |
1914 | 2144 | | |
1915 | 2145 | | |
1916 | | - | |
| 2146 | + | |
| 2147 | + | |
| 2148 | + | |
| 2149 | + | |
| 2150 | + | |
1917 | 2151 | | |
1918 | 2152 | | |
1919 | 2153 | | |
| |||
1927 | 2161 | | |
1928 | 2162 | | |
1929 | 2163 | | |
| 2164 | + | |
1930 | 2165 | | |
1931 | 2166 | | |
1932 | 2167 | | |
1933 | 2168 | | |
| 2169 | + | |
1934 | 2170 | | |
1935 | 2171 | | |
1936 | 2172 | | |
1937 | 2173 | | |
1938 | 2174 | | |
1939 | 2175 | | |
| 2176 | + | |
1940 | 2177 | | |
1941 | 2178 | | |
1942 | 2179 | | |
| |||
2360 | 2597 | | |
2361 | 2598 | | |
2362 | 2599 | | |
2363 | | - | |
| 2600 | + | |
2364 | 2601 | | |
2365 | 2602 | | |
2366 | 2603 | | |
| |||
2389 | 2626 | | |
2390 | 2627 | | |
2391 | 2628 | | |
2392 | | - | |
2393 | | - | |
2394 | | - | |
| 2629 | + | |
2395 | 2630 | | |
2396 | 2631 | | |
2397 | 2632 | | |
| |||
0 commit comments