Skip to content

Commit c366553

Browse files
committed
chore: update entrypoint event for predict homescreen flow
1 parent 80c692d commit c366553

4 files changed

Lines changed: 41 additions & 3 deletions

File tree

app/components/UI/Predict/constants/eventNames.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ export const PredictEventValues = {
9191
TRENDING_SEARCH: 'trending_search',
9292
TRENDING: 'trending',
9393
BUY_PREVIEW: 'buy_preview',
94+
HOME_SECTION: 'home_section',
9495
},
9596
TRANSACTION_TYPE: {
9697
MM_PREDICT_BUY: 'mm_predict_buy',

app/components/UI/Predict/types/navigation.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ export type PredictEntryPoint =
2626
| typeof PredictEventValues.ENTRY_POINT.MAIN_TRADE_BUTTON
2727
| typeof PredictEventValues.ENTRY_POINT.BACKGROUND
2828
| typeof PredictEventValues.ENTRY_POINT.TRENDING_SEARCH
29-
| typeof PredictEventValues.ENTRY_POINT.TRENDING;
29+
| typeof PredictEventValues.ENTRY_POINT.TRENDING
30+
| typeof PredictEventValues.ENTRY_POINT.HOME_SECTION;
3031

3132
/** Predict market list parameters */
3233
export interface PredictMarketListParams {

app/components/Views/Homepage/Sections/Predictions/PredictionsSection.test.tsx

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ describe('PredictionsSection', () => {
223223
expect(screen.getByText('Predictions')).toBeOnTheScreen();
224224
});
225225

226-
it('navigates to predictions market list on title press', () => {
226+
it('navigates with home_section entry_point when trending markets title is pressed', () => {
227227
renderWithProvider(
228228
<PredictionsSection sectionIndex={0} totalSectionsLoaded={1} />,
229229
);
@@ -232,6 +232,9 @@ describe('PredictionsSection', () => {
232232

233233
expect(mockNavigate).toHaveBeenCalledWith(Routes.PREDICT.ROOT, {
234234
screen: Routes.PREDICT.MARKET_LIST,
235+
params: {
236+
entryPoint: PredictEventValues.ENTRY_POINT.HOME_SECTION,
237+
},
235238
});
236239
});
237240

@@ -786,6 +789,32 @@ describe('PredictionsSection', () => {
786789
expect(screen.getByText('Trending predictions')).toBeOnTheScreen();
787790
});
788791

792+
it('navigates with home_section entry_point on title press', () => {
793+
mockUsePredictMarketsForHomepage.mockReturnValue({
794+
markets: mockMarkets,
795+
isLoading: false,
796+
error: null,
797+
refetch: jest.fn(),
798+
});
799+
800+
renderWithProvider(
801+
<PredictionsSection
802+
sectionIndex={0}
803+
totalSectionsLoaded={5}
804+
mode="trending-only"
805+
/>,
806+
);
807+
808+
fireEvent.press(screen.getByText('Predictions'));
809+
810+
expect(mockNavigate).toHaveBeenCalledWith(Routes.PREDICT.ROOT, {
811+
screen: Routes.PREDICT.MARKET_LIST,
812+
params: {
813+
entryPoint: PredictEventValues.ENTRY_POINT.HOME_SECTION,
814+
},
815+
});
816+
});
817+
789818
it('returns null when no markets after loading', () => {
790819
mockUsePredictMarketsForHomepage.mockReturnValue({
791820
markets: [],

app/components/Views/Homepage/Sections/Predictions/PredictionsSection.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,12 +233,19 @@ const HomepagePredictPositions = ({
233233
</Box>
234234
);
235235

236-
const usePredictNavigationHandlers = () => {
236+
const usePredictNavigationHandlers = (): {
237+
handleViewAllPredictions: () => void;
238+
handleViewAllFromPositions: () => void;
239+
handlePositionPress: (position: PredictPosition) => void;
240+
} => {
237241
const navigation =
238242
useNavigation<NavigationProp<PredictNavigationParamList>>();
239243
const handleViewAllPredictions = useCallback(() => {
240244
navigation.navigate(Routes.PREDICT.ROOT, {
241245
screen: Routes.PREDICT.MARKET_LIST,
246+
params: {
247+
entryPoint: PredictEventValues.ENTRY_POINT.HOME_SECTION,
248+
},
242249
});
243250
}, [navigation]);
244251

0 commit comments

Comments
 (0)