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: flaky test Import flow @no-mmi Import wallet using Secret Recovery Phrase with pasting word by word #26049

Merged
merged 5 commits into from
Jul 23, 2024

Conversation

seaona
Copy link
Contributor

@seaona seaona commented Jul 23, 2024

Description

The test Import flow @no-mmi Import wallet using Secret Recovery Phrase with pasting word by word fails because after opting out from metametrics, we land into the Home page again instead of going to the Import SRP page, causing the test to fail as the srp element cannot be located (ci failure).

This is a race condition on the wallet level, and not on the test level: iinstead of going inside the ONBOARDING_IMPORT_WITH_SRP_ROUTE condition, we fallback to the DEFAULT_ROUTE which directs you to home (see screenshot of the failure):

export function getFirstTimeFlowTypeRouteAfterMetaMetricsOptIn(state) {
  const { firstTimeFlowType } = state.metamask;

  if (firstTimeFlowType === FirstTimeFlowType.create) {
    return ONBOARDING_CREATE_PASSWORD_ROUTE;
  } else if (firstTimeFlowType === FirstTimeFlowType.import) {
    return ONBOARDING_IMPORT_WITH_SRP_ROUTE;
  } else if (firstTimeFlowType === FirstTimeFlowType.restore) {
    return ONBOARDING_SECURE_YOUR_WALLET_ROUTE;
  }
  return DEFAULT_ROUTE;
}

I am able to consistently reproduce it locally if I add a timeout in the onImportClick function:

  const onImportClick = async () => {
    setTimeout(async () => {
    dispatch(setFirstTimeFlowType(FirstTimeFlowType.import));
    }, 200);

Open in GitHub Codespaces

Related issues

Fixes: #26053

Manual testing steps

  1. Check ci hasn''t failed anymore with the Import flow @no-mmi Import wallet using Secret Recovery Phrase with pasting word by word

Screenshots/Recordings

Race condition which lands me back to HOME page:

race-condition-import-flow.mp4

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.

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.

Copy link

@seaona seaona changed the title test: flaky fix import srp fix: flaky test Import flow @no-mmi Import wallet using Secret Recovery Phrase with pasting word by word Jul 23, 2024
@seaona seaona added the area-qa Relating to QA work (Quality Assurance) label Jul 23, 2024
@seaona seaona self-assigned this Jul 23, 2024
@seaona seaona added Sev2-normal Normal severity; minor loss of service or inconvenience. flaky tests labels Jul 23, 2024
@seaona seaona marked this pull request as ready for review July 23, 2024 15:53
@seaona seaona requested a review from a team as a code owner July 23, 2024 15:53
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

This pull request addresses a race condition in the onboarding flow by ensuring asynchronous actions are properly awaited.

  • ui/pages/onboarding-flow/welcome/welcome.js: Made dispatch call in onImportClick function asynchronous to prevent race conditions.
  • ui/pages/onboarding-flow/welcome/welcome.test.js: Updated tests to use waitFor for asynchronous actions, improving test reliability.
  • ui/store/actions.ts: Modified setFirstTimeFlowType to return a Promise<void> and use async/await for better async handling.

3 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings

@seaona seaona removed the Sev2-normal Normal severity; minor loss of service or inconvenience. label Jul 23, 2024
@metamaskbot
Copy link
Collaborator

Builds ready [1f07bb2]
Page Load Metrics (167 ± 203 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint68158982211
domContentLoaded96225147
load432010167423203
domInteractive96225147
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 0 Bytes (0.00%)
  • ui: 6 Bytes (0.00%)
  • common: 20 Bytes (0.00%)

Copy link

codecov bot commented Jul 23, 2024

Codecov Report

Attention: Patch coverage is 12.50000% with 7 lines in your changes missing coverage. Please review.

Project coverage is 69.68%. Comparing base (a3c4333) to head (1f07bb2).
Report is 2 commits behind head on develop.

Files Patch % Lines
ui/store/actions.ts 0.00% 7 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           develop   #26049   +/-   ##
========================================
  Coverage    69.68%   69.68%           
========================================
  Files         1405     1405           
  Lines        49701    49701           
  Branches     13738    13737    -1     
========================================
  Hits         34630    34630           
  Misses       15071    15071           

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

Copy link
Contributor

@danjm danjm left a comment

Choose a reason for hiding this comment

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

LGTM!

@hjetpoluru hjetpoluru merged commit 5272c59 into develop Jul 23, 2024
106 checks passed
@hjetpoluru hjetpoluru deleted the flaky-fix-import-srp branch July 23, 2024 16:32
@github-actions github-actions bot locked and limited conversation to collaborators Jul 23, 2024
@metamaskbot metamaskbot added the release-12.3.0 Issue or pull request that will be included in release 12.3.0 label Jul 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-qa Relating to QA work (Quality Assurance) flaky tests release-12.3.0 Issue or pull request that will be included in release 12.3.0 team-extension-platform
Projects
None yet
Development

Successfully merging this pull request may close these issues.

flaky test: Import flow @no-mmi Import wallet using Secret Recovery Phrase with pasting word by word
5 participants