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

fix: Address performance issues with 'Portfolio Dashboard' loading in test environment #26182

Merged
merged 1 commit into from
Jul 29, 2024

Conversation

albertolive
Copy link
Contributor

@albertolive albertolive commented Jul 29, 2024

Description

We have noticed significant performance issues when accessing the 'Settings' menu option due to delays in loading the 'Portfolio Dashboard'. This delay has caused flakiness in many of our automated tests. The issue appears to have started after changes were made in PR #25899.

Root Cause:
The performance issue is linked to an HTTP request to https://configuration.dev.metamask-institutional.io/v2/configuration/default to check if portfolio.enabled is true. This request is made in the onSubmitPassword method in the mmi-controller file, resulting in delays.

Solution:
To mitigate this issue, we have decided to set the portfolio.enabled variable to true by default in the test environment. This will ensure the 'Portfolio Dashboard' item always appears in the menu during tests, thereby preventing delays caused by the HTTP request and stabilizing our automated tests.

Changes Made:

  • Updated the getMmiPortfolioEnabled function to return true if the IN_TEST environment variable is set.
  • This change applies only in the test environment, ensuring that the production environment remains unaffected.
export function getMmiPortfolioEnabled(state) {
  if (process.env.IN_TEST) {
    return true;
  }

  return state.metamask.mmiConfiguration?.portfolio?.enabled;
}

Open in GitHub Codespaces

Related issues

Fixes:

Manual testing steps

  1. Attempt to click on the Settings menu option.
  2. Observe the delay in the ‘Portfolio Dashboard’ loading.

Screenshots/Recordings

Before

After

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.

… test environment

We have noticed significant performance issues when accessing the 'Settings' menu option due to delays in loading the 'Portfolio Dashboard'. This delay has caused flakiness in many of our automated tests. The issue appears to have started after changes were made in PR #25899.

Root Cause:
The performance issue is linked to an HTTP request to `https://configuration.dev.metamask-institutional.io/v2/configuration/default` to check if `portfolio.enabled` is true. This request is made in the `onSubmitPassword` method in the `mmi-controller` file, resulting in delays.

Solution:
To mitigate this issue, we have decided to set the `portfolio.enabled` variable to `true` by default in the test environment. This will ensure the 'Portfolio Dashboard' item always appears in the menu during tests, thereby preventing delays caused by the HTTP request and stabilizing our automated tests.

Changes Made:
- Updated the `getMmiPortfolioEnabled` function to return `true` if the `IN_TEST` environment variable is set.
- This change applies only in the test environment, ensuring that the production environment remains unaffected.

```diff
export function getMmiPortfolioEnabled(state) {
  if (process.env.IN_TEST) {
    return true;
  }

  return state.metamask.mmiConfiguration?.portfolio?.enabled;
}
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.

@albertolive albertolive added the team-mmi PRs from the MMI team label Jul 29, 2024
Copy link

sonarcloud bot commented Jul 29, 2024

Copy link

codecov bot commented Jul 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 69.93%. Comparing base (efbdd42) to head (64ff164).
Report is 1 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop   #26182   +/-   ##
========================================
  Coverage    69.93%   69.93%           
========================================
  Files         1409     1409           
  Lines        49786    49788    +2     
  Branches     13769    13770    +1     
========================================
+ Hits         34817    34819    +2     
  Misses       14969    14969           

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

@metamaskbot
Copy link
Collaborator

Builds ready [64ff164]
Page Load Metrics (433 ± 417 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint802861235326
domContentLoaded107929189
load413110433868417
domInteractive107929189
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@hjetpoluru hjetpoluru self-requested a review July 29, 2024 12:45
Copy link
Contributor

@hjetpoluru hjetpoluru left a comment

Choose a reason for hiding this comment

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

Thanks @albertolive, I checked manually and 'Portfolio Dashboard' is always appearing in the menu for the test build and LGTM!!

@albertolive albertolive marked this pull request as ready for review July 29, 2024 12:57
@albertolive albertolive requested a review from a team as a code owner July 29, 2024 12:57
@albertolive albertolive merged commit 0d8b35f into develop Jul 29, 2024
106 checks passed
@albertolive albertolive deleted the MMI-5330-flaky-portfolio-fashboard-item-menu branch July 29, 2024 14:21
@github-actions github-actions bot locked and limited conversation to collaborators Jul 29, 2024
@metamaskbot metamaskbot added the release-12.4.0 Issue or pull request that will be included in release 12.4.0 label Jul 29, 2024
@gauthierpetetin gauthierpetetin added release-12.3.0 Issue or pull request that will be included in release 12.3.0 and removed release-12.4.0 Issue or pull request that will be included in release 12.4.0 labels Sep 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-12.3.0 Issue or pull request that will be included in release 12.3.0 team-mmi PRs from the MMI team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants