Skip to content

Commit

Permalink
test: initial ramps E2E test to build quote (#11086)
Browse files Browse the repository at this point in the history
<!--
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**

This is the initial foundation for Ramps Mobile E2E tests. This adds the
first basic user flow, which is to login, go through onboarding, select
region and payment method, and verify the Build Quote view appears.

## **Related issues**

https://consensyssoftware.atlassian.net/browse/RAMPS-1858

## **Manual testing steps**
```
 PASS  e2e/specs/ramps/onramp.spec.js (43.097 s)
  SmokeRamps Buy Crypto
    ✓ should select Region and Payment Method to see the Build Quote screen (15625 ms)

Test Suites: 1 passed, 1 total
Tests:       1 passed, 1 total
Snapshots:   0 total
Time:        43.154 s
```


## **Screenshots/Recordings**


https://github.com/user-attachments/assets/30eed114-5f32-4989-9b07-65ec818c0381


## **Pre-merge author checklist**

- [x] I’ve followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/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-mobile/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.

---------

Co-authored-by: legobeat <109787230+legobeat@users.noreply.github.com>
Co-authored-by: Curtis David <Curtis.David7@gmail.com>
  • Loading branch information
3 people authored Oct 3, 2024
1 parent aef9a93 commit ddffe09
Show file tree
Hide file tree
Showing 10 changed files with 166 additions and 0 deletions.
13 changes: 13 additions & 0 deletions e2e/pages/Ramps/BuildQuoteView.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import Matchers from '../../utils/Matchers';
import { BuildQuoteSelectors } from '../../selectors/Ramps/BuildQuote.selectors';

class BuildQuoteView {
get amountToBuyLabel() {
return Matchers.getElementByText(BuildQuoteSelectors.AMOUNT_TO_BUY_LABEL);
}
get getQuotesButton() {
return Matchers.getElementByText(BuildQuoteSelectors.GET_QUOTES_BUTTON);
}
}

export default new BuildQuoteView();
15 changes: 15 additions & 0 deletions e2e/pages/Ramps/BuyGetStartedView.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import Matchers from '../../utils/Matchers';
import Gestures from '../../utils/Gestures';
import { GetStartedSelectors } from '../../selectors/Ramps/GetStarted.selectors';

class BuyGetStartedView {
get getStartedButton() {
return Matchers.getElementByText(GetStartedSelectors.GET_STARTED);
}

async tapGetStartedButton() {
await Gestures.waitAndTap(this.getStartedButton);
}
}

export default new BuyGetStartedView();
21 changes: 21 additions & 0 deletions e2e/pages/Ramps/SelectPaymentMethodView.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import Matchers from '../../utils/Matchers';
import Gestures from '../../utils/Gestures';
import { SelectPaymentMethodSelectors } from '../../selectors/Ramps/SelectPaymentMethod.selectors';

class SelectPaymentMethodView {
get continueButton() {
return Matchers.getElementByText(SelectPaymentMethodSelectors.CONTINUE_BUTTON);
}

async tapPaymentMethodOption(paymentMethod) {
const paymentMethodOption = Matchers.getElementByText(paymentMethod);
await Gestures.waitAndTap(paymentMethodOption);
}

async tapContinueButton() {
await Gestures.waitAndTap(this.continueButton);
}

}

export default new SelectPaymentMethodView();
28 changes: 28 additions & 0 deletions e2e/pages/Ramps/SelectRegionView.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import Matchers from '../../utils/Matchers';
import Gestures from '../../utils/Gestures';
import { SelectRegionSelectors } from '../../selectors/Ramps/SelectRegion.selectors';

class SelectRegionView {
get selectRegionDropdown() {
return Matchers.getElementByText(SelectRegionSelectors.SELECT_REGION);
}

get continueButton() {
return Matchers.getElementByText(SelectRegionSelectors.CONTINUE_BUTTON);
}

async tapSelectRegionDropdown() {
await Gestures.waitAndTap(this.selectRegionDropdown);
}

async tapRegionOption(region) {
const regionOption = Matchers.getElementByText(region);
await Gestures.waitAndTap(regionOption);
}

async tapContinueButton() {
await Gestures.waitAndTap(this.continueButton);
}
}

export default new SelectRegionView();
8 changes: 8 additions & 0 deletions e2e/pages/modals/WalletActionsModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ class WalletActionsModal {
return Matchers.getElementByID(WalletActionsModalSelectorsIDs.SWAP_BUTTON);
}

get buyButton() {
return Matchers.getElementByID(WalletActionsModalSelectorsIDs.BUY_BUTTON);
}

async tapSendButton() {
await Gestures.waitAndTap(this.sendButton);
}
Expand All @@ -28,6 +32,10 @@ class WalletActionsModal {
async tapSwapButton() {
await Gestures.waitAndTap(this.swapButton);
}

async tapBuyButton() {
await Gestures.waitAndTap(this.buyButton);
}
}

export default new WalletActionsModal();
6 changes: 6 additions & 0 deletions e2e/selectors/Ramps/BuildQuote.selectors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import enContent from '../../../locales/languages/en.json';

export const BuildQuoteSelectors = {
AMOUNT_TO_BUY_LABEL: enContent.fiat_on_ramp_aggregator.amount_to_buy,
GET_QUOTES_BUTTON: enContent.fiat_on_ramp_aggregator.get_quotes,
};
5 changes: 5 additions & 0 deletions e2e/selectors/Ramps/GetStarted.selectors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import enContent from '../../../locales/languages/en.json';

export const GetStartedSelectors = {
GET_STARTED: enContent.fiat_on_ramp_aggregator.onboarding.get_started,
};
5 changes: 5 additions & 0 deletions e2e/selectors/Ramps/SelectPaymentMethod.selectors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import enContent from '../../../locales/languages/en.json';

export const SelectPaymentMethodSelectors = {
CONTINUE_BUTTON: enContent.fiat_on_ramp_aggregator.payment_method.continue_to_amount,
};
6 changes: 6 additions & 0 deletions e2e/selectors/Ramps/SelectRegion.selectors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import enContent from '../../../locales/languages/en.json';

export const SelectRegionSelectors = {
SELECT_REGION: enContent.fiat_on_ramp_aggregator.region.select_region,
CONTINUE_BUTTON: enContent.fiat_on_ramp_aggregator.continue,
};
59 changes: 59 additions & 0 deletions e2e/specs/ramps/onramp.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
'use strict';
import { loginToApp } from '../../viewHelper';
import TabBarComponent from '../../pages/TabBarComponent';
import WalletActionsModal from '../../pages/modals/WalletActionsModal';
import FixtureBuilder from '../../fixtures/fixture-builder';
import {
loadFixture,
startFixtureServer,
stopFixtureServer,
} from '../../fixtures/fixture-helper';
import TestHelpers from '../../helpers';
import FixtureServer from '../../fixtures/fixture-server';
import { getFixturesServerPort } from '../../fixtures/utils';
import { SmokeAssets } from '../../tags';
import BuyGetStartedView from '../../pages/Ramps/BuyGetStartedView';
import SelectRegionView from '../../pages/Ramps/SelectRegionView';
import SelectPaymentMethodView from '../../pages/Ramps/SelectPaymentMethodView';
import BuildQuoteView from '../../pages/Ramps/BuildQuoteView';
import Assertions from '../../utils/Assertions';

const fixtureServer = new FixtureServer();

describe(SmokeAssets('Buy Crypto'), () => {
beforeAll(async () => {
await TestHelpers.reverseServerPort();
const fixture = new FixtureBuilder().build();
await startFixtureServer(fixtureServer);
await loadFixture(fixtureServer, { fixture });
await device.launchApp({
permissions: { notifications: 'YES' },
launchArgs: { fixtureServerPort: `${getFixturesServerPort()}` },
});
await loginToApp();
});

afterAll(async () => {
await stopFixtureServer(fixtureServer);
});

beforeEach(async () => {
jest.setTimeout(150000);
});

it('should select Region and Payment Method to see the Build Quote screen', async () => {
await TabBarComponent.tapWallet();
await TabBarComponent.tapActions();
await WalletActionsModal.tapBuyButton();
await BuyGetStartedView.tapGetStartedButton();
await SelectRegionView.tapSelectRegionDropdown();
await SelectRegionView.tapRegionOption('United States of America');
await SelectRegionView.tapRegionOption('California');
await SelectRegionView.tapContinueButton();
await SelectPaymentMethodView.tapPaymentMethodOption('Debit or Credit');
await SelectPaymentMethodView.tapContinueButton();
await Assertions.checkIfVisible(BuildQuoteView.amountToBuyLabel);
await Assertions.checkIfVisible(BuildQuoteView.getQuotesButton);
});

});

0 comments on commit ddffe09

Please sign in to comment.