Skip to content

Commit fa95438

Browse files
committed
Outline plan for reviewer comments
1 parent 2f19e0e commit fa95438

6 files changed

Lines changed: 132 additions & 102 deletions

File tree

app/components/UI/Bridge/Views/BridgeView/BridgeView.test.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { BridgeViewSelectorsIDs } from './BridgeView.testIds';
2525
import { MOCK_ENTROPY_SOURCE as mockEntropySource } from '../../../../../util/test/keyringControllerTestUtils';
2626
import { RootState } from '../../../../../reducers';
2727
import { mockQuoteWithMetadata } from '../../_mocks_/bridgeQuoteWithMetadata';
28+
import { BridgeTrendingTokensSectionTestIds } from '../../components/BridgeTrendingTokensSection/BridgeTrendingTokensSection.testIds';
2829

2930
// Mock the account-tree-controller file that imports the problematic module
3031
jest.mock(
@@ -849,7 +850,7 @@ describe('BridgeView', () => {
849850
expect(queryByTestId('banneralert')).toBeNull();
850851
expect(queryByTestId('edit-slippage-button')).toBeNull();
851852
expect(
852-
queryByTestId(BridgeViewSelectorsIDs.TRENDING_TOKENS_SECTION),
853+
queryByTestId(BridgeTrendingTokensSectionTestIds.SECTION),
853854
).toBeNull();
854855
expect(queryByText('Fetching quote')).toBeNull();
855856
});
@@ -925,7 +926,7 @@ describe('BridgeView', () => {
925926
});
926927
expect(queryByTestId('edit-slippage-button')).toBeNull();
927928
expect(
928-
queryByTestId(BridgeViewSelectorsIDs.TRENDING_TOKENS_SECTION),
929+
queryByTestId(BridgeTrendingTokensSectionTestIds.SECTION),
929930
).toBeNull();
930931
});
931932

@@ -963,7 +964,7 @@ describe('BridgeView', () => {
963964
});
964965
expect(getByTestId(BridgeViewSelectorsIDs.CONFIRM_BUTTON)).toBeTruthy();
965966
expect(
966-
queryByTestId(BridgeViewSelectorsIDs.TRENDING_TOKENS_SECTION),
967+
queryByTestId(BridgeTrendingTokensSectionTestIds.SECTION),
967968
).toBeNull();
968969
});
969970

@@ -1016,7 +1017,7 @@ describe('BridgeView', () => {
10161017
);
10171018

10181019
expect(
1019-
getByTestId(BridgeViewSelectorsIDs.TRENDING_TOKENS_SECTION),
1020+
getByTestId(BridgeTrendingTokensSectionTestIds.SECTION),
10201021
).toBeTruthy();
10211022
expect(queryByTestId('edit-slippage-button')).toBeNull();
10221023
});

app/components/UI/Bridge/Views/BridgeView/BridgeView.testIds.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@ export const BridgeViewSelectorsIDs = {
66
CONFIRM_BUTTON: 'bridge-confirm-button',
77
CONFIRM_BUTTON_KEYPAD: 'bridge-confirm-button-keypad',
88
BRIDGE_VIEW_SCROLL: 'bridge-view-scroll',
9-
TRENDING_TOKENS_SECTION: 'bridge-trending-tokens-section',
10-
TRENDING_PRICE_FILTER: 'bridge-trending-price-filter',
11-
TRENDING_NETWORK_FILTER: 'bridge-trending-network-filter',
12-
TRENDING_TIME_FILTER: 'bridge-trending-time-filter',
13-
TRENDING_SHOW_MORE: 'bridge-trending-show-more',
149
QUOTE_DETAILS_SKELETON: 'bridge-quote-details-skeleton',
1510
} as const;
1611

app/components/UI/Bridge/components/BridgeTrendingTokensSection/BridgeTrendingTokensSection.test.tsx

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import React from 'react';
44
import BridgeTrendingTokensSection from './BridgeTrendingTokensSection';
55
import { useTokenListFilters } from '../../../Trending/hooks/useTokenListFilters/useTokenListFilters';
66
import { useTrendingRequest } from '../../../Trending/hooks/useTrendingRequest/useTrendingRequest';
7+
import { BridgeTrendingTokensSectionTestIds } from './BridgeTrendingTokensSection.testIds';
78

89
jest.mock('react-redux', () => ({
910
useSelector: jest.fn(() => ({})),
@@ -30,24 +31,24 @@ jest.mock('../../../Trending/utils/sortTrendingTokens', () => ({
3031
jest.mock(
3132
'../../../Trending/components/TrendingTokenRowItem/TrendingTokenRowItem',
3233
() => {
33-
const React = jest.requireActual('react');
34+
const ReactLib = jest.requireActual('react');
3435
const { View } = jest.requireActual('react-native');
3536
return {
3637
__esModule: true,
3738
default: ({ token }: { token: { assetId: string } }) =>
38-
React.createElement(View, { testID: `row-${token.assetId}` }),
39+
ReactLib.createElement(View, { testID: `row-${token.assetId}` }),
3940
};
4041
},
4142
);
4243

4344
jest.mock(
4445
'../../../Trending/components/TrendingTokenSkeleton/TrendingTokensSkeleton',
4546
() => {
46-
const React = jest.requireActual('react');
47+
const ReactLib = jest.requireActual('react');
4748
const { View } = jest.requireActual('react-native');
4849
return {
4950
__esModule: true,
50-
default: () => React.createElement(View, { testID: 'skeleton-row' }),
51+
default: () => ReactLib.createElement(View, { testID: 'skeleton-row' }),
5152
};
5253
},
5354
);
@@ -118,7 +119,9 @@ describe('BridgeTrendingTokensSection', () => {
118119

119120
const rows = getAllByTestId(/^row-/);
120121
expect(rows).toHaveLength(12);
121-
expect(getByTestId('bridge-trending-show-more')).toBeTruthy();
122+
expect(
123+
getByTestId(BridgeTrendingTokensSectionTestIds.SHOW_MORE),
124+
).toBeTruthy();
122125
});
123126

124127
it('appends one chunk when isNearBottom becomes true', () => {
@@ -143,15 +146,19 @@ describe('BridgeTrendingTokensSection', () => {
143146
rerender(<BridgeTrendingTokensSection />);
144147

145148
expect(getAllByTestId(/^row-/)).toHaveLength(8);
146-
expect(queryByTestId('bridge-trending-show-more')).toBeNull();
149+
expect(
150+
queryByTestId(BridgeTrendingTokensSectionTestIds.SHOW_MORE),
151+
).toBeNull();
147152
});
148153

149154
it('does not append chunk while a bottom sheet is open', () => {
150155
const { getAllByTestId, getByTestId, rerender } = render(
151156
<BridgeTrendingTokensSection />,
152157
);
153158

154-
fireEvent.press(getByTestId('bridge-trending-price-filter'));
159+
fireEvent.press(
160+
getByTestId(BridgeTrendingTokensSectionTestIds.PRICE_FILTER),
161+
);
155162

156163
rerender(<BridgeTrendingTokensSection isNearBottom />);
157164

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export const BridgeTrendingTokensSectionTestIds = {
2+
SECTION: 'bridge-trending-tokens-section',
3+
PRICE_FILTER: 'bridge-trending-price-filter',
4+
NETWORK_FILTER: 'bridge-trending-network-filter',
5+
TIME_FILTER: 'bridge-trending-time-filter',
6+
SHOW_MORE: 'bridge-trending-show-more',
7+
} as const;
8+
9+
export type BridgeTrendingTokensSectionTestIdsType =
10+
typeof BridgeTrendingTokensSectionTestIds;

app/components/UI/Bridge/components/BridgeTrendingTokensSection/BridgeTrendingTokensSection.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ import { useTokenListFilters } from '../../../Trending/hooks/useTokenListFilters
2727
import { useTrendingRequest } from '../../../Trending/hooks/useTrendingRequest/useTrendingRequest';
2828
import { sortTrendingTokens } from '../../../Trending/utils/sortTrendingTokens';
2929
import { strings } from '../../../../../../locales/i18n';
30-
import { BridgeViewSelectorsIDs } from '../../Views/BridgeView/BridgeView.testIds';
3130
import { getNetworkImageSource } from '../../../../../util/networks';
3231
import { NETWORK_TO_SHORT_NETWORK_NAME_MAP } from '../../../../../constants/bridge';
3332
import type { ProcessedNetwork } from '../../../../hooks/useNetworksByNamespace/useNetworksByNamespace';
3433
import type { CaipChainId } from '@metamask/utils';
3534
import { FilterButton } from '../../../Trending/components/FilterBar/FilterBar';
35+
import { BridgeTrendingTokensSectionTestIds } from './BridgeTrendingTokensSection.testIds';
3636

3737
const TOKEN_CHUNK_SIZE = 12;
3838

@@ -142,7 +142,7 @@ const BridgeTrendingTokensSection = ({
142142
<>
143143
<Box
144144
twClassName="mt-4 px-4 pb-4"
145-
testID={BridgeViewSelectorsIDs.TRENDING_TOKENS_SECTION}
145+
testID={BridgeTrendingTokensSectionTestIds.SECTION}
146146
>
147147
<Text
148148
variant={TextVariant.HeadingLg}
@@ -156,19 +156,19 @@ const BridgeTrendingTokensSection = ({
156156
twClassName="gap-2 mb-3 w-full"
157157
>
158158
<FilterButton
159-
testID={BridgeViewSelectorsIDs.TRENDING_PRICE_FILTER}
159+
testID={BridgeTrendingTokensSectionTestIds.PRICE_FILTER}
160160
onPress={() => setActiveBottomSheet('price_change')}
161161
label={priceChangeButtonText}
162162
twClassName="flex-1"
163163
/>
164164
<FilterButton
165-
testID={BridgeViewSelectorsIDs.TRENDING_NETWORK_FILTER}
165+
testID={BridgeTrendingTokensSectionTestIds.NETWORK_FILTER}
166166
onPress={() => setActiveBottomSheet('network')}
167167
label={selectedNetworkName}
168168
twClassName="flex-1"
169169
/>
170170
<FilterButton
171-
testID={BridgeViewSelectorsIDs.TRENDING_TIME_FILTER}
171+
testID={BridgeTrendingTokensSectionTestIds.TIME_FILTER}
172172
onPress={() => setActiveBottomSheet('time')}
173173
label={selectedTimeOption}
174174
twClassName="w-[72px] shrink-0"
@@ -192,7 +192,7 @@ const BridgeTrendingTokensSection = ({
192192
))}
193193
{!isLoading && hasMore ? (
194194
<Pressable
195-
testID={BridgeViewSelectorsIDs.TRENDING_SHOW_MORE}
195+
testID={BridgeTrendingTokensSectionTestIds.SHOW_MORE}
196196
onPress={loadNextChunk}
197197
style={({ pressed }) =>
198198
tw.style('mt-3 py-2 self-center', pressed && 'opacity-70')

0 commit comments

Comments
 (0)