Skip to content

Commit 6a6edf9

Browse files
authored
Merge branch 'main' into fix/backup-vault-try-catch
2 parents 43ff1dd + dedb5dd commit 6a6edf9

105 files changed

Lines changed: 8379 additions & 3170 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintrc.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,33 @@ module.exports = {
385385
],
386386
},
387387
},
388+
{
389+
files: ['**/*.test.{js,ts,tsx,jsx}', '**/*.spec.{js,ts,tsx,jsx}'],
390+
plugins: ['jest'],
391+
rules: {
392+
// Prevent new file-based snapshots. Inline snapshots (toMatchInlineSnapshot)
393+
// are still allowed as they keep assertions co-located with the test.
394+
'jest/no-restricted-matchers': [
395+
'error',
396+
{
397+
toMatchSnapshot:
398+
'Use toMatchInlineSnapshot() or an explicit assertion instead. File-based snapshots are being phased out.',
399+
},
400+
],
401+
},
402+
},
403+
{
404+
// Matches CODEOWNERS `**/snaps/**` and `**/Snaps/**` (@MetaMask/core-platform).
405+
// ESLint cannot read CODEOWNERS.
406+
files: [
407+
'**/snaps/**/*.{test,spec}.{js,ts,tsx,jsx}',
408+
'**/Snaps/**/*.{test,spec}.{js,ts,tsx,jsx}',
409+
],
410+
plugins: ['jest'],
411+
rules: {
412+
'jest/no-restricted-matchers': 'off',
413+
},
414+
},
388415
// ── Perps controller Core-alignment override ──
389416
// Enforces the same ESLint rules that Core's @metamask/eslint-config
390417
// applies to packages/perps-controller so that code written in mobile

app/component-library/components/Badges/BadgeWrapper/BadgeWrapper.test.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,20 @@ import React from 'react';
33
import { render, screen } from '@testing-library/react-native';
44

55
// Internal dependencies.
6+
import { BADGENETWORK_TEST_ID } from '../Badge/variants/BadgeNetwork/BadgeNetwork.constants';
67
import BadgeWrapper from './BadgeWrapper';
78
import {
89
SAMPLE_BADGEWRAPPER_PROPS,
910
BADGE_WRAPPER_BADGE_TEST_ID,
1011
} from './BadgeWrapper.constants';
1112

1213
describe('BadgeWrapper', () => {
13-
it('should render BadgeWrapper correctly', () => {
14-
const { toJSON } = render(<BadgeWrapper {...SAMPLE_BADGEWRAPPER_PROPS} />);
15-
expect(toJSON()).toMatchSnapshot();
16-
expect(screen.getByTestId(BADGE_WRAPPER_BADGE_TEST_ID)).toBeDefined();
14+
it('renders anchor content, network badge, and wrapper test id', () => {
15+
render(<BadgeWrapper {...SAMPLE_BADGEWRAPPER_PROPS} />);
16+
17+
expect(screen.getByTestId(BADGE_WRAPPER_BADGE_TEST_ID)).toBeOnTheScreen();
18+
expect(screen.getByText('C')).toBeOnTheScreen();
19+
expect(screen.getByTestId(BADGENETWORK_TEST_ID)).toBeOnTheScreen();
20+
expect(screen.getByTestId('network-avatar-image')).toBeOnTheScreen();
1721
});
1822
});

app/component-library/components/Badges/BadgeWrapper/__snapshots__/BadgeWrapper.test.tsx.snap

Lines changed: 0 additions & 122 deletions
This file was deleted.

app/component-library/components/Toast/Toast.styles.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,15 @@ const styleSheet = (params: { theme: Theme }) => {
2626
borderRadius: 12,
2727
padding,
2828
flexDirection: 'row',
29-
alignItems: 'center',
29+
alignItems: 'flex-start',
3030
},
3131
avatar: {
32+
marginTop: -4,
3233
marginRight: 16,
3334
},
3435
labelsContainer: {
3536
flex: 1,
36-
justifyContent: 'center',
37+
justifyContent: 'flex-start',
3738
},
3839
label: {
3940
color: colors.text.default,

app/component-library/components/Toast/Toast.test.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
// Third party dependencies.
22
import React, { createRef } from 'react';
3+
import { StyleSheet } from 'react-native';
34
import { render, screen, act } from '@testing-library/react-native';
45

56
// Internal dependencies.
67
import Toast from './Toast';
78
import { ToastRef, ToastVariants, ToastOptions } from './Toast.types';
9+
import { ToastSelectorsIDs } from './ToastModal.testIds';
810

911
// react-native-reanimated is already mocked globally via setUpTests() in testSetup.js
1012

@@ -163,4 +165,24 @@ describe('Toast', () => {
163165
expect(screen.queryByText('In Progress')).toBeNull();
164166
expect(screen.getByText('Success')).toBeOnTheScreen();
165167
});
168+
169+
it('uses flex-start justifyContent on labels container by default', async () => {
170+
const toastOptions: ToastOptions = {
171+
variant: ToastVariants.Plain,
172+
labelOptions: [{ label: 'Aligned label' }],
173+
hasNoTimeout: true,
174+
};
175+
176+
render(<Toast ref={toastRef} />);
177+
178+
await act(async () => {
179+
toastRef.current?.showToast(toastOptions);
180+
jest.runAllTimers();
181+
});
182+
183+
const labelsContainer = screen.getByTestId(ToastSelectorsIDs.CONTAINER);
184+
const flat = StyleSheet.flatten(labelsContainer.props.style);
185+
186+
expect(flat.justifyContent).toBe('flex-start');
187+
});
166188
});

app/components/Nav/Main/MainNavigator.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ import ContactForm from '../../Views/Settings/Contacts/ContactForm';
5151
import ActivityView from '../../Views/ActivityView';
5252
import RewardsNavigator from '../../UI/Rewards/RewardsNavigator';
5353
import { ExploreFeed } from '../../Views/TrendingView/TrendingView';
54+
import WhatsHappeningDetailView from '../../Views/WhatsHappeningDetailView';
5455
import ExploreSearchScreen from '../../Views/TrendingView/Views/ExploreSearchScreen/ExploreSearchScreen';
5556
import ExploreSectionResultsFullView from '../../Views/TrendingView/Views/ExploreSectionResultsFullView/ExploreSectionResultsFullView';
5657
import TrendingFeedSessionManager from '../../UI/Trending/services/TrendingFeedSessionManager';
@@ -1368,6 +1369,11 @@ const MainNavigator = () => {
13681369
component={SitesFullView}
13691370
options={{ headerShown: false, ...slideFromRightAnimation }}
13701371
/>
1372+
<Stack.Screen
1373+
name={Routes.WHATS_HAPPENING_DETAIL}
1374+
component={WhatsHappeningDetailView}
1375+
options={{ headerShown: false, ...slideFromRightAnimation }}
1376+
/>
13711377
<Stack.Screen
13721378
name={Routes.EXPLORE_SECTION_RESULTS_FULL_VIEW}
13731379
component={ExploreSectionResultsFullView}

app/components/Nav/Main/MainNavigator.test.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,6 +1045,19 @@ describe('MainNavigator', () => {
10451045
expect(screen).toBeDefined();
10461046
});
10471047

1048+
it('includes WhatsHappeningDetailView screen', () => {
1049+
const container = renderWithProvider(<MainNavigator />, {
1050+
state: initialRootState,
1051+
});
1052+
1053+
const screenProps = getScreenProps(container);
1054+
const screen = screenProps?.find(
1055+
(s) => s?.name === Routes.WHATS_HAPPENING_DETAIL,
1056+
);
1057+
1058+
expect(screen).toBeDefined();
1059+
});
1060+
10481061
it('includes Browser home screen in main navigator', () => {
10491062
const container = renderWithProvider(<MainNavigator />, {
10501063
state: initialRootState,

0 commit comments

Comments
 (0)