diff --git a/ui/components/app/signature-request-original/signature-request-original.component.js b/ui/components/app/signature-request-original/signature-request-original.component.js index 9c70a99f4c90..073f6d5f61c1 100644 --- a/ui/components/app/signature-request-original/signature-request-original.component.js +++ b/ui/components/app/signature-request-original/signature-request-original.component.js @@ -28,8 +28,8 @@ import { Size, ///: BEGIN:ONLY_INCLUDE_IN(build-mmi) IconColor, - DISPLAY, - BLOCK_SIZES, + Display, + BlockSize, TextVariant, BackgroundColor, ///: END:ONLY_INCLUDE_IN @@ -37,6 +37,7 @@ import { import { ButtonLink, ///: BEGIN:ONLY_INCLUDE_IN(build-mmi) + Box, Icon, IconName, Text, @@ -45,9 +46,6 @@ import { ///: BEGIN:ONLY_INCLUDE_IN(blockaid) import BlockaidBannerAlert from '../security-provider-banner-alert/blockaid-banner-alert/blockaid-banner-alert'; ///: END:ONLY_INCLUDE_IN -///: BEGIN:ONLY_INCLUDE_IN(build-mmi) -import Box from '../../ui/box/box'; -///: END:ONLY_INCLUDE_IN import ConfirmPageContainerNavigation from '../confirm-page-container/confirm-page-container-navigation'; import SecurityProviderBannerMessage from '../security-provider-banner-message/security-provider-banner-message'; @@ -172,8 +170,8 @@ export default class SignatureRequestOriginal extends Component { this.props.fromAccount.address ? null : ( ({ @@ -52,26 +53,29 @@ const MOCK_SIGN_DATA = JSON.stringify({ }, }); +const address = '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc'; + const props = { signMessage: jest.fn(), cancelMessage: jest.fn(), txData: { msgParams: { - from: '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc', + from: address, data: MOCK_SIGN_DATA, origin: 'https://happydapp.website/governance?futarchy=true', }, type: MESSAGE_TYPE.ETH_SIGN, }, selectedAccount: { - address: '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc', + address, }, }; -const render = (txData = props.txData) => { +const render = ({ txData = props.txData, selectedAddress = address } = {}) => { const store = configureStore({ metamask: { ...mockState.metamask, + selectedAddress, }, }); @@ -145,7 +149,7 @@ describe('SignatureRequestOriginal', () => { }, type: MESSAGE_TYPE.ETH_SIGN_TYPED_DATA, }; - const { getByText } = render(txData); + const { getByText } = render({ txData }); expect(getByText('Message \\u202E test:')).toBeInTheDocument(); expect(getByText('Hi, \\u202E Alice!')).toBeInTheDocument(); }); @@ -196,4 +200,17 @@ describe('SignatureRequestOriginal', () => { render(); expect(screen.getByText('This is a deceptive request')).toBeInTheDocument(); }); + + it('should display mismatch info when selected account address and from account address are not the same', () => { + const selectedAddress = '0xeb9e64b93097bc15f01f13eae97015c57ab64823'; + const mismatchAccountText = `Your selected account (${shortenAddress( + selectedAddress, + )}) is different than the account trying to sign (${shortenAddress( + address, + )})`; + + render({ selectedAddress }); + + expect(screen.getByText(mismatchAccountText)).toBeInTheDocument(); + }); });