1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 01:47:00 +01:00

Fix #19437 - Prevent Connected Sites global menu item from being clicked during confirmation (#19598)

* Fix #19437 - Prevent Connected Sites global menu item from being clicked during confirmation

* Add tests
This commit is contained in:
David Walsh 2023-06-15 08:36:28 -05:00 committed by GitHub
parent b6f42bacf7
commit 276d9c74c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 0 deletions

View File

@ -77,6 +77,7 @@ export const GlobalMenu = ({ closeMenu, anchorElement }) => {
<Menu anchorElement={anchorElement} onHide={closeMenu}>
<MenuItem
iconName={IconName.Connect}
disabled={hasUnapprovedTransactions}
onClick={() => {
history.push(CONNECTED_ROUTE);
trackEvent({
@ -88,6 +89,7 @@ export const GlobalMenu = ({ closeMenu, anchorElement }) => {
});
closeMenu();
}}
data-testid="global-menu-connected-sites"
>
{t('connectedSites')}
</MenuItem>

View File

@ -67,6 +67,20 @@ describe('AccountListItem', () => {
});
});
it('disables the connected sites item when there is an active transaction', async () => {
const { getByTestId } = render();
await waitFor(() => {
expect(getByTestId('global-menu-connected-sites')).toBeDisabled();
});
});
it('enables the connected sites item when there is no active transaction', async () => {
const { getByTestId } = render({ unapprovedTxs: {} });
await waitFor(() => {
expect(getByTestId('global-menu-connected-sites')).toBeEnabled();
});
});
it('expands metamask to tab when item is clicked', async () => {
global.platform = { openExtensionInBrowser: jest.fn() };