Skip to content

Commit

Permalink
fix: flaky test screenshot for `Increase Token Allowance increases to…
Browse files Browse the repository at this point in the history
…ken spending cap to allow other accounts to transfer tokens ` (#25324)

<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->

## **Description**
This test fails whenever we try to switch to the MetaMask Dialog. 
This PR waits until there are 3 window handles and then performs the
window switch. Not sure yet which is the cause of the Dialog not
appearing, as I cannot reproduce it locally. However, the benefit of
this change is that in the case the dialog does not appear, now we'll be
able to take a screenshot and check the artifacts for further
information and debugging.

See ci failure:
https://app.circleci.com/pipelines/github/MetaMask/metamask-extension/87524/workflows/aa81e40a-0aa1-40dc-9ddf-dc83b4db83f1/jobs/3205989/parallel-runs/8?filterBy=FAILED

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/25324?quickstart=1)

## **Related issues**

Fixes:

## **Manual testing steps**

1. Check ci

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

![Screenshot from 2024-06-14
15-30-23](https://github.com/MetaMask/metamask-extension/assets/54408225/41fd0f92-2d50-4550-a43b-04005d7dc912)

See how no screenshot was taken due to the failure on the window switch

![Screenshot from 2024-06-14
15-30-39](https://github.com/MetaMask/metamask-extension/assets/54408225/88c7b4f9-7a5f-4bea-86ee-635fb9de41ce)

## **Pre-merge author checklist**

- [ ] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md).
- [ ] I've completed the PR template to the best of my ability
- [ ] I’ve included tests if applicable
- [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **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.

---------

Co-authored-by: HJetpoluru <harika.jetpoluru@consensys.net>
Co-authored-by: Harika Jetpoluru <153644847+hjetpoluru@users.noreply.github.com>
  • Loading branch information
3 people authored Jun 24, 2024
1 parent 64b8db4 commit fcb4265
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions test/e2e/tests/tokens/increase-token-allowance.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,8 @@ describe('Increase Token Allowance', function () {
});
await driver.delay(2000);

// Windows: MetaMask, Test Dapp and Dialog
await driver.waitUntilXWindowHandles(3);
await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog);
let spendingCapElement = await driver.findElement(
'[data-testid="custom-spending-cap-input"]',
Expand Down Expand Up @@ -297,6 +299,8 @@ describe('Increase Token Allowance', function () {
}

async function confirmTransferFromTokensSuccess(driver) {
// Windows: MetaMask, Test Dapp and Dialog
await driver.waitUntilXWindowHandles(3, 1000, 10000);
await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog);
await driver.waitForSelector({ text: '1.5 TST', tag: 'h1' });
await driver.clickElement({ text: 'Confirm', tag: 'button' });
Expand Down

0 comments on commit fcb4265

Please sign in to comment.