Skip to content

Commit

Permalink
Merge branch 'main' into fix/notifications-first-round-of-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathansoufer authored Aug 15, 2024
2 parents 1a5499f + de3ab1a commit 59f2c59
Show file tree
Hide file tree
Showing 20 changed files with 94 additions and 89 deletions.
74 changes: 26 additions & 48 deletions app/components/Views/confirmations/Send/index.test.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import { renderScreen } from '../../../../util/test/renderWithProvider';
import {
DeepPartial,
renderScreen,
} from '../../../../util/test/renderWithProvider';
import Send from '.';
import {
MOCK_ACCOUNTS_CONTROLLER_STATE,
MOCK_ADDRESS_1,
} from '../../../../util/test/accountsControllerTestUtils';
import { MOCK_KEYRING_CONTROLLER } from '../../../../selectors/keyringController/testUtils';
import { RootState } from '../../../../reducers';

const initialState = {
const initialState: DeepPartial<RootState> = {
transaction: {
transaction: {
value: '',
Expand Down Expand Up @@ -40,9 +44,6 @@ const initialState = {
},
},
},
_U: 0,
_V: 1,
_X: null,
},
AddressBookController: {
addressBook: {},
Expand All @@ -51,7 +52,7 @@ const initialState = {
contractBalances: {},
},
TokenListController: {
tokenList: [],
tokenList: { '0x1': {} },
},
PreferencesController: {
featureFlags: {},
Expand All @@ -67,51 +68,30 @@ const initialState = {
eth_sign: false,
},
showTestNetworks: true,
_U: 0,
_V: 1,
_W: {
featureFlags: {},
frequentRpcList: [],
ipfsGateway: 'https://cloudflare-ipfs.com/ipfs/',
lostIdentities: {},
selectedAddress: MOCK_ADDRESS_1,
useTokenDetection: true,
useNftDetection: false,
displayNftMedia: true,
useSafeChainsListValidation: false,
isMultiAccountBalancesEnabled: true,
disabledRpcMethodPreferences: {
eth_sign: false,
},
showTestNetworks: true,
showIncomingTransactions: {
'0x1': true,
'0x5': true,
'0x38': true,
'0x61': true,
'0xa': true,
'0xa869': true,
'0x1a4': true,
'0x89': true,
'0x13881': true,
'0xa86a': true,
'0xfa': true,
'0xfa2': true,
'0xaa36a7': true,
'0xe704': true,
'0xe708': true,
'0x504': true,
'0x507': true,
'0x505': true,
'0x64': true,
},
showIncomingTransactions: {
'0x1': true,
'0x5': true,
'0x38': true,
'0x61': true,
'0xa': true,
'0xa869': true,
'0x89': true,
'0x13881': true,
'0xa86a': true,
'0xfa': true,
'0xfa2': true,
'0xaa36a7': true,
'0xe704': true,
'0xe708': true,
'0x504': true,
'0x507': true,
'0x505': true,
'0x64': true,
},
_X: null,
},
AccountsController: MOCK_ACCOUNTS_CONTROLLER_STATE,
KeyringController: MOCK_KEYRING_CONTROLLER,
NetworkController: {
network: '1',
providerConfig: {
ticker: 'ETH',
type: 'mainnet',
Expand All @@ -127,8 +107,6 @@ const initialState = {
TransactionController: {
methodData: {},
transactions: [],
internalTransactions: [],
swapsTransactions: {},
},
SmartTransactionsController: {
smartTransactionsState: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const renderComponent = (state: any) =>
address={'0xd018538C87232FF95acbCe4870629b75640a78E7'}
onAccountPress={() => null}
onAccountLongPress={() => null}
onIconPress={() => null}
testID="address-element"
/>,
{ state },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-nocheck - Confirmations team or Transactions team
/* eslint-disable react/prop-types */

// Third-Party dependencies
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-nocheck - Confirmations team or Transactions team
import React, { useCallback, useEffect, useMemo, useState } from 'react';
import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view';
import Modal from 'react-native-modal';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,28 @@ import React from 'react';
import { ConnectedComponent } from 'react-redux';
import { waitFor } from '@testing-library/react-native';
import Confirm from '.';
import { renderScreen } from '../../../../../util/test/renderWithProvider';
import {
DeepPartial,
renderScreen,
} from '../../../../../util/test/renderWithProvider';
import Routes from '../../../../../constants/navigation/Routes';
import { backgroundState } from '../../../../../util/test/initial-root-state';
import { TESTID_ACCORDION_CONTENT } from '../../../../../component-library/components/Accordions/Accordion/Accordion.constants';
import { FALSE_POSITIVE_REPOST_LINE_TEST_ID } from '../../components/BlockaidBanner/BlockaidBanner.constants';
import { createMockAccountsControllerState } from '../../../../../util/test/accountsControllerTestUtils';
import { RootState } from '../../../../../reducers';

const MOCK_ADDRESS = '0x15249D1a506AFC731Ee941d0D40Cf33FacD34E58';

const MOCK_ACCOUNTS_CONTROLLER_STATE = createMockAccountsControllerState([
MOCK_ADDRESS,
]);

const mockInitialState = {
const mockInitialState: DeepPartial<RootState> = {
engine: {
backgroundState: {
...backgroundState,
NetworkController: {
network: '1',
providerConfig: {
ticker: 'ETH',
type: 'mainnet',
Expand Down Expand Up @@ -73,7 +76,7 @@ const mockInitialState = {
networks: [
{
active: true,
chainId: 1,
chainId: '0x1',
chainName: 'Ethereum Mainnet',
nativeTokenSupported: true,
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import React from 'react';

import renderWithProvider from '../../../../../util/test/renderWithProvider';
import renderWithProvider, {
DeepPartial,
} from '../../../../../util/test/renderWithProvider';
import ApproveTransactionHeader from '.';
import { backgroundState } from '../../../../../util/test/initial-root-state';
import { APPROVE_TRANSACTION_ORIGIN_PILL } from './ApproveTransactionHeader.constants';
import { createMockAccountsControllerState } from '../../../../../util/test/accountsControllerTestUtils';
import { RootState } from '../../../../../reducers';

const MOCK_ADDRESS_1 = '0xC4955C0d639D99699Bfd7Ec54d9FaFEe40e4D272';
const MOCK_ADDRESS_2 = '0xd018538C87232FF95acbCe4870629b75640a78E7';
Expand All @@ -27,7 +30,7 @@ jest.mock('../../../../../core/Engine', () => ({
},
}));

const mockInitialState = {
const mockInitialState: DeepPartial<RootState> = {
settings: {},
engine: {
backgroundState: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-nocheck - Confirmations team or Transactions team
import { toChecksumAddress } from 'ethereumjs-util';
import React, { useEffect, useMemo, useState } from 'react';
import { View } from 'react-native';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-nocheck - Confirmations team or Transactions team
import React, { useState, useEffect, useCallback } from 'react';
import { SafeAreaView, View, TextInput, TouchableOpacity } from 'react-native';
import AntDesignIcon from 'react-native-vector-icons/AntDesign';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-nocheck - Confirmations team or Transactions team
import ApproveTransactionModal from '.';
import { backgroundState } from '../../../../../util/test/initial-root-state';
import { renderScreen } from '../../../../../util/test/renderWithProvider';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable no-console */
import React from 'react';

import { select, text } from '@storybook/addon-knobs';
import { text } from '@storybook/addon-knobs';
import { storiesOf } from '@storybook/react-native';

import {
Expand All @@ -10,23 +10,9 @@ import {
} from '../../../../../component-library/components/Banners/Banner/variants/BannerAlert/BannerAlert.constants';
import { storybookPropsGroupID } from '../../../../../component-library/constants/storybook.constants';
import BlockaidBanner from './BlockaidBanner';
import { BlockaidBannerProps, FlagType, Reason } from './BlockaidBanner.types';
import { BlockaidBannerProps } from './BlockaidBanner.types';

export const getBlockaidBannerStoryProps = (): BlockaidBannerProps => {
const flagTypeSelector = select(
'flagType',
FlagType,
FlagType.Warning,
storybookPropsGroupID,
);

const reasonSelector = select(
'reason',
Reason,
Reason.approvalFarming,
storybookPropsGroupID,
);

const title = text('title', SAMPLE_BANNERALERT_TITLE, storybookPropsGroupID);
const description = text(
'description',
Expand All @@ -37,12 +23,6 @@ export const getBlockaidBannerStoryProps = (): BlockaidBannerProps => {
return {
title,
description,
reason: reasonSelector,
flagType: flagTypeSelector,
features: [
'Operator is an EOA',
'Operator is untrusted according to previous activity',
],
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import { BANNERALERT_TEST_ID } from '../../../../../component-library/components
import BlockaidBanner from './BlockaidBanner';
import { FALSE_POSITIVE_REPOST_LINE_TEST_ID } from './BlockaidBanner.constants';
import { ResultType, Reason } from './BlockaidBanner.types';
import renderWithProvider from '../../../../../util/test/renderWithProvider';
import renderWithProvider, {
DeepPartial,
} from '../../../../../util/test/renderWithProvider';
import { RootState } from '../../../../../reducers';

jest.mock('../../../../../util/blockaid', () => ({
isBlockaidFeatureEnabled: jest.fn().mockReturnValue(true),
Expand All @@ -20,7 +23,7 @@ jest.mock('react-native-gzip', () => ({
deflate: (val: any) => val,
}));

const mockState = {
const mockState: DeepPartial<RootState> = {
engine: {
backgroundState: {
NetworkController: { providerConfig: { chainId: '0x1' } },
Expand Down Expand Up @@ -164,7 +167,7 @@ describe('BlockaidBanner', () => {
});

it('should not render if blockaid does not support network', async () => {
const mockStateNetwork = {
const mockStateNetwork: DeepPartial<RootState> = {
engine: {
backgroundState: {
NetworkController: { providerConfig: { chainId: '0xfa' } },
Expand All @@ -183,7 +186,7 @@ describe('BlockaidBanner', () => {
});

it('should not render if user has not enabled blockaid', async () => {
const mockStateNetwork = {
const mockStateNetwork: DeepPartial<RootState> = {
engine: {
backgroundState: {
NetworkController: { providerConfig: { chainId: '0x1' } },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-nocheck - Confirmations team or Transactions team
import React, { useCallback, useState, useMemo } from 'react';
import {
View,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import React from 'react';

import { backgroundState } from '../../../../../util/test/initial-root-state';
import renderWithProvider from '../../../../../util/test/renderWithProvider';
import renderWithProvider, {
DeepPartial,
} from '../../../../../util/test/renderWithProvider';
import EditGasFeeLegacyUpdate from '.';
import { RootState } from '../../../../../reducers';

const mockInitialState = (txnType = 'none') => ({
const mockInitialState: (
txnType?: 'none' | 'eth_gasPrice' | 'fee-market' | 'legacy' | undefined,
) => DeepPartial<RootState> = (txnType = 'none') => ({
engine: {
backgroundState: {
...backgroundState,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-nocheck - Confirmations team or Transactions team
import BigNumber from 'bignumber.js';
/* eslint-disable react/display-name */
import React, { useCallback, useMemo, useState } from 'react';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import React from 'react';

import renderWithProvider from '../../../../../util/test/renderWithProvider';
import renderWithProvider, {
DeepPartial,
} from '../../../../../util/test/renderWithProvider';
import { TESTID_ACCORDION_CONTENT } from '../../../../../component-library/components/Accordions/Accordion/Accordion.constants';
import { TESTID_ACCORDIONHEADER } from '../../../../../component-library/components/Accordions/Accordion/foundation/AccordionHeader/AccordionHeader.constants';

import { ResultType, Reason } from '../BlockaidBanner/BlockaidBanner.types';
import TransactionBlockaidBanner from './TransactionBlockaidBanner';
import { RootState } from '../../../../../reducers';

jest.mock('../../../../../core/Engine', () => ({
context: {
Expand All @@ -23,7 +26,7 @@ jest.mock('react-native-gzip', () => ({
deflate: (val: any) => val,
}));

const mockState = {
const mockState: DeepPartial<RootState> = {
engine: {
backgroundState: {
NetworkController: { providerConfig: { chainId: '0x1' } },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-nocheck - Confirmations team or Transactions team
import React from 'react';

import renderWithProvider, {
DeepPartial,
renderHookWithProvider,
} from '../../../../../../util/test/renderWithProvider';
import TransactionReviewEIP1559 from '.';
import { backgroundState } from '../../../../../../util/test/initial-root-state';
import { RootState } from '../../../../../../reducers';

const initialState = {
const initialState: DeepPartial<RootState> = {
settings: {},
engine: {
backgroundState: {
...backgroundState,
AccountTrackerController: {
accounts: {
'0x0': {
balance: 200,
balance: '200',
},
},
},
Expand All @@ -28,7 +32,7 @@ const initialState = {
},
TokenRatesController: {
marketData: {
0x1: {
'0x1': {
'0x326836cc6cd09B5aa59B81A7F72F25FcC0136b95': 1,
},
},
Expand Down
Loading

0 comments on commit 59f2c59

Please sign in to comment.