Skip to content

Commit ddb3c81

Browse files
authored
test: remove toMatchSnapshot and removed snapshot files in notifications tests (#29329)
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until this PR meets the canonical Definition of Ready For Review in `docs/readme/ready-for-review.md`. In short: the template must be materially complete (not just section titles present), all status checks must be currently passing, and the only expected follow-up commits must be reviewer-driven. --> ## **Description** > Removes Jest snapshot coverage for several notification detail components and deletes the associated `.snap` files. > > Updates `NotificationBadge`, `NetworkFeeField`, and `Header` tests to assert specific rendered output instead of `toMatchSnapshot()` (e.g., presence of key `testID`s and title/description text, and explicitly expecting `null` renders where applicable). ## **Changelog** <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> CHANGELOG entry: ## **Related issues** Fixes: ## **Manual testing steps** ```gherkin Feature: my feature name Scenario: user [verb for user action] Given [describe expected initial app state] When user [verb for user action] Then [describe expected outcome] ``` ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** <!-- Every checklist item must be consciously assessed before marking this PR as "Ready for review". A checked box means you deliberately considered that responsibility, not that you literally performed every action listed. Unchecked boxes are ambiguous: they are not an implicit "N/A" and they are not a silent "skip". See `docs/readme/ready-for-review.md` for the full checklist semantics. --> - [ ] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I've included tests if applicable - [ ] I've documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I've applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. #### Performance checks (if applicable) - [ ] I've tested on Android - Ideally on a mid-range device; emulator is acceptable - [ ] I've tested with a power user scenario - Use these [power-user SRPs](https://consensyssoftware.atlassian.net/wiki/spaces/TL1/pages/edit-v2/401401446401?draftShareId=9d77e1e1-4bdc-4be1-9ebb-ccd916988d93) to import wallets with many accounts and tokens - [ ] I've instrumented key operations with Sentry traces for production performance metrics - See [`trace()`](/app/util/trace.ts) for usage and [`addToken`](/app/components/Views/AddAsset/components/AddCustomToken/AddCustomToken.tsx#L274) for an example For performance guidelines and tooling, see the [Performance Guide](https://consensyssoftware.atlassian.net/wiki/spaces/TL1/pages/400085549067/Performance+Guide+for+Engineers). ## **Pre-merge reviewer checklist** <!-- Reviewer checklist items follow the same semantics as the author checklist: an unchecked box is ambiguous, a checked box means the reviewer consciously assessed that responsibility. See `docs/readme/ready-for-review.md`. --> - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Test-only changes that remove snapshot reliance; low product risk but may reduce coverage of UI regressions previously caught by snapshots. > > **Overview** > Removes Jest snapshot files for several notification components and updates their tests to stop using `toMatchSnapshot()`. > > Tests now assert specific rendered output instead (e.g., presence of key `testID`s/text) and explicitly check `null` rendering for `NetworkFeeField` where applicable. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit dbddff4. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 5e07380 commit ddb3c81

10 files changed

Lines changed: 15 additions & 1839 deletions

File tree

app/components/UI/Notification/BaseNotification/__snapshots__/index.test.jsx.snap

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

app/components/UI/Notification/BaseNotification/index.test.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ const defaultProps = [
4545
describe('BaseNotification', () => {
4646
it('gets icon correctly for each status', () => {
4747
defaultProps.forEach(({ status, data }) => {
48-
const { toJSON } = renderWithProvider(
48+
const { getByTestId } = renderWithProvider(
4949
<BaseNotification status={status} data={data} />,
5050
);
51-
expect(toJSON()).toMatchSnapshot();
51+
expect(getByTestId('notification-title')).toBeOnTheScreen();
5252
});
5353
});
5454

app/components/UI/Notification/Empty/__snapshots__/index.test.tsx.snap

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

app/components/UI/Notification/Empty/index.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import renderWithProvider from '../../../../util/test/renderWithProvider';
44

55
describe('Empty', () => {
66
it('should render correctly', () => {
7-
const { toJSON } = renderWithProvider(<Empty />);
8-
expect(toJSON()).toMatchSnapshot();
7+
const { getByText } = renderWithProvider(<Empty />);
8+
expect(getByText('Nothing to see here')).toBeOnTheScreen();
99
});
1010
});

app/components/Views/Notifications/Details/Badge/__snapshots__/index.test.tsx.snap

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

app/components/Views/Notifications/Details/Badge/index.test.tsx

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,6 @@ describe('NotificationBadge', () => {
3232
'https://token.api.cx.metamask.io/assets/nativeCurrencyLogos/ethereum.svg',
3333
};
3434

35-
it('should renders correctly', () => {
36-
const { toJSON } = render(
37-
<Provider store={store}>
38-
<NotificationBadge
39-
{...commonProps}
40-
notificationType={TRIGGER_TYPES.ETH_RECEIVED}
41-
/>
42-
</Provider>,
43-
);
44-
expect(toJSON()).toMatchSnapshot();
45-
});
46-
4735
it('should renders NetworkMainAssetLogo for ETH notification types', () => {
4836
const { getByTestId } = render(
4937
<Provider store={store}>

app/components/Views/Notifications/Details/Fields/NetworkFeeField.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ describe('NetworkFeeField', () => {
6767
/>,
6868
);
6969

70-
expect(toJSON()).toMatchSnapshot();
70+
expect(toJSON()).toBeNull();
7171
});
7272

7373
it('renders loading state', () => {

app/components/Views/Notifications/Details/Fields/__snapshots__/NetworkFeeField.test.tsx.snap

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

app/components/Views/Notifications/Details/Title/__snapshots__/index.test.tsx.snap

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

app/components/Views/Notifications/Details/Title/index.test.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,14 @@ jest.mock('../../../../../component-library/components/Texts/Text', () => {
99
const originalModule = jest.requireActual(
1010
'../../../../../component-library/components/Texts/Text',
1111
);
12+
// eslint-disable-next-line @typescript-eslint/no-require-imports
13+
const { Text } = require('react-native');
1214
return {
1315
...originalModule,
1416
__esModule: true,
15-
default: jest.fn(({ children }) => children),
17+
default: jest.fn(({ children, testID }) => (
18+
<Text testID={testID}>{children}</Text>
19+
)),
1620
};
1721
});
1822

@@ -21,7 +25,10 @@ describe('Header', () => {
2125
const DESCRIPTION = 'This is a mock of description';
2226

2327
it('should render correctly', () => {
24-
const { toJSON } = render(<Header title={TITLE} subtitle={DESCRIPTION} />);
25-
expect(toJSON()).toMatchSnapshot();
28+
const { getByTestId, getByText } = render(
29+
<Header title={TITLE} subtitle={DESCRIPTION} />,
30+
);
31+
expect(getByTestId('notification-details-header-title')).toBeOnTheScreen();
32+
expect(getByText(DESCRIPTION)).toBeOnTheScreen();
2633
});
2734
});

0 commit comments

Comments
 (0)