Skip to content

Commit bf83353

Browse files
authored
fix: flaky test Smart Transactions Swap (#32032)
<!-- 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** Flaky test due to anti-pattern usage of getText, instead of looking for the target text to be rendered. https://app.circleci.com/pipelines/github/MetaMask/metamask-extension/140221/workflows/d5037001-7fe3-4784-bf7c-4eecbdb58a97/jobs/4778615/tests#failed-test-0 [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/32032?quickstart=1) ## **Related issues** Fixes: #32036 ## **Manual testing steps** 1. Check FF run in ci here https://app.circleci.com/pipelines/github/MetaMask/metamask-extension/140350/workflows/3024f7d1-5398-42a5-8274-af8c76709072/jobs/4781457/steps ## **Screenshots/Recordings** ![Screenshot from 2025-04-16 11-27-43](https://github.com/user-attachments/assets/1f1c006b-c8b1-430f-ad14-45f65453f549) ## **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.
1 parent a2faefa commit bf83353

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

test/e2e/tests/swaps/shared.ts

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,17 @@ export const reviewQuote = async (
7474
'[data-testid="exchange-rate-display-quote-rate"]',
7575
);
7676
const summaryText = await summary.getText();
77-
assert.equal(summaryText.includes(options.swapFrom), true);
78-
assert.equal(summaryText.includes(options.swapTo), true);
77+
78+
await driver.waitForSelector({
79+
testId: 'prepare-swap-page-swap-from',
80+
text: options.swapFrom,
81+
});
82+
83+
await driver.waitForSelector({
84+
testId: 'prepare-swap-page-swap-to',
85+
text: options.swapTo,
86+
});
87+
7988
const quote = summaryText.split(`\n`);
8089

8190
const elementSwapToAmount = await driver.findElement(
@@ -138,22 +147,20 @@ export const checkActivityTransaction = async (
138147
await driver.clickElement('[data-testid="account-overview__activity-tab"]');
139148
await driver.waitForSelector('.activity-list-item');
140149

141-
const transactionList = await driver.findElements(
142-
'[data-testid="activity-list-item-action"]',
143-
);
144-
const transactionText = await transactionList[options.index].getText();
145-
assert.equal(
146-
transactionText,
147-
`Swap ${options.swapFrom} to ${options.swapTo}`,
148-
'Transaction not found',
149-
);
150+
await driver.waitForSelector({
151+
tag: 'p',
152+
text: `Swap ${options.swapFrom} to ${options.swapTo}`,
153+
});
150154

151155
await driver.findElement({
152156
css: '[data-testid="transaction-list-item-primary-currency"]',
153157
text: `-${options.amount} ${options.swapFrom}`,
154158
});
155159

156-
await transactionList[options.index].click();
160+
await driver.clickElement({
161+
tag: 'p',
162+
text: `Swap ${options.swapFrom} to ${options.swapTo}`,
163+
});
157164
await driver.delay(regularDelayMs);
158165

159166
await driver.findElement({

0 commit comments

Comments
 (0)