From c10a4a3d64f942faa82948de536e64d7c0144404 Mon Sep 17 00:00:00 2001 From: seaona <54408225+seaona@users.noreply.github.com> Date: Thu, 23 May 2024 13:18:28 +0200 Subject: [PATCH] test: fix flaky test `Increase Token Allowance increases token spending cap to allow other accounts to transfer tokens @no-mmi` (#24734) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## **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 https://github.com/MetaMask/metamask-extension/issues/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. --- test/e2e/tests/tokens/increase-token-allowance.spec.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/e2e/tests/tokens/increase-token-allowance.spec.js b/test/e2e/tests/tokens/increase-token-allowance.spec.js index 1a1e861d6bad..e0f353de1245 100644 --- a/test/e2e/tests/tokens/increase-token-allowance.spec.js +++ b/test/e2e/tests/tokens/increase-token-allowance.spec.js @@ -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',