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: split the SDKConnect class into smaller chunks and add unit tests #8028

Merged

Conversation

omridan159
Copy link
Contributor

@omridan159 omridan159 commented Dec 7, 2023

Description

Split the SDKConnect class into smaller chunks to make the code more testable and add unit tests.

Related issues

Fixes:

Manual testing steps

  1. Go to this page...

Screenshots/Recordings

Before

After

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.

@omridan159 omridan159 requested a review from a team as a code owner December 7, 2023 07:58
Copy link
Contributor

github-actions bot commented Dec 7, 2023

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 Dec 7, 2023

Codecov Report

Attention: 113 lines in your changes are missing coverage. Please review.

Comparison is base (635daa3) 37.92% compared to head (ef032ae) 38.81%.

Files Patch % Lines
.../core/SDKConnect/ConnectionManagement/reconnect.ts 42.59% 21 Missing and 10 partials ⚠️
.../core/SDKConnect/StateManagement/handleAppState.ts 39.02% 19 Missing and 6 partials ⚠️
...p/core/SDKConnect/InitializationManagement/init.ts 0.00% 12 Missing ⚠️
...e/SDKConnect/InitializationManagement/asyncInit.ts 68.96% 6 Missing and 3 partials ⚠️
app/core/SDKConnect/AndroidSDK/bindAndroidSDK.ts 14.28% 5 Missing and 1 partial ⚠️
...DKConnect/ConnectionManagement/connectToChannel.ts 85.18% 2 Missing and 2 partials ⚠️
...SDKConnect/ConnectionManagement/watchConnection.ts 75.00% 2 Missing and 2 partials ⚠️
app/core/SDKConnect/SDKConnect.ts 87.87% 3 Missing and 1 partial ⚠️
app/core/SDKConnect/SessionManagement/unmount.ts 83.33% 2 Missing and 1 partial ⚠️
...ore/SDKConnect/ConnectionManagement/approveHost.ts 83.33% 1 Missing and 1 partial ⚠️
... and 9 more
Additional details and impacted files
@@                               Coverage Diff                               @@
##           chore_add-unit-tests-to-SDKConnect-handlers    #8028      +/-   ##
===============================================================================
+ Coverage                                        37.92%   38.81%   +0.88%     
===============================================================================
  Files                                             1140     1163      +23     
  Lines                                            29196    29206      +10     
  Branches                                          2746     2747       +1     
===============================================================================
+ Hits                                             11074    11337     +263     
+ Misses                                           17478    17195     -283     
- Partials                                           644      674      +30     

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

andreahaku
andreahaku previously approved these changes Dec 7, 2023
Copy link
Member

@andreahaku andreahaku left a comment

Choose a reason for hiding this comment

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

LGTM

@omridan159 omridan159 added the needs-qa Any New Features that needs a full manual QA prior to being added to a release. label Dec 7, 2023
@omridan159 omridan159 changed the title chore: split the SDKConnect class into smaller chunks chore: split the SDKConnect class into smaller chunks and add unit tests Dec 8, 2023
Copy link

socket-security bot commented Dec 8, 2023

No top level dependency changes detected. Learn more about Socket for GitHub ↗︎

Copy link

socket-security bot commented Dec 8, 2023

🚨 Potential security issues detected. Learn more about Socket for GitHub ↗︎

To accept the risk, merge this PR and you will not be notified again.

Issue Package Version Note Source
New author parse5-htmlparser2-tree-adapter 7.0.0

Next steps

What is new author?

A new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.

Scrutinize new collaborator additions to packages because they now have the ability to publish code into your dependency tree. Packages should avoid frequent or unnecessary additions or changes to publishing rights.

Take a deeper look at the dependency

Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support [AT] socket [DOT] dev.

Remove the package

If you happen to install a dependency that Socket reports as Known Malware you should immediately remove it and select a different dependency. For other alert types, you may may wish to investigate alternative packages or consider if there are other ways to mitigate the specific risk posed by the dependency.

Mark a package as acceptable risk

To ignore an alert, reply with a comment starting with @SocketSecurity ignore followed by a space separated list of package-name@version specifiers. e.g. @SocketSecurity ignore foo@1.0.0 bar@* or ignore all packages with @SocketSecurity ignore-all

  • @SocketSecurity ignore parse5-htmlparser2-tree-adapter@7.0.0

Base automatically changed from chore_add-unit-tests-to-SDKConnect-handlers to main December 12, 2023 09:03
@christopherferreira9 christopherferreira9 dismissed andreahaku’s stale review December 12, 2023 09:03

The base branch was changed.

@christopherferreira9 christopherferreira9 added QA in Progress QA has started on the feature. and removed needs-qa Any New Features that needs a full manual QA prior to being added to a release. labels Dec 12, 2023
Copy link
Member

@andreahaku andreahaku left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

sonarcloud bot commented Dec 12, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 3 Code Smells

73.8% 73.8% Coverage
0.0% 0.0% Duplication

@christopherferreira9
Copy link
Contributor

Tiny tiny detail that may have come from a different branch. The console.warn in the video can be ignored.

Screen.Recording.2023-12-12.at.17.05.04.mov

Steps:

  1. Connect via QR Code and select "Do not remember me"
  2. Refresh dapp
  3. A loader is presented even though it can't resume since it did not save the room.

Expected result:
The loader is not presented

Actual result:
You get a loader

@christopherferreira9
Copy link
Contributor

Since the bug reported doesn't break the overall functionality and is of low severity this is going to merged and #8079 was opened.

@christopherferreira9 christopherferreira9 merged commit c2149bb into main Dec 12, 2023
24 of 26 checks passed
@christopherferreira9 christopherferreira9 deleted the chore_split-the-SDKConnect-class-into-smaller-chunks branch December 12, 2023 17:42
@github-actions github-actions bot locked and limited conversation to collaborators Dec 12, 2023
@metamaskbot metamaskbot added the release-7.15.0 Issue or pull request that will be included in release 7.15.0 label Dec 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
QA in Progress QA has started on the feature. release-7.15.0 Issue or pull request that will be included in release 7.15.0 team-sdk SDK team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants