Skip to content

Commit

Permalink
fix: fix sticky autodetection banner
Browse files Browse the repository at this point in the history
  • Loading branch information
salimtb committed Dec 10, 2024
1 parent 1c2755c commit d190575
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`DetectedTokenIgnoredPopover should match snapshot for ignore mode 1`] = `<DocumentFragment />`;

exports[`DetectedTokenIgnoredPopover should match snapshot for import mode 1`] = `<DocumentFragment />`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import React from 'react';
import { render, screen, fireEvent } from '@testing-library/react';
import DetectedTokenIgnoredPopover from './detected-token-ignored-popover';

describe('DetectedTokenIgnoredPopover', () => {
const defaultProps = {
partiallyIgnoreDetectedTokens: false,
onCancelIgnore: jest.fn(),
handleClearTokensSelection: jest.fn(),
isOpen: true,
};

const renderComponent = (props = {}) =>
render(<DetectedTokenIgnoredPopover {...defaultProps} {...props} />);

it('should match snapshot for ignore mode', () => {
const { asFragment } = renderComponent();
expect(asFragment()).toMatchSnapshot();
});

it('should match snapshot for import mode', () => {
const { asFragment } = renderComponent({
partiallyIgnoreDetectedTokens: true,
});
expect(asFragment()).toMatchSnapshot();
});

it('should call handleClearTokensSelection when the confirm button is clicked', () => {
renderComponent();
const confirmButton = screen.getByTestId(
'detected-token-ignored-popover-confirm-button',
);
fireEvent.click(confirmButton);
expect(defaultProps.handleClearTokensSelection).toHaveBeenCalled();
});
});
12 changes: 7 additions & 5 deletions ui/components/app/detected-token/detected-token.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,14 +210,16 @@ const DetectedToken = ({ setShowDetectedTokens }) => {

const promises = Object.entries(groupedByChainId).map(
async ([chainId, tokens]) => {
const chainConfig = allNetworks[chainId];
const { defaultRpcEndpointIndex } = chainConfig;
const { networkClientId: networkInstanceId } =
chainConfig.rpcEndpoints[defaultRpcEndpointIndex];
const { defaultRpcEndpointIndex, rpcEndpoints } =
allNetworks[chainId];
const networkInstanceId =
rpcEndpoints[defaultRpcEndpointIndex].networkClientId;

const tokensToIgnore = tokens.map((token) => token.address);

await dispatch(
ignoreTokens({
tokensToIgnore: tokens,
tokensToIgnore,
dontShowLoadingIndicator: true,
networkClientId: networkInstanceId,
}),
Expand Down

0 comments on commit d190575

Please sign in to comment.