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

fix: refactor saga xhr injection; only perform xhr2 injection on test

Open legobeat opened this issue 1 year ago • 18 comments
trafficstars

Description

The basic functionality toggle saga relies on monkeypatching the root XmlHttpRequest.send and XmlHttpRequest.open in order to properly respect user privacy preferences.

But is requires the use of xhr2 as the unit tests are running in node.js environment with Jest and not in a React Native one.

This PR makes sure the replacement for xhr is properly done according to the environment.

  • Break out xhr override functionality from saga into new file app/store/sagas/xmlHttpRequestOverride.ts
  • Guard monkeypatching using xhr2 to only run in Jest environment
  • fix: Don't ignore async,username,password options.

Related issues

  • #9584

Manual testing steps

  1. Monitor outgoing network requests
  2. Toggle basic functionality off
  3. Navigate around the app
  4. Notice blocked network requests not being sent out
  5. Enable basic functionaliy toggle
  6. Navigate around the app
  7. Notice previously blocked requests being sent out

Screenshots/Recordings

Before

After

Pre-merge author checklist

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.

legobeat avatar Jun 08 '24 02:06 legobeat

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 Jun 08 '24 02:06 github-actions[bot]

https://bitrise.io/ Bitrise

✅✅✅ pr_smoke_e2e_pipeline passed on Bitrise! ✅✅✅

Commit hash: f515674eafea2b3ade3c4ffd9059bc6adaf35bf5 Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/59c11970-c89f-477c-be08-7cd79dd8d0f9

[!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

github-actions[bot] avatar Jun 08 '24 02:06 github-actions[bot]

https://bitrise.io/ Bitrise

❌❌❌ pr_smoke_e2e_pipeline failed on Bitrise! ❌❌❌

Commit hash: dce8717da43323a2e6429f808a7e2b35a75b1ce6 Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/74f17515-0526-4f19-8053-022b3fa3c626

[!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

github-actions[bot] avatar Jun 08 '24 03:06 github-actions[bot]

https://bitrise.io/ Bitrise

✅✅✅ pr_smoke_e2e_pipeline passed on Bitrise! ✅✅✅

Commit hash: e4eae7547c709a3577a8cf32e8224e4acd1f3714 Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/67eab2fb-c1b5-4fdf-8ce2-a9fbdbb772b8

[!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

github-actions[bot] avatar Jun 08 '24 05:06 github-actions[bot]

https://bitrise.io/ Bitrise

❌❌❌ pr_smoke_e2e_pipeline failed on Bitrise! ❌❌❌

Commit hash: 102eb971455dd787a03bd60daf09c86d1106a835 Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/f191787d-dc5d-486c-bd47-647457f3e6fa

[!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

github-actions[bot] avatar Jun 10 '24 08:06 github-actions[bot]

https://bitrise.io/ Bitrise

✅✅✅ pr_smoke_e2e_pipeline passed on Bitrise! ✅✅✅

Commit hash: ff0f431f3a1d21c35dbf9d065758ae04eaf5b21c Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/98bf9c00-d575-455a-9521-ad23bf273c92

[!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

github-actions[bot] avatar Jun 10 '24 08:06 github-actions[bot]

https://bitrise.io/ Bitrise

❌❌❌ pr_smoke_e2e_pipeline failed on Bitrise! ❌❌❌

Commit hash: 781b5ae635e8a3a6fe4993f021839ed5ff68452a Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/7219f259-e97e-4737-9179-7cdae0739da8

[!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

github-actions[bot] avatar Jun 18 '24 01:06 github-actions[bot]

https://bitrise.io/ Bitrise

✅✅✅ pr_smoke_e2e_pipeline passed on Bitrise! ✅✅✅

Commit hash: 849adf8e4062a47b7a12aff480ff64bcb0180a32 Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/12438d0a-f6a7-45f7-9194-e807f2c98fdd

[!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

github-actions[bot] avatar Jun 19 '24 22:06 github-actions[bot]

https://bitrise.io/ Bitrise

✅✅✅ pr_smoke_e2e_pipeline passed on Bitrise! ✅✅✅

Commit hash: 2fe1f62c2875109ddd38c9fd8237d7093dd3885e Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/59fd3bd3-7a18-4f5e-a427-0fffb2e80b11

[!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

github-actions[bot] avatar Jul 12 '24 20:07 github-actions[bot]

https://bitrise.io/ Bitrise

✅✅✅ pr_smoke_e2e_pipeline passed on Bitrise! ✅✅✅

Commit hash: 24d251717c669d5e68d41b0d8bc598bcf1eb2a55 Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/0d586ffc-b1f5-46df-9de7-31ca2ebacc69

[!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

github-actions[bot] avatar Jul 23 '24 03:07 github-actions[bot]

https://bitrise.io/ Bitrise

❌❌❌ pr_smoke_e2e_pipeline failed on Bitrise! ❌❌❌

Commit hash: ce60add28b20dee96b173c57ff3a6b10e9ae870a Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/1932250a-f5a5-4705-91c4-9b9f569f6802

[!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

github-actions[bot] avatar Aug 28 '24 09:08 github-actions[bot]

https://bitrise.io/ Bitrise

✅✅✅ pr_smoke_e2e_pipeline passed on Bitrise! ✅✅✅

Commit hash: 21e91b2ffbfdcff748691f9f563fe7bc563076b5 Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/6d3981a4-ded0-4bcc-9f4e-bf6d5f373a52

[!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

github-actions[bot] avatar Aug 28 '24 09:08 github-actions[bot]

https://bitrise.io/ Bitrise

✅✅✅ pr_smoke_e2e_pipeline passed on Bitrise! ✅✅✅

Commit hash: 5737d19c2fe70ef7c55318ef6e341a72369d7dd7 Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/39b25a2c-f043-4e06-9afc-b6d5c89212d4

[!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

github-actions[bot] avatar Aug 28 '24 10:08 github-actions[bot]

https://bitrise.io/ Bitrise

✅✅✅ pr_smoke_e2e_pipeline passed on Bitrise! ✅✅✅

Commit hash: 865adc3879e924393adc41d14cc7f9f5cf2526e3 Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/5f918be8-2a98-4476-b172-88709ec596ba

[!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

github-actions[bot] avatar Aug 28 '24 19:08 github-actions[bot]

Codecov Report

Attention: Patch coverage is 96.15385% with 1 line in your changes missing coverage. Please review.

Project coverage is 52.76%. Comparing base (d95e1fc) to head (865adc3). Report is 26 commits behind head on main.

Files with missing lines Patch % Lines
app/store/sagas/xmlHttpRequestOverride.ts 96.15% 0 Missing and 1 partial :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9910      +/-   ##
==========================================
+ Coverage   52.60%   52.76%   +0.15%     
==========================================
  Files        1530     1533       +3     
  Lines       36709    36775      +66     
  Branches     4313     4335      +22     
==========================================
+ Hits        19312    19403      +91     
+ Misses      16086    16056      -30     
- Partials     1311     1316       +5     

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

codecov-commenter avatar Aug 28 '24 19:08 codecov-commenter

https://bitrise.io/ Bitrise

✅✅✅ pr_smoke_e2e_pipeline passed on Bitrise! ✅✅✅

Commit hash: e0841713a1104fe1ea31482dbaa532f2210c946f Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/ba131d58-7481-4673-80bf-31b5cc97b7a4

[!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

github-actions[bot] avatar Aug 28 '24 21:08 github-actions[bot]