diff --git a/app/components/UI/ApprovalTagUrl/ApprovalTagUrl.test.tsx b/app/components/UI/ApprovalTagUrl/ApprovalTagUrl.test.tsx index 415cff34f01..0b260915412 100644 --- a/app/components/UI/ApprovalTagUrl/ApprovalTagUrl.test.tsx +++ b/app/components/UI/ApprovalTagUrl/ApprovalTagUrl.test.tsx @@ -1,10 +1,12 @@ import React from 'react'; import renderWithProvider from '../../../util/test/renderWithProvider'; -import ApprovalTagUrl from './ApprovalTagUrl'; +import ApprovalTagUrl, { APPROVAL_TAG_URL_ORIGIN_PILL } from './ApprovalTagUrl'; import { backgroundState } from '../../../util/test/initial-root-state'; +import { INTERNAL_ORIGINS } from '../../../constants/transaction'; const ADDRESS_MOCK = '0x1234567890abcdef1234567890abcdef12345678'; const DOMAIN_MOCK = 'metamask.github.io'; + const mockInitialState = { settings: {}, engine: { @@ -19,7 +21,7 @@ const mockInitialState = { describe('ApprovalTagUrl', () => { it('renders correctly', () => { - const { toJSON } = renderWithProvider( + const { toJSON, getByTestId } = renderWithProvider( { ); expect(toJSON()).toMatchSnapshot(); + expect(getByTestId(APPROVAL_TAG_URL_ORIGIN_PILL)).toBeDefined(); + }); + + it('does not render when origin is an internal origin', () => { + const { queryByTestId } = renderWithProvider( + , + { state: mockInitialState }, + ); + + expect(queryByTestId(APPROVAL_TAG_URL_ORIGIN_PILL)).toBeNull(); }); }); diff --git a/app/components/UI/ApprovalTagUrl/ApprovalTagUrl.tsx b/app/components/UI/ApprovalTagUrl/ApprovalTagUrl.tsx index 48ca00125da..dc7ebc8aa2d 100644 --- a/app/components/UI/ApprovalTagUrl/ApprovalTagUrl.tsx +++ b/app/components/UI/ApprovalTagUrl/ApprovalTagUrl.tsx @@ -11,6 +11,7 @@ import { selectAccountsByChainId } from '../../../selectors/accountTrackerContro import { getHost, prefixUrlWithProtocol } from '../../../util/browser'; import useFavicon from '../../hooks/useFavicon/useFavicon'; import stylesheet from './ApprovalTagUrl.styles'; +import { INTERNAL_ORIGINS } from '../../../constants/transaction'; const { ORIGIN_DEEPLINK, ORIGIN_QR_CODE } = AppConstants.DEEPLINKS; export const APPROVAL_TAG_URL_ORIGIN_PILL = 'APPROVAL_TAG_URL_ORIGIN_PILL'; @@ -76,7 +77,9 @@ const ApprovalTagUrl = ({ uri: '', }; - if (origin && !isOriginDeepLink) { + const showOrigin = origin && !isOriginDeepLink && !INTERNAL_ORIGINS.includes(origin); + + if (showOrigin) { return (