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: E2E Mocking Setup For Detox Tests #11144

Merged
merged 32 commits into from
Sep 18, 2024
Merged

Conversation

Andepande
Copy link
Member

@Andepande Andepande commented Sep 10, 2024

Consolidated Mocking Research into Current Branch

Description

This PR introduces the initial E2E API mocking test. When IsTest is true, the iOS/Android app redirects traffic to a proxy within the e2e folder for tests that require mocking. The mock server proxy forwards all traffic to its destination unless it matches specific mock requirements. The first test verifies that the suggestedGasApi falls back to the legacy endpoint when the EIP1559 API is down, displaying a legacy modal. The test then reinstates the service and asserts the modal change immediately.

Related issues

Fixes:https://github.com/orgs/MetaMask/projects/60/views/16?pane=issue&itemId=70977379

Manual testing steps

  1. Run e2e Detox setup
  2. Have IOS and Android sim ready
  3. For IOS run command yarn detox test -c ios.sim.debug e2e/specs/wallet/suggestedGasApi.mock.spec.js; for Android
    run yarn detox test -c android.emu.debug e2e/specs/wallet/suggestedGasApi.mock.spec.js

Screenshots/Recordings

After

https://www.loom.com/share/64d322a3f50d4888b1b7a96107008918
https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/ef9aaa7c-6247-4bf9-81fd-09bbaa76d7c8

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.

Merged all mocking research into this branch
Copy link

socket-security bot commented Sep 10, 2024

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

Package New capabilities Transitives Size Publisher
npm/@graphql-tools/merge@8.3.1 None 0 94.4 kB ardatan
npm/@graphql-tools/schema@8.5.1 None 0 64.8 kB ardatan
npm/@graphql-tools/utils@8.9.0 None 0 416 kB ardatan
npm/@httptoolkit/httpolyglot@2.2.1 network 0 29 kB pimterry
npm/@httptoolkit/subscriptions-transport-ws@0.11.2 None 0 270 kB pimterry
npm/@httptoolkit/websocket-stream@6.0.1 None 0 29.7 kB pimterry
npm/@types/cors@2.8.17 None 0 5.91 kB types
npm/ast-types@0.13.4 None 0 465 kB benjamn
npm/backo2@1.0.2 None 0 3.1 kB mokesmokes
npm/base64-arraybuffer@0.1.5 None 0 5.23 kB niklasvh
npm/brotli-wasm@3.0.1 filesystem 0 3.25 MB pimterry
npm/bytes@3.1.2 None 0 12.3 kB dougwilson
npm/cacheable-lookup@6.1.0 network 0 24.9 kB szmarczak
npm/common-tags@1.8.2 None 0 228 kB fatfisz
npm/cors-gate@1.1.3 None 0 17 kB ryanbrunner
npm/debug@4.3.7 environment 0 42.1 kB qix
npm/destroyable-server@1.0.2 None 0 22 kB pimterry
npm/eventemitter3@3.1.2 None 0 36.2 kB lpinca
npm/finalhandler@1.2.0 environment 0 18.6 kB dougwilson
npm/graphql-http@1.22.1 network 0 406 kB enisdenjo
npm/graphql-subscriptions@1.2.1 None 0 52.8 kB apollo-bot
npm/graphql-tag@2.12.6 None 0 172 kB apollo-bot
npm/graphql@15.9.0 environment 0 2.13 MB benjie
npm/http-encoding@2.0.1 None 0 48.1 kB pimterry
npm/http2-wrapper@2.2.1 network 0 75.9 kB szmarczak
npm/iconv-lite@0.4.24 None 0 336 kB ashtuchkin
npm/isomorphic-ws@4.0.1 None 0 3.89 kB heineiuo
npm/iterall@1.3.0 None 0 94.3 kB leebyron
npm/mockttp@3.15.2 filesystem, network 0 1.55 MB pimterry
npm/ms@2.1.3 None 0 6.72 kB styfle
npm/native-duplexpair@1.0.0 None 0 8.29 kB arthurschreiber
npm/pac-proxy-agent@7.0.2 network 0 33.5 kB tootallnate
npm/parse-multipart-data@1.5.0 None 0 27.6 kB imazzara
npm/read-tls-client-hello@1.0.1 None 0 58 kB pimterry
npm/socks-proxy-agent@8.0.4 network 0 24.8 kB tootallnate
npm/symbol-observable@1.2.0 eval 0 10.2 kB blesh
npm/typed-error@3.2.2 None 0 35.3 kB balena.io
npm/urlpattern-polyfill@8.0.2 None 0 103 kB sanderelias
npm/value-or-promise@1.0.11 None 0 28.5 kB yaacovcr
npm/zstd-codec@0.1.5 eval, filesystem, network 0 2.08 MB yoshihitoh

🚮 Removed packages: npm/ast-types@0.15.2, npm/bytes@3.0.0, npm/cacheable-lookup@5.0.4, npm/debug@4.3.5, npm/eventemitter3@4.0.7, npm/finalhandler@1.1.2, npm/http2-wrapper@1.0.3, npm/ip@2.0.1, npm/jsbn@0.1.1, npm/pac-proxy-agent@7.0.1, npm/socks@2.7.1

View full report↗︎

Copy link

socket-security bot commented Sep 10, 2024

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

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

Alert Package NoteSourceCI
Network access npm/@httptoolkit/httpolyglot@2.2.1 🚫
Network access npm/@httptoolkit/httpolyglot@2.2.1 🚫
Network access npm/@httptoolkit/httpolyglot@2.2.1 🚫
Network access npm/@httptoolkit/httpolyglot@2.2.1 🚫
Network access npm/graphql-http@1.22.1 🚫
Network access npm/zstd-codec@0.1.5 🚫
Network access npm/mockttp@3.15.2 🚫
Network access npm/mockttp@3.15.2 🚫
Network access npm/mockttp@3.15.2 🚫
Network access npm/mockttp@3.15.2 🚫
Network access npm/mockttp@3.15.2 🚫
Network access npm/mockttp@3.15.2 🚫
Network access npm/mockttp@3.15.2 🚫
Network access npm/mockttp@3.15.2 🚫
Network access npm/mockttp@3.15.2 🚫
Network access npm/mockttp@3.15.2 🚫

View full report↗︎

Next steps

What is network access?

This module accesses the network.

Packages should remove all network access that is functionally unnecessary. Consumers should audit network access to ensure legitimate use.

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 ecosystem/package-name@version specifiers. e.g. @SocketSecurity ignore npm/foo@1.0.0 or ignore all packages with @SocketSecurity ignore-all

  • @SocketSecurity ignore npm/@httptoolkit/httpolyglot@2.2.1
  • @SocketSecurity ignore npm/graphql-http@1.22.1
  • @SocketSecurity ignore npm/zstd-codec@0.1.5
  • @SocketSecurity ignore npm/mockttp@3.15.2

@Andepande Andepande changed the title First mocking test final branch test: E2E Mocking Setup for Detox Tests Sep 10, 2024
@SamuelSalas SamuelSalas added the Run Smoke E2E Triggers smoke e2e on Bitrise label Sep 11, 2024
Copy link
Contributor

github-actions bot commented Sep 11, 2024

https://bitrise.io/ Bitrise

❌❌❌ pr_smoke_e2e_pipeline failed on Bitrise! ❌❌❌

Commit hash: 322c948
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/7ce0f649-c868-4176-aaf6-49545d332be0

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

@SamuelSalas SamuelSalas added Run Smoke E2E Triggers smoke e2e on Bitrise and removed Run Smoke E2E Triggers smoke e2e on Bitrise labels Sep 11, 2024
Copy link
Contributor

github-actions bot commented Sep 11, 2024

https://bitrise.io/ Bitrise

❌❌❌ pr_smoke_e2e_pipeline failed on Bitrise! ❌❌❌

Commit hash: 8c64453
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/e9e5573f-19bb-4ed7-9bde-8fd2bfddc094

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

@Andepande Andepande changed the title test: E2E Mocking Setup for Detox Tests test: E2E Mocking Setup For Detox Tests Sep 11, 2024
@Andepande Andepande marked this pull request as ready for review September 11, 2024 12:34
@Andepande Andepande requested review from a team as code owners September 11, 2024 12:34
@Andepande Andepande added Run Smoke E2E Triggers smoke e2e on Bitrise and removed Run Smoke E2E Triggers smoke e2e on Bitrise labels Sep 11, 2024
@SamuelSalas SamuelSalas added the Run Smoke E2E Triggers smoke e2e on Bitrise label Sep 18, 2024
NicolasMassart
NicolasMassart previously approved these changes Sep 18, 2024
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. Great work!

@SamuelSalas SamuelSalas added Run Smoke E2E Triggers smoke e2e on Bitrise and removed Run Smoke E2E Triggers smoke e2e on Bitrise labels Sep 18, 2024
Copy link
Contributor

github-actions bot commented Sep 18, 2024

https://bitrise.io/ Bitrise

❌❌❌ pr_smoke_e2e_pipeline failed on Bitrise! ❌❌❌

Commit hash: 4545a94
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/b1497ab2-f6c4-42f0-98f7-3b97e59f2621

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

@SamuelSalas SamuelSalas added Run Smoke E2E Triggers smoke e2e on Bitrise and removed Run Smoke E2E Triggers smoke e2e on Bitrise labels Sep 18, 2024
@SamuelSalas SamuelSalas added Run Smoke E2E Triggers smoke e2e on Bitrise and removed Run Smoke E2E Triggers smoke e2e on Bitrise labels Sep 18, 2024
Copy link
Contributor

github-actions bot commented Sep 18, 2024

https://bitrise.io/ Bitrise

✅✅✅ pr_smoke_e2e_pipeline passed on Bitrise! ✅✅✅

Commit hash: d1f42bc
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/7d0b6a49-1059-4501-a413-2af9b094e8c9

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

Copy link

@SamuelSalas SamuelSalas added this pull request to the merge queue Sep 18, 2024
@SamuelSalas SamuelSalas removed this pull request from the merge queue due to a manual request Sep 18, 2024
github-actions bot pushed a commit that referenced this pull request Sep 18, 2024
Consolidated Mocking Research into Current Branch

<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->

## **Description**

This PR introduces the initial E2E API mocking test. When IsTest is
true, the iOS/Android app redirects traffic to a proxy within the e2e
folder for tests that require mocking. The mock server proxy forwards
all traffic to its destination unless it matches specific mock
requirements. The first test verifies that the suggestedGasApi falls
back to the legacy endpoint when the EIP1559 API is down, displaying a
legacy modal. The test then reinstates the service and asserts the modal
change immediately.

<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->

## **Related issues**


Fixes:https://github.com/orgs/MetaMask/projects/60/views/16?pane=issue&itemId=70977379

## **Manual testing steps**

1. Run e2e Detox setup 
2. Have IOS and Android sim ready
3. For IOS run command `yarn detox test -c ios.sim.debug
e2e/specs/wallet/suggestedGasApi.mock.spec.js;` for Android
run `yarn detox test -c android.emu.debug
e2e/specs/wallet/suggestedGasApi.mock.spec.js`

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **After**

<!-- [screenshots/recordings] -->
https://www.loom.com/share/64d322a3f50d4888b1b7a96107008918

https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/ef9aaa7c-6247-4bf9-81fd-09bbaa76d7c8
## **Pre-merge author checklist**

- [ ] I’ve followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I’ve included tests if applicable
- [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **Pre-merge reviewer checklist**

- [x] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [x] 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.

---------

Co-authored-by: SamuelSalas <samuel.salas.reyes@gmail.com>
@SamuelSalas SamuelSalas added this pull request to the merge queue Sep 18, 2024
Merged via the queue into main with commit 2cf4303 Sep 18, 2024
35 of 36 checks passed
@SamuelSalas SamuelSalas deleted the test-first-mock-e2e-test branch September 18, 2024 22:02
@github-actions github-actions bot locked and limited conversation to collaborators Sep 18, 2024
@metamaskbot metamaskbot added the release-7.32.0 Issue or pull request that will be included in release 7.32.0 label Sep 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Detox release-7.32.0 Issue or pull request that will be included in release 7.32.0 Run Smoke E2E Triggers smoke e2e on Bitrise team-mobile-platform
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

10 participants