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

chore: Migrate a batch of unit tests away from enzyme #8839

Merged
merged 15 commits into from
Mar 7, 2024
Merged

Conversation

kylanhurt
Copy link
Contributor

@kylanhurt kylanhurt commented Mar 4, 2024

Description

Works on #8804

This PR is in line with the mobile platform's team to reduce usage of Enzyme as a testing library. The following tests were modified:

  'app/components/UI/BiometryButton/index.test.tsx',
  'app/components/UI/OnboardingWizard/Coachmark/index.test.tsx',
  'app/component-library/components/Pickers/PickerBase/PickerBase.test.tsx',
  'app/component-library/components/Cards/Card/Card.test.tsx',
  'app/components/Views/TermsAndConditions/index.test.tsx',
  'app/components/Views/Onboarding/index.test.tsx',
  'app/components/Views/GasEducationCarousel/index.test.tsx',
  'app/components/Views/Asset/index.test.js',
  'app/components/UI/UrlAutocomplete/index.test.js',
  'app/components/UI/UpdateNeeded/UpdateNeeded.test.tsx',
  'app/components/UI/SelectComponent/index.test.tsx',
  'app/components/UI/NavbarBrowserTitle/index.test.tsx',
  'app/components/UI/DrawerView/index.test.tsx',
  'app/components/UI/EnableAutomaticSecurityChecksModal/EnableAutomaticSecurityChecksModal.test.tsx',
  'app/components/Views/confirmations/Send/index.test.tsx',
  'app/components/Views/Settings/AppInformation/index.test.tsx',
  'app/components/UI/Tabs/TabThumbnail/index.test.tsx'

Related issues

Fixes: #8804

Manual testing steps

  1. yarn test:unit

Screenshots/Recordings

image

Pre-merge author checklist

  • I’ve followed MetaMask Coding Standards.
  • I've clearly explained what problem this PR is solving and how it is solved.
  • I've linked related issues
  • I've included manual testing steps
  • I've included screenshots/recordings if applicable
  • I’ve included tests if applicable
  • I’ve documented my code using JSDoc format if applicable
  • I’ve applied the right labels on the PR (see labeling guidelines). Not required for external contributors.
  • I’ve properly set the pull request status:
    • In case it's not yet "ready for review", I've set it to "draft".
    • In case it's "ready for review", I've changed it from "draft" to "non-draft".

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.

Copy link
Contributor

github-actions bot commented Mar 4, 2024

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.

@codecov-commenter
Copy link

codecov-commenter commented Mar 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 43.20%. Comparing base (a73e159) to head (b51fd2e).
Report is 7 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8839      +/-   ##
==========================================
+ Coverage   41.61%   43.20%   +1.58%     
==========================================
  Files        1269     1270       +1     
  Lines       30869    30887      +18     
  Branches     3086     3083       -3     
==========================================
+ Hits        12846    13344     +498     
+ Misses      17246    16769     -477     
+ Partials      777      774       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

WIP fixing unit tests

Fixed Send component snapshot'

Provisional completion of first batch migrate from enzyme to testing-library

Revert some this.context conditionals that were breaking unit tests
@kylanhurt kylanhurt changed the title Kylan/unit tests chore: Migrate a batch of unit tests away from enzyme Mar 5, 2024
@kylanhurt kylanhurt added needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) team-mobile-platform labels Mar 5, 2024
@kylanhurt kylanhurt assigned Cal-L and unassigned Cal-L Mar 5, 2024
@kylanhurt kylanhurt added the Spot Check on the Release Build If a ticket doesn't require feature QA, but does require some form of manual spot checking label Mar 5, 2024
@kylanhurt kylanhurt marked this pull request as ready for review March 5, 2024 18:56
@kylanhurt kylanhurt requested review from a team as code owners March 5, 2024 18:56
@github-actions github-actions bot added the Run Smoke E2E Triggers smoke e2e on Bitrise label Mar 5, 2024
Copy link
Contributor

github-actions bot commented Mar 5, 2024

https://bitrise.io/ Bitrise

✅✅✅ pr_smoke_e2e_pipeline passed on Bitrise! ✅✅✅

Commit hash: 5696e43
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/1c0eace3-5138-4296-b215-87ac2ddba234

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

brianacnguyen
brianacnguyen previously approved these changes Mar 5, 2024
@Cal-L Cal-L added Run Smoke E2E Triggers smoke e2e on Bitrise and removed Run Smoke E2E Triggers smoke e2e on Bitrise labels Mar 5, 2024
Cal-L
Cal-L previously approved these changes Mar 5, 2024
@Cal-L Cal-L dismissed their stale review March 5, 2024 20:07

Accidentally approved

Copy link
Contributor

@Cal-L Cal-L left a comment

Choose a reason for hiding this comment

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

Let's address the lint failure in the checks

Copy link
Contributor

@Cal-L Cal-L left a comment

Choose a reason for hiding this comment

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

Left some comments. Looks like a file was missed as well
app/component-library/components/Cards/Card/Card.test.tsx

Copy link
Contributor

@Cal-L Cal-L left a comment

Choose a reason for hiding this comment

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

  • Let's test for toJSON() for tests where it's testing wrapper directly
  • Unit tests are failing

Copy link
Contributor

@Cal-L Cal-L left a comment

Choose a reason for hiding this comment

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

Left some comments

app/components/Views/Onboarding/index.test.tsx Outdated Show resolved Hide resolved
app/components/UI/UpdateNeeded/UpdateNeeded.test.tsx Outdated Show resolved Hide resolved
Copy link
Contributor

@Cal-L Cal-L left a comment

Choose a reason for hiding this comment

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

LGTM, great work!

@Cal-L Cal-L added No QA Needed/E2E Only Apply this label when your PR does not need any QA effort. Spot Check on the Release Build If a ticket doesn't require feature QA, but does require some form of manual spot checking and removed Spot Check on the Release Build If a ticket doesn't require feature QA, but does require some form of manual spot checking No QA Needed/E2E Only Apply this label when your PR does not need any QA effort. labels Mar 6, 2024
Copy link

sonarcloud bot commented Mar 7, 2024

@kylanhurt kylanhurt merged commit f66c08b into main Mar 7, 2024
28 of 29 checks passed
@kylanhurt kylanhurt deleted the kylan/unit-tests branch March 7, 2024 17:43
@github-actions github-actions bot locked and limited conversation to collaborators Mar 7, 2024
@github-actions github-actions bot removed the needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) label Mar 7, 2024
@metamaskbot metamaskbot added the release-7.19.0 Issue or pull request that will be included in release 7.19.0 label Mar 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-7.19.0 Issue or pull request that will be included in release 7.19.0 Run Smoke E2E Triggers smoke e2e on Bitrise Spot Check on the Release Build If a ticket doesn't require feature QA, but does require some form of manual spot checking team-mobile-platform
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Reduce enzyme usage in unit test down to 50% - [1 of 3]
5 participants