metamask-extension icon indicating copy to clipboard operation
metamask-extension copied to clipboard

fix: switch e2e test to mainnet instead of ganache

Open sahar-fehri opened this issue 1 year ago • 6 comments

Description

Switches e2e test to connect to BSC instead of ganache. This is related to an incoming change on core to remove ganache ID from isTokenListSupportedForNetwork since accountApi does not support ganache and the fetchTokenMetadata would fail not allowing users who are using ganache to see the imported ERC20 tokens.

This e2e test using ganache was passing initially because we mock the following call https://github.com/MetaMask/metamask-extension/blob/5a968da2eeb6818247af982d58e00b14dc7fb72a/test/e2e/mock-e2e.js#L268.

Related issues

Fixes: https://github.com/MetaMask/metamask-mobile/issues/6410 Related to :(https://github.com/MetaMask/core/pull/3777)

Manual testing steps

  1. Run ganache locally
  2. Use test dapp to deploy ERC20
  3. Use test dapp to add the token to wallet (triggering watchAsset)
  4. You should be able to see the new token in tokens tab

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.

sahar-fehri avatar Feb 08 '24 17:02 sahar-fehri

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.

github-actions[bot] avatar Feb 08 '24 17:02 github-actions[bot]

Builds ready [1cce780]
Page Load Metrics (832 ± 23 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint97133113115
domContentLoaded105326126
load7519308324823
domInteractive105326126
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

metamaskbot avatar Feb 08 '24 17:02 metamaskbot

Generally we don't want E2E tests making external network requests (see these guidelines: https://docs.google.com/document/d/1eQyeScSZQlzGLapef_8PANkU_ObNPJcuMCP040T2gfM/edit). That would include request to Infura, which this would introduce by switching to Mainnet.

Perhaps you could edit the Ganache config to use the chain ID of a supported network instead?

Gudahtt avatar Feb 08 '24 17:02 Gudahtt

d edit the Ganache config to use the chain ID of a supported network instead?

Hey @Gudahtt , thnx for checking this 🙏 If im not mistaking there is already another e2e test test/e2e/tests/import-tokens.spec.js that is switching to mainnet? Should that also be updated to interact with a supported chainId + mocking the calls to tokenApi ?

sahar-fehri avatar Feb 08 '24 18:02 sahar-fehri

Builds ready [e982ada]
Page Load Metrics (941 ± 25 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint1092181742713
domContentLoaded974282512
load84910129415225
domInteractive974282512
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

metamaskbot avatar Feb 14 '24 09:02 metamaskbot

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (391e9e7) 68.55% compared to head (e982ada) 68.55%. Report is 5 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop   #22880   +/-   ##
========================================
  Coverage    68.55%   68.55%           
========================================
  Files         1088     1088           
  Lines        42907    42907           
  Branches     11415    11415           
========================================
  Hits         29411    29411           
  Misses       13496    13496           

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Feb 14 '24 10:02 codecov[bot]