Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix non regression tests #11768

Merged
merged 42 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
17636b4
fix: fix non regression tests
salimtb Oct 13, 2024
164b703
fix: move uri js as dependency
salimtb Oct 14, 2024
c72c75d
fix Android: get to Add custom RPC form
cortisiko Oct 15, 2024
04a31f5
fix: android
salimtb Oct 14, 2024
8aec07a
fix: fix bottom sheet
salimtb Oct 15, 2024
5bcc7db
fix: fix temp salim
salimtb Oct 15, 2024
ab9f10a
fix: redirect to wallet page after select rpc
salimtb Oct 15, 2024
dc9d760
fix: temp fix non regression tests
salimtb Oct 16, 2024
a0811d1
fix: improve migration code quality
salimtb Oct 16, 2024
314f13c
fix: increase unit test coverage
salimtb Oct 16, 2024
e6b39af
fixx: fix unit tests
salimtb Oct 16, 2024
79ac1c2
fix: increase unit tests
salimtb Oct 16, 2024
03546d6
fix: test validateSymbol
salimtb Oct 16, 2024
2bb875d
fix: increase test coverage
salimtb Oct 16, 2024
0c34c3e
fix: increase tests coverage
salimtb Oct 16, 2024
4aa69fc
fix: add test for onRpcUrlChangeWithName
salimtb Oct 16, 2024
abd5daf
fix: test handleNetworkUpdate
salimtb Oct 16, 2024
7d59860
fix: increase test coverage
salimtb Oct 16, 2024
b5f5ea6
fix: increase test for network selector
salimtb Oct 16, 2024
5809ba9
Merge branch 'main' into salim/fix-non-regression-tests
salimtb Oct 16, 2024
9cecfde
fix: fix test coverage
salimtb Oct 16, 2024
7684162
fix: fix refacto
salimtb Oct 16, 2024
1880ab5
fix: fix UI
salimtb Oct 16, 2024
4560c83
fix: fix PR comments
salimtb Oct 17, 2024
75c5516
Merge branch 'main' into salim/fix-non-regression-tests
salimtb Oct 17, 2024
8495255
fix: fix QA issues
salimtb Oct 17, 2024
834686b
fix: fix PR comments
salimtb Oct 18, 2024
9d528d6
Merge branch 'main' into salim/fix-non-regression-tests
salimtb Oct 18, 2024
812e609
fix: fix QA issues
salimtb Oct 18, 2024
472e2a4
fix: fix QA issues
salimtb Oct 18, 2024
1b70381
fix: fix QA issues
salimtb Oct 19, 2024
2520e5b
fix: fix QA issues
salimtb Oct 20, 2024
8b4700a
fix: fix QA issues
salimtb Oct 20, 2024
9a72735
fix: increase test coverage
salimtb Oct 20, 2024
66f1f57
fix: fix test coverage
salimtb Oct 20, 2024
7f18d22
fix: increase test coverage
salimtb Oct 20, 2024
e1a5844
fix: increase test coverage
salimtb Oct 20, 2024
63ca9a5
fix: fix QA issues
salimtb Oct 21, 2024
fe8b868
Merge branch 'main' into salim/fix-non-regression-tests
salimtb Oct 21, 2024
b2354d7
Merge branch 'main' into salim/fix-non-regression-tests
salimtb Oct 22, 2024
6c3289d
Merge branch 'main' into salim/fix-non-regression-tests
salimtb Oct 22, 2024
5e97c4d
Merge branch 'main' into salim/fix-non-regression-tests
salimtb Oct 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions app/components/UI/ReusableModal/ReusableModal.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ export interface ReusableModalProps extends ViewProps {
* @default true
*/
isInteractable?: boolean;

/**
* Determines whether the navigation should revert to the previous path when the modal is closed.
* If set to `true`, closing the modal will trigger the navigation to go back to the previous screen or route.
* If set to `false`, the navigation will remain on the current path when the modal is closed.
* @default true
*/
shouldGoBack?: boolean;
}

export type ReusableModalPostCallback = () => void;
Expand Down
18 changes: 15 additions & 3 deletions app/components/UI/ReusableModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,17 @@ import {
export type { ReusableModalRef } from './ReusableModal.types';

const ReusableModal = forwardRef<ReusableModalRef, ReusableModalProps>(
({ children, onDismiss, isInteractable = true, style, ...props }, ref) => {
(
{
children,
onDismiss,
isInteractable = true,
shouldGoBack = true,
style,
...props
},
ref,
) => {
const postCallback = useRef<ReusableModalPostCallback>();
const { height: screenHeight } = useWindowDimensions();
const { styles } = useStyles(styleSheet, {});
Expand All @@ -66,10 +76,12 @@ const ReusableModal = forwardRef<ReusableModalRef, ReusableModalProps>(

const onHidden = useCallback(() => {
// Sheet is automatically unmounted from the navigation stack.
navigation.goBack();
if (shouldGoBack) {
navigation.goBack();
}
onDismiss?.(!!postCallback.current);
postCallback.current?.();
}, [navigation, onDismiss]);
}, [navigation, onDismiss, shouldGoBack]);

const gestureHandler = useAnimatedGestureHandler<
PanGestureHandlerGestureEvent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ const AccountPermissionsConnected = ({
)}
{!isMultichainVersion1Enabled && (
<PickerNetwork
label={networkName}
label={providerConfig?.nickname || networkName}
imageSource={networkImageSource}
onPress={switchNetwork}
style={styles.networkPicker}
Expand Down
72 changes: 72 additions & 0 deletions app/components/Views/NetworkSelector/NetworkSelector.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,20 @@ describe('Network Selector', () => {
expect(toJSON()).toMatchSnapshot();
});

it('renders correctly when network UI redesign is enabled', () => {
(isNetworkUiRedesignEnabled as jest.Mock).mockImplementation(() => true);
const { toJSON } = renderComponent(initialState);
expect(toJSON()).toMatchSnapshot();
});

it('shows popular networks when UI redesign is enabled', () => {
(isNetworkUiRedesignEnabled as jest.Mock).mockImplementation(() => true);
const { getByText } = renderComponent(initialState);

const popularNetworksTitle = getByText('Additional networks');
expect(popularNetworksTitle).toBeTruthy();
});

it('changes network when another network cell is pressed', async () => {
(isNetworkUiRedesignEnabled as jest.Mock).mockImplementation(() => false);
const { getByText } = renderComponent(initialState);
Expand Down Expand Up @@ -387,4 +401,62 @@ describe('Network Selector', () => {
fireEvent.press(rpcOption);
});
});

it('filters networks correctly when searching', () => {
(isNetworkUiRedesignEnabled as jest.Mock).mockImplementation(() => true);
const { getByPlaceholderText, queryByText } = renderComponent(initialState);

const searchInput = getByPlaceholderText('Search');

// Simulate entering a search term
fireEvent.changeText(searchInput, 'Polygon');

// Polygon should appear, but others should not
expect(queryByText('Polygon Mainnet')).toBeTruthy();
expect(queryByText('Avalanche Mainnet C-Chain')).toBeNull();

// Clear search and check if all networks appear
fireEvent.changeText(searchInput, '');
expect(queryByText('Polygon Mainnet')).toBeTruthy();
expect(queryByText('Avalanche Mainnet C-Chain')).toBeTruthy();
});

it('shows popular networks when network UI redesign is enabled', () => {
(isNetworkUiRedesignEnabled as jest.Mock).mockImplementation(() => true);
const { getByText } = renderComponent(initialState);

// Check that the additional networks section is rendered
const popularNetworksTitle = getByText('Additional networks');
expect(popularNetworksTitle).toBeTruthy();
});

it('opens the multi-RPC selection modal correctly', async () => {
(isNetworkUiRedesignEnabled as jest.Mock).mockImplementation(() => true);
const { getByText } = renderComponent(initialState);

const polygonCell = getByText('Polygon Mainnet');

// Open the modal
fireEvent.press(polygonCell);
await waitFor(() => {
const rpcOption = getByText('polygon-mainnet.infura.io/v3');
expect(rpcOption).toBeTruthy();
});
});

it('toggles test networks visibility when switch is used', () => {
(isNetworkUiRedesignEnabled as jest.Mock).mockImplementation(() => true);
const { getByTestId } = renderComponent(initialState);
const testNetworksSwitch = getByTestId(
NetworkListModalSelectorsIDs.TEST_NET_TOGGLE,
);

// Toggle the switch on
fireEvent(testNetworksSwitch, 'onValueChange', true);
expect(setShowTestNetworksSpy).toBeCalledWith(true);

// Toggle the switch off
fireEvent(testNetworksSwitch, 'onValueChange', false);
expect(setShowTestNetworksSpy).toBeCalledWith(false);
});
});
Loading
Loading