mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
[MMI] Improved code, fixed bugs and added more tests (#19488)
* Improved code, fixed bugs and added more tests * removing tabKey prop as is causing to fail other test
This commit is contained in:
parent
2ee1e4d78b
commit
08b881880f
@ -704,6 +704,7 @@ export default class ConfirmTransactionBase extends Component {
|
|||||||
addToAddressBookIfNew,
|
addToAddressBookIfNew,
|
||||||
toAccounts,
|
toAccounts,
|
||||||
toAddress,
|
toAddress,
|
||||||
|
showCustodianDeepLink,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
const { noteText } = this.state;
|
const { noteText } = this.state;
|
||||||
|
|
||||||
@ -748,9 +749,8 @@ export default class ConfirmTransactionBase extends Component {
|
|||||||
if (!this._isMounted) {
|
if (!this._isMounted) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (txData.custodyStatus) {
|
if (txData.custodyStatus) {
|
||||||
this.props.showCustodianDeepLink({
|
showCustodianDeepLink({
|
||||||
fromAddress,
|
fromAddress,
|
||||||
closeNotification: isNotification && unapprovedTxCount === 1,
|
closeNotification: isNotification && unapprovedTxCount === 1,
|
||||||
txId: txData.id,
|
txId: txData.id,
|
||||||
|
@ -378,10 +378,12 @@ const mergeProps = (stateProps, dispatchProps, ownProps) => {
|
|||||||
...otherDispatchProps
|
...otherDispatchProps
|
||||||
} = dispatchProps;
|
} = dispatchProps;
|
||||||
|
|
||||||
let isMainBetaFlask = false;
|
let isMainBetaFlask = ownProps.isMainBetaFlask || false;
|
||||||
|
|
||||||
///: BEGIN:ONLY_INCLUDE_IN(build-main,build-beta,build-flask)
|
///: BEGIN:ONLY_INCLUDE_IN(build-main,build-beta,build-flask)
|
||||||
isMainBetaFlask = true;
|
if (ownProps.isMainBetaFlask === undefined) {
|
||||||
|
isMainBetaFlask = true;
|
||||||
|
}
|
||||||
///: END:ONLY_INCLUDE_IN
|
///: END:ONLY_INCLUDE_IN
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -233,10 +233,11 @@ describe('Confirm Transaction Base', () => {
|
|||||||
<ConfirmTransactionBase actionKey="confirm" />,
|
<ConfirmTransactionBase actionKey="confirm" />,
|
||||||
store,
|
store,
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(getByTestId('transaction-note')).toBeInTheDocument();
|
expect(getByTestId('transaction-note')).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('handleMainSubmit calls sendTransaction with correct arguments', async () => {
|
it('handleMainSubmit calls sendTransaction correctly', async () => {
|
||||||
const newMockedStore = {
|
const newMockedStore = {
|
||||||
...mockedStore,
|
...mockedStore,
|
||||||
appState: {
|
appState: {
|
||||||
@ -300,6 +301,86 @@ describe('Confirm Transaction Base', () => {
|
|||||||
expect(sendTransaction).toHaveBeenCalled();
|
expect(sendTransaction).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('handleMMISubmit calls sendTransaction correctly and then showCustodianDeepLink', async () => {
|
||||||
|
const newMockedStore = {
|
||||||
|
...mockedStore,
|
||||||
|
appState: {
|
||||||
|
...mockedStore.appState,
|
||||||
|
gasLoadingAnimationIsShowing: false,
|
||||||
|
},
|
||||||
|
confirmTransaction: {
|
||||||
|
...mockedStore.confirmTransaction,
|
||||||
|
txData: {
|
||||||
|
...mockedStore.confirmTransaction.txData,
|
||||||
|
custodyStatus: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
metamask: {
|
||||||
|
...mockedStore.metamask,
|
||||||
|
accounts: {
|
||||||
|
[mockTxParamsFromAddress]: {
|
||||||
|
balance: '0x1000000000000000000',
|
||||||
|
address: mockTxParamsFromAddress,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
gasEstimateType: GasEstimateTypes.feeMarket,
|
||||||
|
networkDetails: {
|
||||||
|
...mockedStore.metamask.networkDetails,
|
||||||
|
EIPS: {
|
||||||
|
1559: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
customGas: {
|
||||||
|
gasLimit: '0x5208',
|
||||||
|
gasPrice: '0x59682f00',
|
||||||
|
},
|
||||||
|
noGasPrice: false,
|
||||||
|
},
|
||||||
|
send: {
|
||||||
|
...mockedStore.send,
|
||||||
|
gas: {
|
||||||
|
...mockedStore.send.gas,
|
||||||
|
gasEstimateType: GasEstimateTypes.legacy,
|
||||||
|
gasFeeEstimates: {
|
||||||
|
low: '0',
|
||||||
|
medium: '1',
|
||||||
|
high: '2',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
hasSimulationError: false,
|
||||||
|
userAcknowledgedGasMissing: false,
|
||||||
|
submitting: false,
|
||||||
|
hardwareWalletRequiresConnection: false,
|
||||||
|
gasIsLoading: false,
|
||||||
|
gasFeeIsCustom: true,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
const store = configureMockStore(middleware)(newMockedStore);
|
||||||
|
const sendTransaction = jest
|
||||||
|
.fn()
|
||||||
|
.mockResolvedValue(newMockedStore.confirmTransaction.txData);
|
||||||
|
const showCustodianDeepLink = jest.fn();
|
||||||
|
const setWaitForConfirmDeepLinkDialog = jest.fn();
|
||||||
|
|
||||||
|
const { getByTestId } = renderWithProvider(
|
||||||
|
<ConfirmTransactionBase
|
||||||
|
actionKey="confirm"
|
||||||
|
sendTransaction={sendTransaction}
|
||||||
|
showCustodianDeepLink={showCustodianDeepLink}
|
||||||
|
setWaitForConfirmDeepLinkDialog={setWaitForConfirmDeepLinkDialog}
|
||||||
|
toAddress={mockPropsToAddress}
|
||||||
|
toAccounts={[{ address: mockPropsToAddress }]}
|
||||||
|
isMainBetaFlask={false}
|
||||||
|
/>,
|
||||||
|
store,
|
||||||
|
);
|
||||||
|
const confirmButton = getByTestId('page-container-footer-next');
|
||||||
|
fireEvent.click(confirmButton);
|
||||||
|
expect(setWaitForConfirmDeepLinkDialog).toHaveBeenCalled();
|
||||||
|
await expect(sendTransaction).toHaveBeenCalled();
|
||||||
|
expect(showCustodianDeepLink).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
describe('when rendering the recipient value', () => {
|
describe('when rendering the recipient value', () => {
|
||||||
describe(`when the transaction is a ${TransactionType.simpleSend} type`, () => {
|
describe(`when the transaction is a ${TransactionType.simpleSend} type`, () => {
|
||||||
it(`should use txParams.to address`, () => {
|
it(`should use txParams.to address`, () => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user