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

View File

@ -100,4 +100,37 @@ describe('AccountListMenu', () => {
getByTestId('multichain-account-menu-no-results'),
).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();
});
});