Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(3664): add unit tests for network permissions components #13401

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

EtherWizard33
Copy link
Contributor

@EtherWizard33 EtherWizard33 commented Feb 7, 2025

Description

This PR adds comprehensive unit tests for components involved in managing network permissions.

Key Changes

  • NetworkSelectorList tests:
    • Snapshot tests for rendering verification.
    • Tests for network selection and right accessory rendering.
  • NetworkConnectMultiSelector tests:
    • Simulate network permission update flows.
    • Validate handling of multi-select behavior and correct chain ID usage.
  • ConnectionDetails tests:
    • Verify proper rendering and date formatting for network permission details.
  • PermittedNetworksInfoSheet tests:
    • Ensure the info sheet renders the correct title, description, and action button.
  • PermissionsManager tests:
    • Check that the component renders the empty state when no network permissions exist.

Related issues

Contributes to: https://github.com/MetaMask/MetaMask-planning/issues/3664

Manual testing steps

  1. run jest for each test file, npx jest , or just yarn test:unit

Screenshots/Recordings

Before

After

Pre-merge author checklist

Pre-merge reviewer checklist

  • 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.

- Added a test case to verify that the PermissionsManager component correctly renders
  the empty state when no permissions exist.
- Validates the presence of the session manager container and the appropriate empty state texts.
…k selection and permission updates

- Ensure proper rendering of the NetworkConnectMultiSelector component.
- Verify initialization with permitted chains from caveat data.
- Test user interactions for network selection and toggling the update button state.
- Confirm proper handling of network disconnects when no networks are selected.
- Validate error handling when retrieving permitted chains.

This commit enhances our test coverage and reinforces the component's robustness.
@EtherWizard33 EtherWizard33 added Run Smoke E2E Triggers smoke e2e on Bitrise team-wallet-ux labels Feb 7, 2025
Copy link
Contributor

github-actions bot commented Feb 7, 2025

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

Copy link
Contributor

github-actions bot commented Feb 7, 2025

https://bitrise.io/ Bitrise

❌❌❌ pr_smoke_e2e_pipeline failed on Bitrise! ❌❌❌

Commit hash: f69a105
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/774d7292-cfd5-446f-85d7-30649cb2375b

Note

  • You can kick off another pr_smoke_e2e_pipeline on Bitrise by removing and re-applying the Run Smoke E2E label on the pull request

Tip

  • Check the documentation if you have any doubts on how to understand the failure on bitrise

@EtherWizard33 EtherWizard33 changed the title test(3664) add unit test coverage to multichain permisisions test(3664) Add Unit Tests for NetworkConnectMultiSelector and PermissionsManager Components Feb 7, 2025
@EtherWizard33 EtherWizard33 changed the title test(3664) Add Unit Tests for NetworkConnectMultiSelector and PermissionsManager Components test(3664): Add Unit Tests for NetworkConnectMultiSelector and PermissionsManager Components Feb 7, 2025
@EtherWizard33 EtherWizard33 changed the title test(3664): Add Unit Tests for NetworkConnectMultiSelector and PermissionsManager Components test(3664): add unit tests for NetworkConnectMultiSelector and PermissionsManager components Feb 7, 2025
Add test coverage for PermittedNetworksInfoSheet component including:
- Create constants file for test IDs
- Add snapshot test
- Test title, description and button rendering
- Test container styles
- Test button interaction
- Add test IDs to component elements
Tests cover rendering, date formatting, default states and user interactions
@EtherWizard33 EtherWizard33 added Run Smoke E2E Triggers smoke e2e on Bitrise and removed Run Smoke E2E Triggers smoke e2e on Bitrise labels Feb 7, 2025
Copy link
Contributor

github-actions bot commented Feb 7, 2025

https://bitrise.io/ Bitrise

❌❌❌ pr_smoke_e2e_pipeline failed on Bitrise! ❌❌❌

Commit hash: 2c333a7
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/b97842d6-2312-401d-ba62-425dda9b9701

Note

  • You can kick off another pr_smoke_e2e_pipeline on Bitrise by removing and re-applying the Run Smoke E2E label on the pull request

Tip

  • Check the documentation if you have any doubts on how to understand the failure on bitrise

- Add explicit types for mock functions and navigation props
- Remove unused imports across test files
- Improve mock component type definitions
@EtherWizard33 EtherWizard33 marked this pull request as ready for review February 7, 2025 11:53
@EtherWizard33 EtherWizard33 requested review from a team as code owners February 7, 2025 11:53
tommasini
tommasini previously approved these changes Feb 7, 2025
@EtherWizard33 EtherWizard33 changed the title test(3664): add unit tests for NetworkConnectMultiSelector and PermissionsManager components test(3664): add unit tests for NetworkConnectMultiSelector, PermissionsManager and other chain permissions components Feb 7, 2025
- Move forwardRef and useImperativeHandle inside mock factory
- Add proper TypeScript types for BottomSheet ref
- Follow Jest naming conventions for mock variables
- Add test suite for NetworkSelectorList component
- Mock react-native Linking API
- Test rendering, network selection, and right accessory functionality
- Add snapshot test
@EtherWizard33 EtherWizard33 added Run Smoke E2E Triggers smoke e2e on Bitrise and removed Run Smoke E2E Triggers smoke e2e on Bitrise labels Feb 10, 2025
Copy link
Contributor

github-actions bot commented Feb 10, 2025

https://bitrise.io/ Bitrise

❌❌❌ pr_smoke_e2e_pipeline failed on Bitrise! ❌❌❌

Commit hash: 90bd0f4
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/6209a5fd-c118-44bd-8f6e-e5dc7322a01b

Note

  • You can kick off another pr_smoke_e2e_pipeline on Bitrise by removing and re-applying the Run Smoke E2E label on the pull request

Tip

  • Check the documentation if you have any doubts on how to understand the failure on bitrise

@EtherWizard33 EtherWizard33 changed the title test(3664): add unit tests for NetworkConnectMultiSelector, PermissionsManager and other chain permissions components test(3664): add unit tests for network permissions components Feb 10, 2025
@metamaskbot metamaskbot added the INVALID-PR-TEMPLATE PR's body doesn't match template label Feb 10, 2025
@metamaskbot metamaskbot removed the INVALID-PR-TEMPLATE PR's body doesn't match template label Feb 11, 2025
@EtherWizard33 EtherWizard33 added Run Smoke E2E Triggers smoke e2e on Bitrise and removed Run Smoke E2E Triggers smoke e2e on Bitrise labels Feb 11, 2025
Copy link
Contributor

github-actions bot commented Feb 11, 2025

https://bitrise.io/ Bitrise

❌❌❌ pr_smoke_e2e_pipeline failed on Bitrise! ❌❌❌

Commit hash: 5f80086
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/e2717d9f-87c5-4137-9bd0-73ab3b488a31

Note

  • You can kick off another pr_smoke_e2e_pipeline on Bitrise by removing and re-applying the Run Smoke E2E label on the pull request

Tip

  • Check the documentation if you have any doubts on how to understand the failure on bitrise

…tID for account list

- Introduce a new test file for AccountConnectMultiSelector with snapshot tests,
  accounts list display, add account button press, and primary action button press.
- Update AccountConnectMultiSelector.tsx to add a testID prop to the AccountSelectorList,
  so it can be properly targeted by tests.
- Skip tests for select/unselect checkbox, disconnect action, and back button press for now.
vinnyhoward
vinnyhoward previously approved these changes Feb 12, 2025
Copy link
Contributor

@vinnyhoward vinnyhoward left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@EtherWizard33 EtherWizard33 added Run Smoke E2E Triggers smoke e2e on Bitrise and removed Run Smoke E2E Triggers smoke e2e on Bitrise labels Feb 13, 2025
Copy link
Contributor

github-actions bot commented Feb 13, 2025

https://bitrise.io/ Bitrise

❌❌❌ pr_smoke_e2e_pipeline failed on Bitrise! ❌❌❌

Commit hash: c049281
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/42bc993e-61b5-4a2e-adb5-7879841d3905

Note

  • You can kick off another pr_smoke_e2e_pipeline on Bitrise by removing and re-applying the Run Smoke E2E label on the pull request

Tip

  • Check the documentation if you have any doubts on how to understand the failure on bitrise

@EtherWizard33 EtherWizard33 added Run Smoke E2E Triggers smoke e2e on Bitrise and removed Run Smoke E2E Triggers smoke e2e on Bitrise labels Feb 13, 2025
Copy link
Contributor

github-actions bot commented Feb 13, 2025

https://bitrise.io/ Bitrise

❌❌❌ pr_smoke_e2e_pipeline failed on Bitrise! ❌❌❌

Commit hash: 8c2dbc8
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/638cafe6-436c-46bb-9450-8767cb441f3f

Note

  • You can kick off another pr_smoke_e2e_pipeline on Bitrise by removing and re-applying the Run Smoke E2E label on the pull request

Tip

  • Check the documentation if you have any doubts on how to understand the failure on bitrise

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Run Smoke E2E Triggers smoke e2e on Bitrise team-wallet-ux
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants