Skip to content

Commit abe5cb3

Browse files
authored
fix: flaky test dApp Request Gas Limit should update the gas limit in the activity list after submitting a request with custom gas (above estimated gas limit) (#37488)
<!-- 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** The test is flaky because after we go to the Activity List and click on the Transaction to open the tx details, the tx details is not there. The problem is that we click on the tx when sometimes is not yet confirmed, causing that if we click just when the tx confirms (updates) the component re-renders and the modal is closed/not open. To avoid re-renders when we click, we'll always wait until the tx is confirmed/failed, then we click to open the details. Extra note: this spec is not following page objects. I leave out of the scope of this PR to migrate all the test, as this only intends to fix the flakiness, but we should migrate the test in a separate PR. <img width="1152" height="785" alt="image" src="https://github.com/user-attachments/assets/d50586b2-7636-4819-9d9d-72ee81aa7bfd" /> <img width="961" height="537" alt="image" src="https://github.com/user-attachments/assets/4c5c8ace-8c7e-4799-a25b-239e3063b9ba" /> [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/37488?quickstart=1) ## **Changelog** <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> CHANGELOG entry: ## **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. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.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/main/.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. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Stabilizes the dApp Request Gas Limit e2e tests by using the new login flow and Activity/Home page objects to verify and open transactions. > > - **Tests (`test/e2e/tests/confirmations/transactions/request-gas-limit.spec.ts`)**: > - Replace `unlockWallet` with `loginWithBalanceValidation`. > - Use `HomePage.goToActivityList()` instead of direct selector clicks. > - Use `ActivityListPage` to assert tx count/status (`checkFailedTxNumberDisplayedInActivity`, `checkConfirmedTxNumberDisplayedInActivity`) and open items (`clickTransactionListItem`). > - Maintain gas parameters and assert displayed gas limit in transaction details. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit c523733. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 90d9a9d commit abe5cb3

File tree

1 file changed

+28
-25
lines changed

1 file changed

+28
-25
lines changed

test/e2e/tests/confirmations/transactions/request-gas-limit.spec.ts

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
/* eslint-disable @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */
2+
import { loginWithBalanceValidation } from '../../../page-objects/flows/login.flow';
23
import { createDappTransaction } from '../../../page-objects/flows/transaction';
4+
import ActivityListPage from '../../../page-objects/pages/home/activity-list';
5+
import HomePage from '../../../page-objects/pages/home/homepage';
36
import TestDapp from '../../../page-objects/pages/test-dapp';
47
import { Driver } from '../../../webdriver/driver';
58

69
const { strict: assert } = require('assert');
710
const FixtureBuilder = require('../../../fixture-builder');
8-
const {
9-
withFixtures,
10-
unlockWallet,
11-
WINDOW_TITLES,
12-
} = require('../../../helpers');
11+
const { withFixtures, WINDOW_TITLES } = require('../../../helpers');
1312

1413
describe('dApp Request Gas Limit', function () {
1514
it('should update the gas limit in the activity list after submitting a request with custom gas (lower than 21000)', async function () {
@@ -29,7 +28,7 @@ describe('dApp Request Gas Limit', function () {
2928
title: this.test?.fullTitle(),
3029
},
3130
async ({ driver }: { driver: Driver }) => {
32-
await unlockWallet(driver);
31+
await loginWithBalanceValidation(driver);
3332

3433
const testDapp = new TestDapp(driver);
3534
await testDapp.openTestDappPage();
@@ -52,12 +51,13 @@ describe('dApp Request Gas Limit', function () {
5251
);
5352

5453
// Click on Activity tab
55-
await driver.clickElement(
56-
'[data-testid="account-overview__activity-tab"]',
57-
);
54+
const homePage = new HomePage(driver);
55+
await homePage.goToActivityList();
5856

5957
// Wait for the transaction to appear and click on it
60-
await driver.clickElement('[data-testid="activity-list-item"]');
58+
const activityList = new ActivityListPage(driver);
59+
await activityList.checkFailedTxNumberDisplayedInActivity(1);
60+
await activityList.clickTransactionListItem();
6161

6262
// Now on transaction details page, find and verify the gas limit
6363
const rows = await driver.findElements(
@@ -91,7 +91,7 @@ describe('dApp Request Gas Limit', function () {
9191
title: this.test?.fullTitle(),
9292
},
9393
async ({ driver }: { driver: Driver }) => {
94-
await unlockWallet(driver);
94+
await loginWithBalanceValidation(driver);
9595

9696
const testDapp = new TestDapp(driver);
9797
await testDapp.openTestDappPage();
@@ -114,12 +114,13 @@ describe('dApp Request Gas Limit', function () {
114114
);
115115

116116
// Click on Activity tab
117-
await driver.clickElement(
118-
'[data-testid="account-overview__activity-tab"]',
119-
);
117+
const homePage = new HomePage(driver);
118+
await homePage.goToActivityList();
120119

121120
// Wait for the transaction to appear and click on it
122-
await driver.clickElement('[data-testid="activity-list-item"]');
121+
const activityList = new ActivityListPage(driver);
122+
await activityList.checkFailedTxNumberDisplayedInActivity(1);
123+
await activityList.clickTransactionListItem();
123124

124125
// Now on transaction details page, find and verify the gas limit
125126
const rows = await driver.findElements(
@@ -153,7 +154,7 @@ describe('dApp Request Gas Limit', function () {
153154
title: this.test?.fullTitle(),
154155
},
155156
async ({ driver }: { driver: Driver }) => {
156-
await unlockWallet(driver);
157+
await loginWithBalanceValidation(driver);
157158

158159
const testDapp = new TestDapp(driver);
159160
await testDapp.openTestDappPage();
@@ -176,12 +177,13 @@ describe('dApp Request Gas Limit', function () {
176177
);
177178

178179
// Click on Activity tab
179-
await driver.clickElement(
180-
'[data-testid="account-overview__activity-tab"]',
181-
);
180+
const homePage = new HomePage(driver);
181+
await homePage.goToActivityList();
182182

183183
// Wait for the transaction to appear and click on it
184-
await driver.clickElement('[data-testid="activity-list-item"]');
184+
const activityList = new ActivityListPage(driver);
185+
await activityList.checkConfirmedTxNumberDisplayedInActivity(1);
186+
await activityList.clickTransactionListItem();
185187

186188
// Now on transaction details page, find and verify the gas limit
187189
const rows = await driver.findElements(
@@ -215,7 +217,7 @@ describe('dApp Request Gas Limit', function () {
215217
title: this.test?.fullTitle(),
216218
},
217219
async ({ driver }: { driver: Driver }) => {
218-
await unlockWallet(driver);
220+
await loginWithBalanceValidation(driver);
219221

220222
const testDapp = new TestDapp(driver);
221223
await testDapp.openTestDappPage();
@@ -238,12 +240,13 @@ describe('dApp Request Gas Limit', function () {
238240
);
239241

240242
// Click on Activity tab
241-
await driver.clickElement(
242-
'[data-testid="account-overview__activity-tab"]',
243-
);
243+
const homePage = new HomePage(driver);
244+
await homePage.goToActivityList();
244245

245246
// Wait for the transaction to appear and click on it
246-
await driver.clickElement('[data-testid="activity-list-item"]');
247+
const activityList = new ActivityListPage(driver);
248+
await activityList.checkConfirmedTxNumberDisplayedInActivity(1);
249+
await activityList.clickTransactionListItem();
247250

248251
// Now on transaction details page, find and verify the gas limit
249252
const rows = await driver.findElements(

0 commit comments

Comments
 (0)