Skip to content

fix: "Phishing Detection Via Iframe should redirect users ..." flaky test#26779

Merged
hjetpoluru merged 7 commits intodevelopfrom
fix-flaky-phishing-detection-test
Aug 30, 2024
Merged

fix: "Phishing Detection Via Iframe should redirect users ..." flaky test#26779
hjetpoluru merged 7 commits intodevelopfrom
fix-flaky-phishing-detection-test

Conversation

@hjetpoluru
Copy link
Copy Markdown
Contributor

@hjetpoluru hjetpoluru commented Aug 29, 2024

Description

Fix for flaky test "Phishing Detection Via Iframe should redirect users ..."
I am unable to reproduce the issue on my mac machine. However, based on the logs and screenshot, it appears that the Dapp was taking time to load after clicking the "Continue to the site" button on the phishing page.

  • I added a delay to allow the Dapp sufficient time to load completely before proceeding with further actions.
  • To prevent any race conditions from getting the header element and followed by getting the corresponding text from the element. I removed that code.
  • After Howard's suggestion, I updated the switchToWindowWithTitle method with a conditional wait provided by Selenium. This approach works effectively and provides logs in case of failure when the title is not loaded.

Open in GitHub Codespaces

Related issues

Fixes:
#26505

Manual testing steps

Run the below commands locally or in codespaces:
yarn
ENABLE_MV3=false yarn start:test
ENABLE_MV3=false yarn test:e2e:single test/e2e/tests/phishing-controller/phishing-detection.spec.js --browser=firefox

The test was executed x5 times against all the builds. Below is the link for the Firefox browser as reported in the flaky test failure:
https://app.circleci.com/pipelines/github/MetaMask/metamask-extension/98030/workflows/344ccffd-8671-46a9-83ab-5dce7a0b9cdd/jobs/3649076

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.

@hjetpoluru hjetpoluru added team-extension-platform Extension Platform team area-qa Relating to QA work (Quality Assurance) labels Aug 29, 2024
@hjetpoluru hjetpoluru self-assigned this Aug 29, 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.

@metamaskbot metamaskbot added the INVALID-PR-TEMPLATE PR's body doesn't match template label Aug 29, 2024
@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [46a4892]
Page Load Metrics (1581 ± 63 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint14632117158413364
domContentLoaded14572097156613062
load14642107158113263
domInteractive11133302612
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@codecov
Copy link
Copy Markdown

codecov bot commented Aug 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 70.13%. Comparing base (0490020) to head (3d2d3e8).
Report is 1 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop   #26779   +/-   ##
========================================
  Coverage    70.13%   70.13%           
========================================
  Files         1417     1417           
  Lines        49444    49444           
  Branches     13835    13835           
========================================
  Hits         34676    34676           
  Misses       14768    14768           

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

text: 'continue to the site.',
});
const header = await driver.findElement('h1');
assert.equal(await header.getText(), 'E2E Test Dapp');
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed this code to prevent race conditions.

const header = await driver.findElement('h1');
assert.equal(await header.getText(), 'E2E Test Dapp');

await driver.delay(2000);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is delay is needed to loading of dapp.

@hjetpoluru hjetpoluru marked this pull request as ready for review August 30, 2024 00:40
@hjetpoluru hjetpoluru requested a review from a team as a code owner August 30, 2024 00:40
@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [6e37386]
Page Load Metrics (1830 ± 49 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint22920371754364175
domContentLoaded16222025180010148
load16622039183010249
domInteractive208240157
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@HowardBraham
Copy link
Copy Markdown
Contributor

HowardBraham commented Aug 30, 2024

I think the safest and fastest-executing way to approach this is

await driver.wait(until.titleIs('E2E Test Dapp'), 10000);

and then no driver.delay. You will also have to add

const { until } = require('selenium-webdriver');

I have tested it myself, and it seems to work great.

EDIT: Oh right, also we should be using the constant WINDOW_TITLES.TestDApp

@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [0ef1973]
Page Load Metrics (1706 ± 65 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint15262266171115273
domContentLoaded15152155168213866
load15282170170613565
domInteractive226738168
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@hjetpoluru
Copy link
Copy Markdown
Contributor Author

thanks @HowardBraham, The approach you suggested works and is effective. I implemented all the points you mentioned, and the CI passes(yay yay!!). Please do approve at your convenience.

@sonarqubecloud
Copy link
Copy Markdown

@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [3d2d3e8]
Page Load Metrics (1688 ± 82 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint27322051543419201
domContentLoaded14772113167615776
load14802208168817082
domInteractive136534136
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

Copy link
Copy Markdown
Member

@seaona seaona 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 9d668dd into develop Aug 30, 2024
@hjetpoluru hjetpoluru deleted the fix-flaky-phishing-detection-test branch August 30, 2024 16:03
@github-actions github-actions bot locked and limited conversation to collaborators Aug 30, 2024
@metamaskbot metamaskbot added the release-12.6.0 Issue or pull request that will be included in release 12.6.0 label Aug 30, 2024
@gauthierpetetin gauthierpetetin added release-12.5.0 Issue or pull request that will be included in release 12.5.0 and removed release-12.6.0 Issue or pull request that will be included in release 12.6.0 labels Sep 11, 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) INVALID-PR-TEMPLATE PR's body doesn't match template release-12.5.0 Issue or pull request that will be included in release 12.5.0 team-extension-platform Extension Platform team

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

5 participants