Skip to content

Commit

Permalink
Merge commit 'efa3faa351380ebb08ecd5f7199af4df9a67941d' into chore/78…
Browse files Browse the repository at this point in the history
…6-trigger-signing-modals-with-approval-requests
  • Loading branch information
matthewwalsh0 committed May 12, 2023
2 parents 6c6b5d1 + efa3faa commit bfc0a91
Show file tree
Hide file tree
Showing 213 changed files with 5,209 additions and 2,978 deletions.
78 changes: 78 additions & 0 deletions .detoxrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/** @type {Detox.DetoxConfig} */
module.exports = {
testRunner: {
args: {
$0: 'jest',
config: 'e2e/jest.e2e.config.js',
},
jest: {
setupTimeout: 120000,
},
},

configurations: {
'ios.sim.debug': {
device: 'ios.simulator',
app: 'ios.debug',
},
'ios.sim.release': {
device: 'ios.simulator',
app: 'ios.release',
},
'android.emu.debug': {
device: 'android.emulator',
app: 'android.debug',
},
'android.emu.release': {
device: 'android.emulator',
app: 'android.release',
},
'android.emu.release.qa': {
device: 'android.emulator',
app: 'android.qa',
},
},
devices: {
'ios.simulator': {
type: 'ios.simulator',
device: {
type: 'iPhone 12 Pro',
},
},
'android.emulator': {
type: 'android.emulator',
device: {
avdName: 'Pixel_3_API_29',
},
},
},
apps: {
'ios.debug': {
type: 'ios.app',
binaryPath: 'ios/build/Build/Products/Debug-iphonesimulator/MetaMask.app',
build: 'yarn start:ios:e2e',
},
'ios.release': {
type: 'ios.app',
binaryPath:
'ios/build/Build/Products/Release-iphonesimulator/MetaMask.app',
build: "METAMASK_ENVIRONMENT='production' yarn build:ios:release:e2e",
},
'android.debug': {
type: 'android.apk',
binaryPath: 'android/app/build/outputs/apk/prod/debug/app-prod-debug.apk',
build: 'yarn start:android:e2e',
},
'android.release': {
type: 'android.apk',
binaryPath:
'android/app/build/outputs/apk/prod/release/app-prod-release.apk',
build: "METAMASK_ENVIRONMENT='production' yarn build:android:release:e2e",
},
'android.qa': {
type: 'android.apk',
binaryPath: 'android/app/build/outputs/apk/qa/release/app-qa-release.apk',
build: "METAMASK_ENVIRONMENT='qa' yarn build:android:qa:e2e",
},
},
};
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ CHANGELOG.md
# Ignore auto generated file used for react-native-storybook-loader
/storybook/storyLoader.js
wdio
/app/util/test/testSetup.js
1 change: 1 addition & 0 deletions app/__mocks__/pngMock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default { uri: 'MockImage' };
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
/* eslint-disable import/no-commonjs */
/* eslint-disable @typescript-eslint/no-var-requires */
/* eslint-disable import/prefer-default-export */
// Third party dependencies.
import { ImageSourcePropType } from 'react-native';

// External dependencies.
import { BannerVariant } from '../../Banner.types';

Expand All @@ -23,8 +20,8 @@ export const DEFAULT_BANNERTIP_LOGOTYPE = BannerTipLogoType.Greeting;
export const BANNERTIP_TEST_ID = 'bannertip';

// Mappings
const logoFoxChat: ImageSourcePropType = require('./assets/fox-chat.png');
const logoFoxGreeting: ImageSourcePropType = require('./assets/fox-greeting.png');
import logoFoxChat from './assets/fox-chat.png';
import logoFoxGreeting from './assets/fox-greeting.png';
export const IMAGESOURCE_BY_BANNERTIPLOGOTYPE: ImageSourceByBannerTipLogoType =
{
[BannerTipLogoType.Chat]: logoFoxChat,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ exports[`BannerTip should render default settings correctly 1`] = `
resizeMode="contain"
source={
Object {
"testUri": "../../../app/component-library/components/Banners/Banner/variants/BannerTip/assets/fox-greeting.png",
"uri": "MockImage",
}
}
style={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ describe('Mandatory Modal', () => {
/>
</SafeAreaView>,
);
expect(wrapper.dive()).toMatchSnapshot();
expect(wrapper).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ describe('TabBar', () => {
descriptors={descriptors as any}
navigation={navigation as any}
/>,
{ state: initialState },
);
expect(toJSON()).toMatchSnapshot();
});
Expand All @@ -91,6 +92,7 @@ describe('TabBar', () => {
descriptors={descriptors as any}
navigation={navigation as any}
/>,
{ state: initialState },
);

fireEvent.press(getByTestId(`tab-bar-item-${TabBarIconKey.Wallet}`));
Expand Down
27 changes: 20 additions & 7 deletions app/components/Base/RemoteImage/__snapshots__/index.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ exports[`RemoteImage should render ipfs sources 1`] = `
onError={[Function]}
source={
Object {
"uri": "https://cloudflare-ipfs.com/ipfs/QmeE94srcYV9WwJb1p42eM4zncdLUai2N9zmMxxukoEQ23",
"uri": "ipfs://QmeE94srcYV9WwJb1p42eM4zncdLUai2N9zmMxxukoEQ23",
}
}
/>
Expand All @@ -23,13 +23,26 @@ exports[`RemoteImage should render static sources 1`] = `
`;

exports[`RemoteImage should render svg correctly 1`] = `
<View>
<RemoteImage
source={
<ComponentErrorBoundary
componentLabel="RemoteImage-SVG"
>
<View
style={
Object {
"uri": "https://raw.githubusercontent.com/MetaMask/contract-metadata/master/images/dai.svg",
"overflow": "hidden",
}
}
/>
</View>
>
<SvgUri
height="100%"
source={
Object {
"uri": "https://raw.githubusercontent.com/MetaMask/contract-metadata/master/images/dai.svg",
}
}
uri="https://raw.githubusercontent.com/MetaMask/contract-metadata/master/images/dai.svg"
width="100%"
/>
</View>
</ComponentErrorBoundary>
`;
2 changes: 1 addition & 1 deletion app/components/Base/RemoteImage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const RemoteImage = (props) => {
onError={props.onError}
componentLabel="RemoteImage-SVG"
>
<View style={[...style, styles.svgContainer]}>
<View style={{ ...style, ...styles.svgContainer }}>
<SvgUri {...props} uri={uri} width={'100%'} height={'100%'} />
</View>
</ComponentErrorBoundary>
Expand Down
15 changes: 7 additions & 8 deletions app/components/Base/RemoteImage/index.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import { View } from 'react-native';
import { shallow } from 'enzyme';
import RemoteImage from './';

Expand All @@ -10,16 +9,16 @@ jest.mock('react-redux', () => ({
.mockImplementation(() => 'https://cloudflare-ipfs.com/ipfs/'),
}));

jest.mock('../../../components/hooks/useIpfsGateway', () => jest.fn());

describe('RemoteImage', () => {
it('should render svg correctly', () => {
const wrapper = shallow(
<View>
<RemoteImage
source={{
uri: 'https://raw.githubusercontent.com/MetaMask/contract-metadata/master/images/dai.svg',
}}
/>
</View>,
<RemoteImage
source={{
uri: 'https://raw.githubusercontent.com/MetaMask/contract-metadata/master/images/dai.svg',
}}
/>,
);
expect(wrapper).toMatchSnapshot();
});
Expand Down
42 changes: 33 additions & 9 deletions app/components/Nav/App/__snapshots__/index.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -1,13 +1,37 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`App should render correctly when logged in 1`] = `
<App
dispatch={[Function]}
/>
`;

exports[`App should render correctly when logged in 2`] = `
<App
dispatch={[Function]}
/>
<ContextProvider
value={
Object {
"store": Object {
"clearActions": [Function],
"dispatch": [Function],
"getActions": [Function],
"getState": [Function],
"replaceReducer": [Function],
"subscribe": [Function],
},
"subscription": Subscription {
"handleChangeWrapper": [Function],
"listeners": Object {
"notify": [Function],
},
"onStateChange": [Function],
"parentSub": undefined,
"store": Object {
"clearActions": [Function],
"dispatch": [Function],
"getActions": [Function],
"getState": [Function],
"replaceReducer": [Function],
"subscribe": [Function],
},
"unsubscribe": null,
},
}
}
>
<Component />
</ContextProvider>
`;
22 changes: 12 additions & 10 deletions app/components/Nav/App/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,23 @@ import React from 'react';
import { shallow } from 'enzyme';
import App from './';
import configureMockStore from 'redux-mock-store';
import { Provider } from 'react-redux';

const initialState = {
user: {
loggedIn: true,
},
};
const mockStore = configureMockStore();
const store = mockStore(initialState);

describe('App', () => {
it('should render correctly when logged in', () => {
const initialState = {
user: {
loggedIn: true,
},
};

const wrapper = shallow(<App />, {
context: { store: mockStore(initialState) },
});
expect(wrapper).toMatchSnapshot();
const wrapper = shallow(
<Provider store={store}>
<App />
</Provider>,
);
expect(wrapper).toMatchSnapshot();
});
});
49 changes: 38 additions & 11 deletions app/components/UI/AccountApproval/__snapshots__/index.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -1,18 +1,45 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`AccountApproval should render correctly 1`] = `
<AccountApproval
accountsLength={1}
currentPageInformation={
<ContextProvider
value={
Object {
"icon": "",
"title": "",
"url": "",
"store": Object {
"clearActions": [Function],
"dispatch": [Function],
"getActions": [Function],
"getState": [Function],
"replaceReducer": [Function],
"subscribe": [Function],
},
"subscription": Subscription {
"handleChangeWrapper": [Function],
"listeners": Object {
"notify": [Function],
},
"onStateChange": [Function],
"parentSub": undefined,
"store": Object {
"clearActions": [Function],
"dispatch": [Function],
"getActions": [Function],
"getState": [Function],
"replaceReducer": [Function],
"subscribe": [Function],
},
"unsubscribe": null,
},
}
}
dispatch={[Function]}
networkType="sepolia"
selectedAddress="0xe7E125654064EEa56229f273dA586F10DF96B0a1"
tokensLength={0}
/>
>
<Component
currentPageInformation={
Object {
"icon": "",
"title": "",
"url": "",
}
}
/>
</ContextProvider>
`;
2 changes: 1 addition & 1 deletion app/components/UI/AccountApproval/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ describe('AccountApproval', () => {
/>
</Provider>,
);
expect(wrapper.dive()).toMatchSnapshot();
expect(wrapper).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ import AccountFromToInfoCard from '.';
import renderWithProvider from '../../../util/test/renderWithProvider';
import { Transaction } from './AccountFromToInfoCard.types';

jest.mock('../../../util/address', () => ({
...jest.requireActual('../../../util/address'),
isQRHardwareAccount: jest.fn(),
}));

const mockStore = configureMockStore();
const initialState = {
settings: {},
Expand Down Expand Up @@ -79,7 +84,7 @@ describe('AccountFromToInfoCard', () => {
<AccountFromToInfoCard transactionState={transactionState} />
</Provider>,
);
expect(wrapper.dive()).toMatchSnapshot();
expect(wrapper).toMatchSnapshot();
});

it('should match snapshot', async () => {
Expand Down
Loading

0 comments on commit bfc0a91

Please sign in to comment.