Skip to content

test: add missing mocks for aggregator metadata, block list and include blocked tokens in all tests#25206

Merged
seaona merged 6 commits intodevelopfrom
e2e-mock-aggregator
Jun 12, 2024
Merged

test: add missing mocks for aggregator metadata, block list and include blocked tokens in all tests#25206
seaona merged 6 commits intodevelopfrom
e2e-mock-aggregator

Conversation

@seaona
Copy link
Copy Markdown
Member

@seaona seaona commented Jun 11, 2024

Description

The responses for the API Calls to aggregator metadata, block list and blocked tokens are not currently mocked on any tests, however the requests happen in the majority of tests. These request return a json back that takes in some occasions more than 1 second to return.

With this PR we mock these responses, so they are immediate, mitigating any possible delay and flakiness due to real live requests.

Note: We are returning the data, since it's been seen that if we return just an empty json, some tests fail as they rely on some data from that requests

Open in GitHub Codespaces

Related issues

Fixes: https://github.com/MetaMask/MetaMask-planning/issues/2637

Manual testing steps

  1. All tests should continue to pass in ci
  2. Check screenshots with the real API requests and slow responses

Screenshots/Recordings

Before

See slow responses for the 3 API requests happening in tests:

  • blocklist: 1.20s

Screenshot from 2024-06-11 12-04-47

  • aggregator metadata: 644ms

Screenshot from 2024-06-11 11-24-24

  • includeBlockedTokens: 664ms

Screenshot from 2024-06-11 12-04-56

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.

@seaona seaona requested a review from a team as a code owner June 11, 2024 09:52
@seaona seaona self-assigned this Jun 11, 2024
@github-actions
Copy link
Copy Markdown
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.

@seaona seaona added team-extension-platform Extension Platform team flaky tests labels Jun 11, 2024
@seaona seaona changed the title test: add mock for aggregator metadata in all tests test: add missing mocks for aggregator metadata, block list and include blocked tokens in all tests Jun 11, 2024
@seaona seaona marked this pull request as draft June 11, 2024 10:32
@seaona seaona marked this pull request as ready for review June 11, 2024 13:34
@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [7adf39b]
Page Load Metrics (51 ± 3 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint701008484
domContentLoaded10131110
load41665173
domInteractive10131110
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@DDDDDanica
Copy link
Copy Markdown
Contributor

Good finding, LGTM !


await server
.forGet('https://swap.api.cx.metamask.io/networks/1/token')
.forGet(`${SWAPS_API_V2_BASE_URL}/networks/1/token`)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nice

@seaona seaona merged commit 5988cc5 into develop Jun 12, 2024
@seaona seaona deleted the e2e-mock-aggregator branch June 12, 2024 16:31
@github-actions github-actions bot locked and limited conversation to collaborators Jun 12, 2024
@metamaskbot metamaskbot added the release-12.1.0 Issue or pull request that will be included in release 12.1.0 label Jun 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

flaky tests release-12.1.0 Issue or pull request that will be included in release 12.1.0 team-extension-platform Extension Platform team

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants