From 96436bef3f4392d7534861a1c7fad6fe2ff3a673 Mon Sep 17 00:00:00 2001 From: Nicholas Gambino Date: Wed, 16 Oct 2024 08:08:52 -1000 Subject: [PATCH] fix: Consider Error boundary during Wallet rendering process --- .../Wallet/__snapshots__/index.test.tsx.snap | 659 ++++++++++-------- app/components/Views/Wallet/index.test.tsx | 73 -- app/components/Views/Wallet/index.tsx | 2 +- 3 files changed, 358 insertions(+), 376 deletions(-) diff --git a/app/components/Views/Wallet/__snapshots__/index.test.tsx.snap b/app/components/Views/Wallet/__snapshots__/index.test.tsx.snap index 588a2afdf64..3ec9cf2c174 100644 --- a/app/components/Views/Wallet/__snapshots__/index.test.tsx.snap +++ b/app/components/Views/Wallet/__snapshots__/index.test.tsx.snap @@ -479,408 +479,463 @@ exports[`Wallet should render correctly 1`] = ` } } > - - - - - - - An error occurred - - - Your information can't be shown. Don’t worry, your wallet and funds are safe. - - + } + > - - View: Wallet -TypeError: Cannot read properties of undefined (reading 'tabs') - - - - + + + Basic functionality is off + + - -  - - - Try again + Turn on basic functionality - + - + + - - - Please report this issue so we can fix it: - - - - -  - - - Take a screenshot of this screen. - - + + + + + + + + + -  - - - - Copy + Account 1 - - the error message to clipboard. - + + + + + + + - -  - - - Submit a ticket - - + + - here. - - - Please include the error message and the screenshot. - - - + 0xC495...D272 + + -  - - - Send us a bug report - - - here. - - - Please include details about what happened. - + width={16} + /> + + - - If this error persists, - - - save your Secret Recovery Phrase - - - & re-install the app. Note: you can NOT restore your wallet without your Secret Recovery Phrase. - + width={16} + /> + - - + + diff --git a/app/components/Views/Wallet/index.test.tsx b/app/components/Views/Wallet/index.test.tsx index cde11aade66..9b008db9496 100644 --- a/app/components/Views/Wallet/index.test.tsx +++ b/app/components/Views/Wallet/index.test.tsx @@ -8,7 +8,6 @@ import { backgroundState } from '../../../util/test/initial-root-state'; import { createMockAccountsControllerState } from '../../../util/test/accountsControllerTestUtils'; import { WalletViewSelectorsIDs } from '../../../../e2e/selectors/wallet/WalletView.selectors'; import { CommonSelectorsIDs } from '../../../../e2e/selectors/Common.selectors'; -import { BN } from 'ethereumjs-util'; const MOCK_ADDRESS = '0xc4955c0d639d99699bfd7ec54d9fafee40e4d272'; @@ -31,9 +30,6 @@ jest.mock('../../../core/Engine', () => ({ }, }, }, - TokensController: { - ignoreTokens: jest.fn(() => Promise.resolve()), - }, TokenRatesController: { poll: jest.fn(), }, @@ -87,60 +83,6 @@ const mockInitialState = { AccountsController: { ...MOCK_ACCOUNTS_CONTROLLER_STATE, }, - TokensController: { - tokens: [ - { - name: 'Ethereum', - symbol: 'ETH', - address: '0x0', - decimals: 18, - isETH: true, - - balanceFiat: '< $0.01', - iconUrl: '', - }, - { - name: 'Bat', - symbol: 'BAT', - address: '0x01', - decimals: 18, - balanceFiat: '$0', - iconUrl: '', - }, - { - name: 'Link', - symbol: 'LINK', - address: '0x02', - decimals: 18, - balanceFiat: '$0', - iconUrl: '', - }, - ], - }, - TokenRatesController: { - marketData: { - '0x1': { - '0x0': { price: 0.005 }, - '0x01': { price: 0.005 }, - '0x02': { price: 0.005 }, - }, - }, - }, - CurrencyRateController: { - currentCurrency: 'USD', - currencyRates: { - ETH: { - conversionRate: 1, - }, - }, - }, - TokenBalancesController: { - contractBalances: { - '0x00': new BN(2).toString(), - '0x01': new BN(2).toString(), - '0x02': new BN(0).toString(), - }, - }, }, }, }; @@ -152,20 +94,6 @@ jest.mock('react-redux', () => ({ .mockImplementation((callback) => callback(mockInitialState)), })); -const mockNavigate = jest.fn(); -const mockPush = jest.fn(); - -jest.mock('@react-navigation/native', () => { - const actualReactNavigation = jest.requireActual('@react-navigation/native'); - return { - ...actualReactNavigation, - useNavigation: () => ({ - navigate: mockNavigate, - push: mockPush, - }), - }; -}); - jest.mock('react-native-scrollable-tab-view', () => { const ScrollableTabViewMock = jest .fn() @@ -176,7 +104,6 @@ jest.mock('react-native-scrollable-tab-view', () => { ScrollableTabViewMock.defaultProps = { onChangeTab: jest.fn(), renderTabBar: jest.fn(), - tabs: [], }; return ScrollableTabViewMock; }); diff --git a/app/components/Views/Wallet/index.tsx b/app/components/Views/Wallet/index.tsx index 9553fccfcfc..a5ccb6e25ea 100644 --- a/app/components/Views/Wallet/index.tsx +++ b/app/components/Views/Wallet/index.tsx @@ -594,7 +594,7 @@ const Wallet = ({ ) : null} <> - + {accountBalanceByChainId && }