1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Ux Multichain: Hide search input for single account (#18798)

* hide search input for single account

* updated test for single account with no search

* nit fix

* nit fix

* added search test for more than one account

---------

Co-authored-by: legobeat <109787230+legobeat@users.noreply.github.com>
This commit is contained in:
Nidhi Kumari 2023-04-27 21:15:11 +05:30 committed by GitHub
parent e339afce7a
commit f7e7ff96c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 49 additions and 9 deletions

View File

@ -79,15 +79,22 @@ export const AccountListMenu = ({ onClose }) => {
> >
<Box className="multichain-account-menu"> <Box className="multichain-account-menu">
{/* Search box */} {/* Search box */}
<Box paddingLeft={4} paddingRight={4} paddingBottom={4} paddingTop={0}> {accounts.length > 1 ? (
<TextFieldSearch <Box
size={Size.SM} paddingLeft={4}
width={BLOCK_SIZES.FULL} paddingRight={4}
placeholder={t('searchAccounts')} paddingBottom={4}
value={searchQuery} paddingTop={0}
onChange={(e) => setSearchQuery(e.target.value)} >
/> <TextFieldSearch
</Box> size={Size.SM}
width={BLOCK_SIZES.FULL}
placeholder={t('searchAccounts')}
value={searchQuery}
onChange={(e) => setSearchQuery(e.target.value)}
/>
</Box>
) : null}
{/* Account list block */} {/* Account list block */}
<Box className="multichain-account-menu__list"> <Box className="multichain-account-menu__list">
{searchResults.length === 0 && searchQuery !== '' ? ( {searchResults.length === 0 && searchQuery !== '' ? (

View File

@ -100,4 +100,37 @@ describe('AccountListMenu', () => {
getByTestId('multichain-account-menu-no-results'), getByTestId('multichain-account-menu-no-results'),
).toBeInTheDocument(); ).toBeInTheDocument();
}); });
it('should not render search bar when there is only one account', () => {
const mockStore = configureStore({
activeTab: {
title: 'Eth Sign Tests',
origin: 'https://remix.ethereum.org',
protocol: 'https:',
url: 'https://remix.ethereum.org/',
},
metamask: {
...mockState.metamask,
accounts: {
'0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc': {
balance: '0x346ba7725f412cbfdb',
address: '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc',
},
},
},
});
const props = { onClose: () => jest.fn() };
const { container } = renderWithProvider(
<AccountListMenu {...props} />,
mockStore,
);
const searchBox = container.querySelector('input[type=search]');
expect(searchBox).not.toBeInTheDocument();
});
it('should render search bar when there is more than one account', () => {
render();
const searchBox = document.querySelector('input[type=search]');
expect(searchBox).toBeInTheDocument();
});
}); });