Skip to content

Commit

Permalink
test: fix flaky test `Increase Token Allowance increases token spendi…
Browse files Browse the repository at this point in the history
…ng cap to allow other accounts to transfer tokens @no-mmi` (#24734)

## **Description**
This PR fixes the flaky test `Increase Token Allowance increases token
spending cap to allow other accounts to transfer tokens @no-mmi).`
The problem with this flaky test is that we are changing the allowance
amount (from 0 to 1) and we confirm the transaction before the gas has
been updated. This makes that the increase token allowance transaction
fails, and the subsequent transaction with the Account 2 cannot be
performed as it doesn't have the allowance for doing a transfer from
action. So the dialog window cannot be found, as the popup is never
triggered (see dapp error).

The fix is to simply await for the expected gas for the
increaseAllowance with amount 1.

This can be clearly seen when you check the tx history from Account 1:

- Here is a successful increaseAllowance with amount 1, and the total
gas is `31000` -- correct

![Screenshot from 2024-05-23
09-41-59](https://github.com/MetaMask/metamask-extension/assets/54408225/727cc834-de9c-452a-81a6-e8fb40e2f75d)

- Here is a failed increaseAllowance with amount 1, and the total gas
limit is `26776` -- incorrect (this value corresponds to the
increaseAllowance with amount 0)

![Screenshot from 2024-05-23
09-41-53](https://github.com/MetaMask/metamask-extension/assets/54408225/e23fdc1b-0c53-48e5-9368-a17a6bdc7fb4)

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

## **Related issues**

Fixes: one of this cases, but not all of them, as the rest of testcases
need to be looked separately
#24603

## **Manual testing steps**

1. Run this test locally multiple times
2. Check ci jobs `yarn test:e2e:single
test/e2e/tests/tokens/increase-token-allowance.spec.js --browser=firefox
--leave-running --retryUntilFailure --retries=10`

## **Screenshots/Recordings**


https://github.com/MetaMask/metamask-extension/assets/54408225/c0d32e57-6ace-4c59-a667-dcafc3421a7c



## **Pre-merge author checklist**

- [X] I’ve followed [MetaMask Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md).
- [X] I've completed the PR template to the best of my ability
- [X] I’ve included tests if applicable
- [X] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [X] 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.
  • Loading branch information
seaona authored May 23, 2024
1 parent fb1c65b commit c10a4a3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion test/e2e/tests/tokens/increase-token-allowance.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,14 @@ describe('Increase Token Allowance', function () {
tag: 'button',
text: 'Next',
});
driver.waitForSelector({
await driver.waitForSelector({
css: '.box--display-flex > h6',
text: `10 TST`,
});
await driver.waitForSelector({
tag: 'h6',
text: '0.000062 ETH',
});
await driver.waitForSelector({
text: `${finalSpendingCap} TST`,
css: '.mm-box > h6',
Expand Down

0 comments on commit c10a4a3

Please sign in to comment.