Skip to content

Commit

Permalink
test: Enhance ramps deeplink e2e (#12821)
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 PR updates some actions in the ramps deep-linking e2e tests to
reflect changes from an earlier PR that fixed a few edge case bugs. It
also sets up an Android-only CI workflow for the ramps tests.


## **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**

- [ ] 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).
- [ ] I've completed the PR template to the best of my ability
- [ ] I’ve included tests if applicable
- [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] 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.
  • Loading branch information
cortisiko authored Dec 20, 2024
1 parent c37adbe commit 5fe6ace
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 40 deletions.
12 changes: 12 additions & 0 deletions bitrise.yml
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ stages:
- run_tag_smoke_assets_android: {}
- run_tag_smoke_confirmations_ios: {}
- run_tag_smoke_confirmations_android: {}
- run_tag_smoke_ramps_android: {}
# - run_tag_smoke_swaps_ios: {}
# - run_tag_smoke_swaps_android: {}
- run_tag_smoke_core_ios: {}
Expand All @@ -182,6 +183,7 @@ stages:
- run_tag_smoke_confirmations_android: {}
- run_tag_smoke_accounts_ios: {}
- run_tag_smoke_accounts_android: {}
- run_tag_smoke_ramps_android: {}
# - run_tag_smoke_identity_ios: {}
# - run_tag_smoke_identity_android: {}
# - run_tag_smoke_assets_ios: {}
Expand Down Expand Up @@ -699,6 +701,16 @@ workflows:
- TEST_SUITE_TAG: '.*SmokeMultiChainPermissions.*'
after_run:
- android_e2e_test
run_tag_smoke_ramps_android:
meta:
bitrise.io:
stack: linux-docker-android-22.04
machine_type_id: elite-xl
envs:
- TEST_SUITE_FOLDER: './e2e/specs/ramps/*'
- TEST_SUITE_TAG: '.*SmokeRamps.*'
after_run:
- android_e2e_test
android_e2e_build:
before_run:
- code_setup
Expand Down
20 changes: 6 additions & 14 deletions e2e/pages/Network/NetworkAddedBottomSheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,15 @@ class NetworkAddedBottomSheet {
}

get switchNetworkButton() {
return device.getPlatform() === 'android'
? Matchers.getElementByLabel(
NetworkAddedBottomSheetSelectorsIDs.SWITCH_NETWORK_BUTTON,
)
: Matchers.getElementByID(
NetworkAddedBottomSheetSelectorsIDs.SWITCH_NETWORK_BUTTON,
);
return Matchers.getElementByID(
NetworkAddedBottomSheetSelectorsIDs.SWITCH_NETWORK_BUTTON,
);
}

get closeNetworkButton() {
return device.getPlatform() === 'android'
? Matchers.getElementByLabel(
NetworkAddedBottomSheetSelectorsIDs.CLOSE_NETWORK_BUTTON,
)
: Matchers.getElementByID(
NetworkAddedBottomSheetSelectorsIDs.CLOSE_NETWORK_BUTTON,
);
return Matchers.getElementByID(
NetworkAddedBottomSheetSelectorsIDs.CLOSE_NETWORK_BUTTON,
);
}

async tapSwitchToNetwork() {
Expand Down
4 changes: 2 additions & 2 deletions e2e/resources/networks.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const PopularNetworksList = {
type: 'rpc',
chainId: toHex('43114'),
rpcUrl: 'https://api.avax.network/ext/bc/C/rpc',
nickname: 'Avalanche Mainnet C-Chain',
nickname: 'Avalanche C-Chain',
ticker: 'AVAX',
},
},
Expand Down Expand Up @@ -46,7 +46,7 @@ const PopularNetworksList = {
type: 'rpc',
chainId: toHex('10'),
rpcUrl: `https://optimism-mainnet.infura.io/v3/${infuraProjectId}`,
nickname: 'Optimism',
nickname: 'OP Mainnet',
ticker: 'ETH',
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import TestHelpers from '../../helpers';

import { loginToApp } from '../../viewHelper';
import { withFixtures } from '../../fixtures/fixture-helper';
import { SmokeCore } from '../../tags';
import { SmokeRamps } from '../../tags';
import FixtureBuilder from '../../fixtures/fixture-builder';

import SellGetStartedView from '../../pages/Ramps/SellGetStartedView';
Expand All @@ -13,8 +13,10 @@ import Assertions from '../../utils/Assertions';
import NetworkAddedBottomSheet from '../../pages/Network/NetworkAddedBottomSheet';
import NetworkApprovalBottomSheet from '../../pages/Network/NetworkApprovalBottomSheet';
import NetworkEducationModal from '../../pages/Network/NetworkEducationModal';
import NetworkListModal from '../../pages/Network/NetworkListModal';
import { PopularNetworksList } from '../../resources/networks.e2e';

describe(SmokeCore('Buy Crypto Deeplinks'), () => {
describe(SmokeRamps('Buy Crypto Deeplinks'), () => {
beforeAll(async () => {
await TestHelpers.reverseServerPort();
});
Expand All @@ -23,9 +25,8 @@ describe(SmokeCore('Buy Crypto Deeplinks'), () => {
jest.setTimeout(150000);
});

it('should deep link to onramp on Base network', async () => {
const BuyDeepLink =
'metamask://buy?chainId=8453&address=0x833589fcd6edb6e08f4c7c32d4f71b54bda02913&amount=12';
it('should deep link to onramp to unsupported network', async () => {
const BuyDeepLink = 'metamask://buy?chainId=2';

await withFixtures(
{
Expand All @@ -45,12 +46,16 @@ describe(SmokeCore('Buy Crypto Deeplinks'), () => {

await BuyGetStartedView.tapGetStartedButton();

await Assertions.checkIfVisible(NetworkApprovalBottomSheet.container);
await Assertions.checkIfTextIsDisplayed('Unsupported buy Network');
await NetworkListModal.changeNetworkTo(
PopularNetworksList.Avalanche.providerConfig.nickname,
);
await NetworkApprovalBottomSheet.tapApproveButton();
await NetworkAddedBottomSheet.tapSwitchToNetwork();
await NetworkAddedBottomSheet.tapCloseButton();
await Assertions.checkIfVisible(NetworkEducationModal.container);
await NetworkEducationModal.tapGotItButton();
await Assertions.checkIfTextIsDisplayed('USD Coin');
await Assertions.checkIfTextIsNotDisplayed('Unsupported buy Network');
await Assertions.checkIfTextIsDisplayed('Avalanche');
},
);
});
Expand Down
40 changes: 38 additions & 2 deletions e2e/specs/ramps/deeplink-to-buy-flow.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import TestHelpers from '../../helpers';

import { loginToApp } from '../../viewHelper';
import { withFixtures } from '../../fixtures/fixture-helper';
import { SmokeCore } from '../../tags';
import { SmokeRamps } from '../../tags';
import FixtureBuilder from '../../fixtures/fixture-builder';

import SellGetStartedView from '../../pages/Ramps/SellGetStartedView';
Expand All @@ -13,7 +13,9 @@ import BuildQuoteView from '../../pages/Ramps/BuildQuoteView';
import TokenSelectBottomSheet from '../../pages/Ramps/TokenSelectBottomSheet';
import Assertions from '../../utils/Assertions';

describe(SmokeCore('Buy Crypto Deeplinks'), () => {
import { PopularNetworksList } from '../../resources/networks.e2e';
import NetworkEducationModal from '../../pages/Network/NetworkEducationModal';
describe(SmokeRamps('Buy Crypto Deeplinks'), () => {
beforeAll(async () => {
await TestHelpers.reverseServerPort();
});
Expand Down Expand Up @@ -52,4 +54,38 @@ describe(SmokeCore('Buy Crypto Deeplinks'), () => {
},
);
});
it('should deep link to onramp on Base network', async () => {
const BuyDeepLink =
'metamask://buy?chainId=8453&address=0x833589fcd6edb6e08f4c7c32d4f71b54bda02913&amount=12';

await withFixtures(
{
fixture: new FixtureBuilder()
.withPopularNetworks()
.withRampsSelectedRegion()
.build(),
restartDevice: true,
},
async () => {
await loginToApp();
await device.sendToHome();
await device.launchApp({
url: BuyDeepLink,
});

await Assertions.checkIfVisible(
await SellGetStartedView.getStartedButton,
);

await BuyGetStartedView.tapGetStartedButton();

await Assertions.checkIfVisible(NetworkEducationModal.container);
await NetworkEducationModal.tapGotItButton();
await Assertions.checkIfTextIsDisplayed('USD Coin');
await Assertions.checkIfTextIsDisplayed(
PopularNetworksList.Base.providerConfig.nickname,
);
},
);
});
});
29 changes: 19 additions & 10 deletions e2e/specs/ramps/deeplink-to-sell-flow.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@ import { withFixtures } from '../../fixtures/fixture-helper';

import TestHelpers from '../../helpers';
import SellGetStartedView from '../../pages/Ramps/SellGetStartedView';
import { SmokeCore } from '../../tags';
import { SmokeRamps } from '../../tags';

import BuildQuoteView from '../../pages/Ramps/BuildQuoteView';
import Assertions from '../../utils/Assertions';
import NetworkApprovalBottomSheet from '../../pages/Network/NetworkApprovalBottomSheet';
import NetworkAddedBottomSheet from '../../pages/Network/NetworkAddedBottomSheet';
import NetworkEducationModal from '../../pages/Network/NetworkEducationModal';
import NetworkListModal from '../../pages/Network/NetworkListModal';
import { PopularNetworksList } from '../../resources/networks.e2e';

describe(SmokeCore('Sell Crypto Deeplinks'), () => {
describe(SmokeRamps('Sell Crypto Deeplinks'), () => {
beforeAll(async () => {
await TestHelpers.reverseServerPort();
});
Expand Down Expand Up @@ -59,8 +61,8 @@ describe(SmokeCore('Sell Crypto Deeplinks'), () => {
},
);
});
it('Should deep link to an unsupported network in the off-ramp flow', async () => {
const unsupportedNetworkSellDeepLink = 'metamask://sell?chainId=56';
it('should deep link to offramp with Base but switch network to OP Mainnet', async () => {
const SellDeepLink = 'metamask://sell?chainId=8453';

await withFixtures(
{
Expand All @@ -69,20 +71,27 @@ describe(SmokeCore('Sell Crypto Deeplinks'), () => {
},
async () => {
await loginToApp();

await device.openURL({
url: unsupportedNetworkSellDeepLink,
await device.sendToHome();
await device.launchApp({
url: SellDeepLink,
});
await Assertions.checkIfVisible(
await SellGetStartedView.getStartedButton,
);

await SellGetStartedView.tapGetStartedButton();

await Assertions.checkIfVisible(NetworkApprovalBottomSheet.container);
await NetworkApprovalBottomSheet.tapCancelButton();
await NetworkListModal.changeNetworkTo(
PopularNetworksList.Optimism.providerConfig.nickname,
);
await NetworkApprovalBottomSheet.tapApproveButton();
await NetworkAddedBottomSheet.tapSwitchToNetwork();
await NetworkAddedBottomSheet.tapCloseButton();
await Assertions.checkIfVisible(NetworkEducationModal.container);
await NetworkEducationModal.tapGotItButton();
await Assertions.checkIfTextIsDisplayed('Ethereum');
await Assertions.checkIfTextIsDisplayed(
PopularNetworksList.Optimism.providerConfig.nickname,
);
},
);
});
Expand Down
4 changes: 2 additions & 2 deletions e2e/specs/ramps/offramp.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { CustomNetworks } from '../../resources/networks.e2e';
import TestHelpers from '../../helpers';
import FixtureServer from '../../fixtures/fixture-server';
import { getFixturesServerPort } from '../../fixtures/utils';
import { SmokeCore } from '../../tags';
import { SmokeRamps } from '../../tags';
import Assertions from '../../utils/Assertions';
import SellGetStartedView from '../../pages/Ramps/SellGetStartedView';
import SelectRegionView from '../../pages/Ramps/SelectRegionView';
Expand All @@ -34,7 +34,7 @@ const PaymentMethods = {
ACH_BANK_TRANSFER: 'ACH Bank Transfer',
};

describe(SmokeCore('Off-Ramp'), () => {
describe(SmokeRamps('Off-Ramp'), () => {
beforeAll(async () => {
await TestHelpers.reverseServerPort();
const fixture = new FixtureBuilder()
Expand Down
4 changes: 2 additions & 2 deletions e2e/specs/ramps/onramp.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
import TestHelpers from '../../helpers';
import FixtureServer from '../../fixtures/fixture-server';
import { getFixturesServerPort } from '../../fixtures/utils';
import { SmokeCore } from '../../tags';
import { SmokeRamps } from '../../tags';
import BuyGetStartedView from '../../pages/Ramps/BuyGetStartedView';
import SelectRegionView from '../../pages/Ramps/SelectRegionView';
import SelectPaymentMethodView from '../../pages/Ramps/SelectPaymentMethodView';
Expand All @@ -20,7 +20,7 @@ import Assertions from '../../utils/Assertions';

const fixtureServer = new FixtureServer();

describe(SmokeCore('Buy Crypto'), () => {
describe(SmokeRamps('Buy Crypto'), () => {
beforeAll(async () => {
await TestHelpers.reverseServerPort();
const fixture = new FixtureBuilder().build();
Expand Down
3 changes: 3 additions & 0 deletions e2e/tags.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const tags = {
smokeAssets: 'smokeAssets:',
smokeIdentity: 'smokeIdentity:',
smokeMultiChainPermissions: 'SmokeMultiChainPermissions:',
smokeRamps: 'SmokeRamps:',
};

const Regression = (testName) => `${tags.regression} ${testName}`;
Expand All @@ -18,6 +19,7 @@ const SmokeConfirmations = (testName) =>
const SmokeSwaps = (testName) => `${tags.SmokeSwaps} ${testName}`;
const SmokeAssets = (testName) => `${tags.smokeAssets} ${testName}`;
const SmokeIdentity = (testName) => `${tags.smokeIdentity} ${testName}`;
const SmokeRamps = (testName) => `${tags.smokeRamps} ${testName}`;

const SmokeMultiChainPermissions = (testName) =>
`${tags.smokeMultiChainPermissions} ${testName}`;
Expand All @@ -30,4 +32,5 @@ export {
SmokeAssets,
SmokeIdentity,
SmokeMultiChainPermissions,
SmokeRamps,
};

0 comments on commit 5fe6ace

Please sign in to comment.