Skip to content

Commit

Permalink
test: Fix Swap Smoke tests failures (#8254)
Browse files Browse the repository at this point in the history
## **Description**

The problem with these tests is that we check for the Swap to complete
we wait for this pop up message to appear Swap complete ETH to DAI so we
call checkIfElementByTextIsVisible which has a timeout of 25 secs.
However sometime, depending on network conditions, it can take longer
and that’s what causes the flakiness. Right now the 25 secs is hardcoded
in checkIfElementByTextIsVisible. I changed the parameter to be optional
so I can pass 60 secs which should be enough for the Swap to complete.

I also changed some the `Swap from the token chart` test to be a
regression not a smoke as it's uncommon
and added token chart display test as smoke test

## **Related issues**

Fixes:

## **Manual testing steps**

1. Go to this page...
2.
3.

## **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 Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've clearly explained what problem this PR is solving and how it
is solved.
- [ ] I've linked related issues
- [ ] I've included manual testing steps
- [ ] I've included screenshots/recordings if applicable
- [ ] I’ve included tests if applicable
- [ ] 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-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.
- [x] I’ve properly set the pull request status:
  - [ ] In case it's not yet "ready for review", I've set it to "draft".
- [ ] In case it's "ready for review", I've changed it from "draft" to
"non-draft".

## **Pre-merge reviewer checklist**

- [x] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [x] 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
davibroc authored Jan 12, 2024
1 parent 845b78d commit 93ce2e2
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions e2e/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,10 @@ export default class TestHelpers {
.withTimeout(10000);
}

static async checkIfElementByTextIsVisible(text) {
static async checkIfElementByTextIsVisible(text, timeout = 25000) {
return await waitFor(element(by.text(text)))
.toBeVisible()
.withTimeout(25000);
.withTimeout(timeout);
}

static async checkIfElementHasString(elementID, text) {
Expand Down
2 changes: 1 addition & 1 deletion e2e/pages/swaps/SwapView.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ export default class SwapView {
}

static async waitForSwapToComplete(sourceTokenSymbol, destTokenSymbol) {
await TestHelpers.delay(5000);
await TestHelpers.checkIfElementByTextIsVisible(
`Swap complete (${sourceTokenSymbol} to ${destTokenSymbol})`,
60000,
);
await device.enableSynchronization();
await TestHelpers.delay(5000);
Expand Down
4 changes: 2 additions & 2 deletions e2e/specs/swaps/swap-token-chart.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ import Networks from '../../resources/networks.json';
import TestHelpers from '../../helpers';
import FixtureServer from '../../fixtures/fixture-server';
import { getFixturesServerPort } from '../../fixtures/utils';
import { SmokeSwaps } from '../../tags';
import { Regression } from '../../tags';

const fixtureServer = new FixtureServer();

describe(SmokeSwaps('Swap from Token view'), () => {
describe(Regression('Swap from Token view'), () => {
const swapOnboarded = true; // TODO: Set it to false once we show the onboarding page again.
beforeAll(async () => {
await TestHelpers.reverseServerPort();
Expand Down
4 changes: 2 additions & 2 deletions e2e/specs/swaps/token-details.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

import { Regression } from '../../tags';
import { SmokeSwaps } from '../../tags';
import WalletView from '../../pages/WalletView';
import TokenOverview from '../../pages/TokenOverview';
import {
Expand All @@ -9,7 +9,7 @@ import {
} from '../../viewHelper';
import Networks from '../../resources/networks.json';

describe(Regression('Token Chart Tests'), () => {
describe(SmokeSwaps('Token Chart Tests'), () => {
beforeAll(async () => {
jest.setTimeout(150000);
await device.launchApp();
Expand Down

0 comments on commit 93ce2e2

Please sign in to comment.