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: build test dapp and run tests against localhost #7202

Merged
merged 5 commits into from
Sep 13, 2023
Merged

Conversation

seaona
Copy link
Contributor

@seaona seaona commented Sep 12, 2023

Description

This PR adds logic for running (one/many) dapp server(s) locally whenever we run the e2e tests. This way we can run the tests in a controlled environment (against localhost) instead of on a live site.

Here some highlights on how it is done (based on existing Extension implementation):

  • we leverage test-dapp node module and serve-handler for building a static server
  • we add the corresponding options on the withFixtures method, in order to indicate if we want a dapp server and how many(if more than one)
  • on the test, we just need to pass dapp: true to start the test dapp server locally

Test on ci continue to work:

Screenshot from 2023-09-12 18-59-46

Screenshots/Recordings

Notice how we are now going to localhost in the browser for accessing the test dapp

test-dapp-e2e-.mp4

Issue

Checklist

  • There is a related GitHub issue
  • Tests are included if applicable
  • Any added code is fully documented

@seaona seaona added the team-confirmations-secure-ux-PR PR from the confirmations team label Sep 12, 2023
@github-actions
Copy link
Contributor

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.

@socket-security
Copy link

New dependencies detected. Learn more about Socket for GitHub ↗︎

Packages Version New capabilities Transitives Size Publisher
serve-handler 6.1.5 environment +8 343 kB vercel-release-bot

@socket-security
Copy link

socket-security bot commented Sep 12, 2023

👍 Dependency issues cleared. Learn more about Socket for GitHub ↗︎

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

Ignoring: path-is-inside@1.0.2, fast-url-parser@1.1.3

Next steps

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

@codecov-commenter
Copy link

codecov-commenter commented Sep 12, 2023

Codecov Report

Patch coverage has no change and project coverage change: +0.11% 🎉

Comparison is base (aea80fe) 32.97% compared to head (ca5cf2a) 33.08%.
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7202      +/-   ##
==========================================
+ Coverage   32.97%   33.08%   +0.11%     
==========================================
  Files        1005     1005              
  Lines       32649    32649              
  Branches     8384     8395      +11     
==========================================
+ Hits        10765    10803      +38     
+ Misses      21884    21846      -38     

see 18 files with indirect coverage changes

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

@seaona seaona self-assigned this Sep 12, 2023
@seaona
Copy link
Contributor Author

seaona commented Sep 12, 2023

@SocketSecurity ignore-all . Reasons:

  • serve-handler is a dev dependency for e2e
  • it is also used in Extension e2e

@seaona seaona marked this pull request as ready for review September 12, 2023 19:03
@seaona seaona requested a review from a team as a code owner September 12, 2023 19:03
package.json Show resolved Hide resolved
@sonarqubecloud
Copy link

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 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

Copy link
Contributor

@NicolasMassart NicolasMassart left a comment

Choose a reason for hiding this comment

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

Looks good to me, this is a very nice step in the direction where we have less constraints and dependencies with the "outside" when testing. Well done!

NOTE: Added a comment but it's not a blocker for merge. the code works and is consistent with extension, so maybe it's better to keep it like this. Commenting it perhaps a bit more could help though (the comments you added to this PR could be in the code).

e2e/fixtures/fixture-helper.js Show resolved Hide resolved
Copy link
Contributor

@jpuri jpuri left a comment

Choose a reason for hiding this comment

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

👍 great work

@seaona
Copy link
Contributor Author

seaona commented Sep 13, 2023

thank you v much for your reviews @jpuri @NicolasMassart
About this comment:

the code works and is consistent with extension, so maybe it's better to keep it like this. Commenting it perhaps a bit more could help though (the comments you added to this PR could be in the code).

This makes a lot of sense and I also see the need to keep things documented. I was thinking maybe to write some documentation around e2e in Mobile, on how to use of fixtures, ganache, contract deployments, and mocking (this is coming very soon) and best practices and we could also have a meeting around that, once the mocking is done, so the infra will be ready. Let me know if that sounds good 🙏

Copy link
Member

@cortisiko cortisiko left a comment

Choose a reason for hiding this comment

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

Looks good!

Copy link
Contributor

@NicolasMassart NicolasMassart left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@seaona seaona merged commit 9b4b9aa into main Sep 13, 2023
@seaona seaona deleted the test-local-dapp branch September 13, 2023 16:23
@github-actions github-actions bot locked and limited conversation to collaborators Sep 13, 2023
@metamaskbot metamaskbot added the release-7.8.0 Issue or pull request that will be included in release 7.8.0 label Sep 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-7.8.0 Issue or pull request that will be included in release 7.8.0 team-confirmations-secure-ux-PR PR from the confirmations team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants