From c1cfb06f04a4191182f34550343399041de91b59 Mon Sep 17 00:00:00 2001 From: vinnyhoward Date: Thu, 7 Nov 2024 13:32:03 -0700 Subject: [PATCH 01/10] fix: privacy mode for account selector is now pass as a param and not a selector --- .../UI/AccountSelectorList/AccountSelectorList.tsx | 3 +-- .../AccountSelectorList/AccountSelectorList.types.ts | 4 ++++ app/components/UI/WalletAccount/WalletAccount.tsx | 6 +++++- .../Views/AccountSelector/AccountSelector.tsx | 12 ++++++++++-- .../Views/AccountSelector/AccountSelector.types.ts | 4 ++++ 5 files changed, 24 insertions(+), 5 deletions(-) diff --git a/app/components/UI/AccountSelectorList/AccountSelectorList.tsx b/app/components/UI/AccountSelectorList/AccountSelectorList.tsx index f8212feda796..e05280964f7b 100644 --- a/app/components/UI/AccountSelectorList/AccountSelectorList.tsx +++ b/app/components/UI/AccountSelectorList/AccountSelectorList.tsx @@ -11,7 +11,6 @@ import Cell, { CellVariant, } from '../../../component-library/components/Cells/Cell'; import { useStyles } from '../../../component-library/hooks'; -import { selectPrivacyMode } from '../../../selectors/preferencesController'; import { TextColor } from '../../../component-library/components/Texts/Text'; import SensitiveText, { SensitiveTextLength, @@ -47,6 +46,7 @@ const AccountSelectorList = ({ isSelectionDisabled, isRemoveAccountEnabled = false, isAutoScrollEnabled = true, + privacyMode = false, ...props }: AccountSelectorListProps) => { // TODO: Replace "any" with type @@ -64,7 +64,6 @@ const AccountSelectorList = ({ ? AvatarAccountType.Blockies : AvatarAccountType.JazzIcon, ); - const privacyMode = useSelector(selectPrivacyMode); const getKeyExtractor = ({ address }: Account) => address; const renderAccountBalances = useCallback( diff --git a/app/components/UI/AccountSelectorList/AccountSelectorList.types.ts b/app/components/UI/AccountSelectorList/AccountSelectorList.types.ts index 4059c710cc98..a2f651c718e9 100644 --- a/app/components/UI/AccountSelectorList/AccountSelectorList.types.ts +++ b/app/components/UI/AccountSelectorList/AccountSelectorList.types.ts @@ -56,4 +56,8 @@ export interface AccountSelectorListProps * Optional boolean to enable removing accounts. */ isRemoveAccountEnabled?: boolean; + /** + * Optional boolean to indicate if privacy mode is enabled. + */ + privacyMode?: boolean; } diff --git a/app/components/UI/WalletAccount/WalletAccount.tsx b/app/components/UI/WalletAccount/WalletAccount.tsx index e96ea0e1e29b..765937ac86f9 100644 --- a/app/components/UI/WalletAccount/WalletAccount.tsx +++ b/app/components/UI/WalletAccount/WalletAccount.tsx @@ -78,7 +78,11 @@ const WalletAccount = ({ style }: WalletAccountProps, ref: React.Ref) => { accountName={accountName} accountAvatarType={accountAvatarType} onPress={() => { - navigate(...createAccountSelectorNavDetails({})); + navigate( + ...createAccountSelectorNavDetails({ + privacyMode: true, + }), + ); }} accountTypeLabel={ getLabelTextByAddress(selectedAccount?.address) || undefined diff --git a/app/components/Views/AccountSelector/AccountSelector.tsx b/app/components/Views/AccountSelector/AccountSelector.tsx index 7bb4d67a1509..e5b12aea6edc 100644 --- a/app/components/Views/AccountSelector/AccountSelector.tsx +++ b/app/components/Views/AccountSelector/AccountSelector.tsx @@ -39,7 +39,8 @@ import { useMetrics } from '../../../components/hooks/useMetrics'; const AccountSelector = ({ route }: AccountSelectorProps) => { const dispatch = useDispatch(); const { trackEvent } = useMetrics(); - const { onSelectAccount, checkBalanceError } = route.params || {}; + const { onSelectAccount, checkBalanceError, privacyMode } = + route.params || {}; const { reloadAccounts } = useSelector((state: RootState) => state.accounts); // TODO: Replace "any" with type @@ -92,6 +93,7 @@ const AccountSelector = ({ route }: AccountSelectorProps) => { accounts={accounts} ensByAccountAddress={ensByAccountAddress} isRemoveAccountEnabled + privacyMode={privacyMode} testID={AccountListViewSelectorsIDs.ACCOUNT_LIST_ID} /> @@ -106,7 +108,13 @@ const AccountSelector = ({ route }: AccountSelectorProps) => { ), - [accounts, _onSelectAccount, ensByAccountAddress, onRemoveImportedAccount], + [ + accounts, + _onSelectAccount, + ensByAccountAddress, + onRemoveImportedAccount, + privacyMode, + ], ); const renderAddAccountActions = useCallback( diff --git a/app/components/Views/AccountSelector/AccountSelector.types.ts b/app/components/Views/AccountSelector/AccountSelector.types.ts index 99f79c3bc402..628d72b288d6 100644 --- a/app/components/Views/AccountSelector/AccountSelector.types.ts +++ b/app/components/Views/AccountSelector/AccountSelector.types.ts @@ -35,6 +35,10 @@ export interface AccountSelectorParams { * @param balance - The ticker balance of an account in wei and hex string format. */ checkBalanceError?: UseAccountsParams['checkBalanceError']; + /** + * Optional boolean to indicate if privacy mode is enabled. + */ + privacyMode?: boolean; } /** From 4e8b9fbbe37053eceb51b6095187e1852a0a5c2f Mon Sep 17 00:00:00 2001 From: vinnyhoward Date: Thu, 7 Nov 2024 13:43:02 -0700 Subject: [PATCH 02/10] fix: add selector --- app/components/UI/WalletAccount/WalletAccount.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/components/UI/WalletAccount/WalletAccount.tsx b/app/components/UI/WalletAccount/WalletAccount.tsx index 765937ac86f9..8aa6f499ea67 100644 --- a/app/components/UI/WalletAccount/WalletAccount.tsx +++ b/app/components/UI/WalletAccount/WalletAccount.tsx @@ -5,6 +5,7 @@ import { useNavigation } from '@react-navigation/native'; import { View } from 'react-native'; // External dependencies +import { selectPrivacyMode } from '../../../selectors/preferencesController'; import { IconName } from '../../../component-library/components/Icons/Icon'; import PickerAccount from '../../../component-library/components/Pickers/PickerAccount'; import { AvatarAccountType } from '../../../component-library/components/Avatars/Avatar/variants/AvatarAccount'; @@ -34,6 +35,7 @@ const WalletAccount = ({ style }: WalletAccountProps, ref: React.Ref) => { const yourAccountRef = useRef(null); const accountActionsRef = useRef(null); const selectedAccount = useSelector(selectSelectedInternalAccount); + const privacyMode = useSelector(selectPrivacyMode); const { ensName } = useEnsNameByAddress(selectedAccount?.address); const defaultName = selectedAccount?.metadata?.name; const accountName = useMemo( @@ -80,7 +82,7 @@ const WalletAccount = ({ style }: WalletAccountProps, ref: React.Ref) => { onPress={() => { navigate( ...createAccountSelectorNavDetails({ - privacyMode: true, + privacyMode, }), ); }} From 24b64165d02dc8358ff768928a5effa94a2c4e5f Mon Sep 17 00:00:00 2001 From: vinnyhoward Date: Thu, 7 Nov 2024 14:06:56 -0700 Subject: [PATCH 03/10] test: update test --- app/components/UI/WalletAccount/WalletAccount.test.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/components/UI/WalletAccount/WalletAccount.test.tsx b/app/components/UI/WalletAccount/WalletAccount.test.tsx index 484786089159..ae49c8e032f7 100644 --- a/app/components/UI/WalletAccount/WalletAccount.test.tsx +++ b/app/components/UI/WalletAccount/WalletAccount.test.tsx @@ -126,7 +126,9 @@ describe('WalletAccount', () => { fireEvent.press(getByTestId(WalletViewSelectorsIDs.ACCOUNT_ICON)); expect(mockNavigate).toHaveBeenCalledWith( - ...createAccountSelectorNavDetails({}), + ...createAccountSelectorNavDetails({ + privacyMode: false, + }), ); }); it('displays the correct account name', () => { From adc745cc394e3c0083d03551888598952902296c Mon Sep 17 00:00:00 2001 From: vinnyhoward Date: Thu, 7 Nov 2024 15:15:25 -0700 Subject: [PATCH 04/10] test: update --- .../AccountSelector.test.tsx | 51 +++++++++++++++++-- 1 file changed, 48 insertions(+), 3 deletions(-) diff --git a/app/components/UI/AccountSelectorList/AccountSelector.test.tsx b/app/components/UI/AccountSelectorList/AccountSelector.test.tsx index 4403184965bb..a144c724e889 100644 --- a/app/components/UI/AccountSelectorList/AccountSelector.test.tsx +++ b/app/components/UI/AccountSelectorList/AccountSelector.test.tsx @@ -16,6 +16,7 @@ import { } from '../../../util/test/accountsControllerTestUtils'; import { mockNetworkState } from '../../../util/test/network'; import { CHAIN_IDS } from '@metamask/transaction-controller'; +import { AccountSelectorListProps } from './AccountSelectorList.types'; const BUSINESS_ACCOUNT = '0xC4955C0d639D99699Bfd7Ec54d9FaFEe40e4D272'; const PERSONAL_ACCOUNT = '0xd018538C87232FF95acbCe4870629b75640a78E7'; @@ -73,8 +74,9 @@ const initialState = { const onSelectAccount = jest.fn(); const onRemoveImportedAccount = jest.fn(); - -const AccountSelectorListUseAccounts = () => { +const AccountSelectorListUseAccounts: React.FC = ({ + privacyMode = false, +}) => { const { accounts, ensByAccountAddress } = useAccounts(); return ( { accounts={accounts} ensByAccountAddress={ensByAccountAddress} isRemoveAccountEnabled + privacyMode={privacyMode} /> ); }; @@ -109,7 +112,7 @@ const renderComponent = ( // eslint-disable-next-line @typescript-eslint/no-explicit-any state: any = {}, AccountSelectorListTest = AccountSelectorListUseAccounts, -) => renderWithProvider(, { state }); +) => renderWithProvider(, { state }); describe('AccountSelectorList', () => { beforeEach(() => { @@ -229,4 +232,46 @@ describe('AccountSelectorList', () => { expect(snapTag).toBeDefined(); }); }); + it('Text is not hidden when privacy mode is off', async () => { + const state = { + ...initialState, + privacyMode: false, + }; + + const { queryByTestId } = renderComponent(state); + + await waitFor(() => { + const businessAccountItem = queryByTestId( + `${AccountListViewSelectorsIDs.ACCOUNT_BALANCE_BY_ADDRESS_TEST_ID}-${BUSINESS_ACCOUNT}`, + ); + + expect(within(businessAccountItem).getByText(regex.eth(1))).toBeDefined(); + expect( + within(businessAccountItem).getByText(regex.usd(3200)), + ).toBeDefined(); + + expect(within(businessAccountItem).queryByText('••••••')).toBeNull(); + }); + }); + it('Text is hidden when privacy mode is on', async () => { + const state = { + ...initialState, + privacyMode: true, + }; + + const { queryByTestId } = renderComponent(state); + + await waitFor(() => { + const businessAccountItem = queryByTestId( + `${AccountListViewSelectorsIDs.ACCOUNT_BALANCE_BY_ADDRESS_TEST_ID}-${BUSINESS_ACCOUNT}`, + ); + + expect(within(businessAccountItem).queryByText(regex.eth(1))).toBeNull(); + expect( + within(businessAccountItem).queryByText(regex.usd(3200)), + ).toBeNull(); + + expect(within(businessAccountItem).getByText('••••••')).toBeDefined(); + }); + }); }); From 9baa15e72387d554a3fcc4931400e621ef405358 Mon Sep 17 00:00:00 2001 From: vinnyhoward Date: Thu, 7 Nov 2024 15:39:55 -0700 Subject: [PATCH 05/10] fix: renaming test file to match component file --- .../{AccountSelector.test.tsx => AccountSelectorList.test.tsx} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename app/components/UI/AccountSelectorList/{AccountSelector.test.tsx => AccountSelectorList.test.tsx} (100%) diff --git a/app/components/UI/AccountSelectorList/AccountSelector.test.tsx b/app/components/UI/AccountSelectorList/AccountSelectorList.test.tsx similarity index 100% rename from app/components/UI/AccountSelectorList/AccountSelector.test.tsx rename to app/components/UI/AccountSelectorList/AccountSelectorList.test.tsx From 02f1a9dc471de266acac9bbff48092c6ad7b53d9 Mon Sep 17 00:00:00 2001 From: vinnyhoward Date: Thu, 7 Nov 2024 16:01:22 -0700 Subject: [PATCH 06/10] fix: update snaps --- ...ntSelector.test.tsx.snap => AccountSelectorList.test.tsx.snap} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename app/components/UI/AccountSelectorList/__snapshots__/{AccountSelector.test.tsx.snap => AccountSelectorList.test.tsx.snap} (100%) diff --git a/app/components/UI/AccountSelectorList/__snapshots__/AccountSelector.test.tsx.snap b/app/components/UI/AccountSelectorList/__snapshots__/AccountSelectorList.test.tsx.snap similarity index 100% rename from app/components/UI/AccountSelectorList/__snapshots__/AccountSelector.test.tsx.snap rename to app/components/UI/AccountSelectorList/__snapshots__/AccountSelectorList.test.tsx.snap From cc2fad0ad991e60f37e446b1c68bfdaac5f6f999 Mon Sep 17 00:00:00 2001 From: vinnyhoward Date: Fri, 8 Nov 2024 13:07:01 -0700 Subject: [PATCH 07/10] test: update tests for account selector --- .../AccountSelector/AccountSelector.test.tsx | 107 ++++ .../AccountSelector.test.tsx.snap | 548 ++++++++++++++++++ 2 files changed, 655 insertions(+) create mode 100644 app/components/Views/AccountSelector/AccountSelector.test.tsx create mode 100644 app/components/Views/AccountSelector/__snapshots__/AccountSelector.test.tsx.snap diff --git a/app/components/Views/AccountSelector/AccountSelector.test.tsx b/app/components/Views/AccountSelector/AccountSelector.test.tsx new file mode 100644 index 000000000000..632607a3f77b --- /dev/null +++ b/app/components/Views/AccountSelector/AccountSelector.test.tsx @@ -0,0 +1,107 @@ +import React from 'react'; +import { screen } from '@testing-library/react-native'; +import AccountSelector from './AccountSelector'; +import { renderScreen } from '../../../util/test/renderWithProvider'; +import { AccountListViewSelectorsIDs } from '../../../../e2e/selectors/AccountListView.selectors'; +import Routes from '../../../constants/navigation/Routes'; +import { + AccountSelectorParams, + AccountSelectorProps, +} from './AccountSelector.types'; + +const mockAccounts = [ + { + address: '0xc4966c0d659d99699bfd7eb54d8fafee40e4a756', + balance: '0x0', + name: 'Account 1', + }, + { + address: '0x2B5634C42055806a59e9107ED44D43c426E58258', + balance: '0x0', + name: 'Account 2', + }, +]; + +const mockEnsByAccountAddress = { + '0xc4966c0d659d99699bfd7eb54d8fafee40e4a756': 'test.eth', +}; + +jest.mock('../../../components/hooks/useAccounts', () => ({ + useAccounts: jest.fn().mockReturnValue({ + accounts: mockAccounts, + ensByAccountAddress: mockEnsByAccountAddress, + isLoading: false, + }), +})); + +jest.mock('../../../core/Engine', () => ({ + setSelectedAddress: jest.fn(), +})); + +const mockTrackEvent = jest.fn(); +jest.mock('../../../components/hooks/useMetrics', () => ({ + useMetrics: () => ({ + trackEvent: mockTrackEvent, + }), +})); + +const mockRoute: AccountSelectorProps['route'] = { + params: { + onSelectAccount: jest.fn((address: string) => address), + checkBalanceError: (balance: string) => balance, + privacyMode: false, + } as AccountSelectorParams, +}; + +const AccountSelectorWrapper = () => ; + +describe('AccountSelector', () => { + beforeEach(() => { + jest.clearAllMocks(); + }); + + it('should render correctly', () => { + const wrapper = renderScreen( + AccountSelectorWrapper, + { + name: Routes.SHEET.ACCOUNT_SELECTOR, + options: {}, + }, + {}, + mockRoute.params, + ); + expect(wrapper.toJSON()).toMatchSnapshot(); + }); + + it('should display accounts list', () => { + renderScreen( + AccountSelectorWrapper, + { + name: Routes.SHEET.ACCOUNT_SELECTOR, + }, + {}, + mockRoute.params, + ); + + const accountsList = screen.getByTestId( + AccountListViewSelectorsIDs.ACCOUNT_LIST_ID, + ); + expect(accountsList).toBeDefined(); + }); + + it('should display add account button', () => { + renderScreen( + AccountSelectorWrapper, + { + name: Routes.SHEET.ACCOUNT_SELECTOR, + }, + {}, + mockRoute.params, + ); + + const addButton = screen.getByTestId( + AccountListViewSelectorsIDs.ACCOUNT_LIST_ADD_BUTTON_ID, + ); + expect(addButton).toBeDefined(); + }); +}); diff --git a/app/components/Views/AccountSelector/__snapshots__/AccountSelector.test.tsx.snap b/app/components/Views/AccountSelector/__snapshots__/AccountSelector.test.tsx.snap new file mode 100644 index 000000000000..9b93f6abe024 --- /dev/null +++ b/app/components/Views/AccountSelector/__snapshots__/AccountSelector.test.tsx.snap @@ -0,0 +1,548 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AccountSelector should render correctly 1`] = ` + + + + + + + + + + + + + AccountSelector + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Accounts + + + + + + + + + + Add account or hardware wallet + + + + + + + + + + + + + + + + +`; From a0fecc63869aa7729fee616c198f8cf5a699d86d Mon Sep 17 00:00:00 2001 From: vinnyhoward Date: Fri, 8 Nov 2024 14:32:49 -0700 Subject: [PATCH 08/10] fix: resolve merge conflict --- .../{AccountSelectorList.test.tsx => AccountSelector.test.tsx} | 0 ...ntSelectorList.test.tsx.snap => AccountSelector.test.tsx.snap} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename app/components/UI/AccountSelectorList/{AccountSelectorList.test.tsx => AccountSelector.test.tsx} (100%) rename app/components/UI/AccountSelectorList/__snapshots__/{AccountSelectorList.test.tsx.snap => AccountSelector.test.tsx.snap} (100%) diff --git a/app/components/UI/AccountSelectorList/AccountSelectorList.test.tsx b/app/components/UI/AccountSelectorList/AccountSelector.test.tsx similarity index 100% rename from app/components/UI/AccountSelectorList/AccountSelectorList.test.tsx rename to app/components/UI/AccountSelectorList/AccountSelector.test.tsx diff --git a/app/components/UI/AccountSelectorList/__snapshots__/AccountSelectorList.test.tsx.snap b/app/components/UI/AccountSelectorList/__snapshots__/AccountSelector.test.tsx.snap similarity index 100% rename from app/components/UI/AccountSelectorList/__snapshots__/AccountSelectorList.test.tsx.snap rename to app/components/UI/AccountSelectorList/__snapshots__/AccountSelector.test.tsx.snap From 1edc8b4abd7dfbfce134b61587727af6c5a930f2 Mon Sep 17 00:00:00 2001 From: vinnyhoward Date: Fri, 8 Nov 2024 14:40:19 -0700 Subject: [PATCH 09/10] test: updated wallet actions tests --- .../UI/WalletAccount/WalletAccount.test.tsx | 59 ++++++++++++++++++- 1 file changed, 56 insertions(+), 3 deletions(-) diff --git a/app/components/UI/WalletAccount/WalletAccount.test.tsx b/app/components/UI/WalletAccount/WalletAccount.test.tsx index 08c4235034cc..5d0ec77edcbd 100644 --- a/app/components/UI/WalletAccount/WalletAccount.test.tsx +++ b/app/components/UI/WalletAccount/WalletAccount.test.tsx @@ -57,6 +57,9 @@ const mockInitialState: DeepPartial = { engine: { backgroundState: { ...backgroundState, + PreferencesController: { + privacyMode: false, + }, AccountsController: MOCK_ACCOUNTS_CONTROLLER_STATE, NetworkController: { ...mockNetworkState({ @@ -101,14 +104,21 @@ jest.mock('../../../util/ENSUtils', () => ({ }), })); +const mockSelector = jest + .fn() + .mockImplementation((callback) => callback(mockInitialState)); + jest.mock('react-redux', () => ({ ...jest.requireActual('react-redux'), - useSelector: jest - .fn() - .mockImplementation((callback) => callback(mockInitialState)), + // eslint-disable-next-line @typescript-eslint/no-explicit-any + useSelector: (selector: any) => mockSelector(selector), })); describe('WalletAccount', () => { + beforeEach(() => { + mockSelector.mockImplementation((callback) => callback(mockInitialState)); + }); + it('renders correctly', () => { const { toJSON } = renderWithProvider(, { state: mockInitialState, @@ -173,4 +183,47 @@ describe('WalletAccount', () => { expect(getByText(customAccountName)).toBeDefined(); }); }); + + it('should navigate to account selector with privacy mode disabled', () => { + const { getByTestId } = renderWithProvider(, { + state: mockInitialState, + }); + + fireEvent.press(getByTestId(WalletViewSelectorsIDs.ACCOUNT_ICON)); + expect(mockNavigate).toHaveBeenCalledWith( + ...createAccountSelectorNavDetails({ + privacyMode: false, + }), + ); + }); + + it('should navigate to account selector with privacy mode enabled', () => { + const stateWithPrivacyMode = { + ...mockInitialState, + engine: { + ...mockInitialState.engine, + backgroundState: { + ...mockInitialState.engine?.backgroundState, + PreferencesController: { + privacyMode: true, + }, + }, + }, + }; + + mockSelector.mockImplementation((callback) => + callback(stateWithPrivacyMode), + ); + + const { getByTestId } = renderWithProvider(, { + state: stateWithPrivacyMode, + }); + + fireEvent.press(getByTestId(WalletViewSelectorsIDs.ACCOUNT_ICON)); + expect(mockNavigate).toHaveBeenCalledWith( + ...createAccountSelectorNavDetails({ + privacyMode: true, + }), + ); + }); }); From 7c6dae31479118b86c36ff46538792cbca6dea39 Mon Sep 17 00:00:00 2001 From: vinnyhoward Date: Fri, 8 Nov 2024 16:18:28 -0700 Subject: [PATCH 10/10] test: update tests for account selector --- .../AccountSelector/AccountSelector.test.tsx | 64 ++++++++++++++++++- 1 file changed, 61 insertions(+), 3 deletions(-) diff --git a/app/components/Views/AccountSelector/AccountSelector.test.tsx b/app/components/Views/AccountSelector/AccountSelector.test.tsx index 632607a3f77b..c0382a688038 100644 --- a/app/components/Views/AccountSelector/AccountSelector.test.tsx +++ b/app/components/Views/AccountSelector/AccountSelector.test.tsx @@ -8,6 +8,10 @@ import { AccountSelectorParams, AccountSelectorProps, } from './AccountSelector.types'; +import { + MOCK_ACCOUNTS_CONTROLLER_STATE, + expectedUuid2, +} from '../../../util/test/accountsControllerTestUtils'; const mockAccounts = [ { @@ -26,6 +30,54 @@ const mockEnsByAccountAddress = { '0xc4966c0d659d99699bfd7eb54d8fafee40e4a756': 'test.eth', }; +const mockInitialState = { + engine: { + backgroundState: { + KeyringController: { + keyrings: [ + { + type: 'HD Key Tree', + accounts: [ + '0xc4966c0d659d99699bfd7eb54d8fafee40e4a756', + '0x2B5634C42055806a59e9107ED44D43c426E58258', + ], + }, + ], + }, + AccountsController: { + ...MOCK_ACCOUNTS_CONTROLLER_STATE, + internalAccounts: { + ...MOCK_ACCOUNTS_CONTROLLER_STATE.internalAccounts, + accounts: { + ...MOCK_ACCOUNTS_CONTROLLER_STATE.internalAccounts.accounts, + [expectedUuid2]: { + ...MOCK_ACCOUNTS_CONTROLLER_STATE.internalAccounts.accounts[ + expectedUuid2 + ], + methods: [], + }, + }, + }, + }, + }, + }, + accounts: { + reloadAccounts: false, + }, + settings: { + useBlockieIcon: false, + }, +}; + +// Mock the Redux dispatch +const mockDispatch = jest.fn(); +jest.mock('react-redux', () => ({ + ...jest.requireActual('react-redux'), + useDispatch: () => mockDispatch, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + useSelector: (selector: any) => selector(mockInitialState), +})); + jest.mock('../../../components/hooks/useAccounts', () => ({ useAccounts: jest.fn().mockReturnValue({ accounts: mockAccounts, @@ -67,7 +119,9 @@ describe('AccountSelector', () => { name: Routes.SHEET.ACCOUNT_SELECTOR, options: {}, }, - {}, + { + state: mockInitialState, + }, mockRoute.params, ); expect(wrapper.toJSON()).toMatchSnapshot(); @@ -79,7 +133,9 @@ describe('AccountSelector', () => { { name: Routes.SHEET.ACCOUNT_SELECTOR, }, - {}, + { + state: mockInitialState, + }, mockRoute.params, ); @@ -95,7 +151,9 @@ describe('AccountSelector', () => { { name: Routes.SHEET.ACCOUNT_SELECTOR, }, - {}, + { + state: mockInitialState, + }, mockRoute.params, );