-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Add ramps URL scheme deeplinking e2e (#12747)
<!-- 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 purpose of this PR is to add e2e coverage for the URL schema deeplinks in the ramps flow. The goal here is to ensure that we properly test the URL scheme deep linking in these flows. ### Sell Deep link ``` Scenario 1 Given I open a sell ETH deeplink for mainnet Then the app should launch with the ramps build quotes page And the token I want to sell is displayed correctly And the amount i want to send is displayed correctly Scenario 2 Given I open a sell deeplink on an unsupported network Then the app should launch with the ramps build quotes page And I am prompted to add the network When I add the network Then the Quotes page should be displayed ``` ### Buy deeplink Flow ``` Scenario 3 Given i deeplink to the buy eth flow on mainnet Then the app should launch with the ramps build quotes page And the token I want to sell is displayed correctly And the amount i want to send is displayed correctly Scenario 4 Given i deeplink to the buy eth flow on a popular network Then the app should launch with the ramps build quotes page And the token I want to sell is displayed correctly And the amount i want to send is displayed correctly ``` ## **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
Showing
8 changed files
with
269 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import Matchers from '../../utils/Matchers'; | ||
import Gestures from '../../utils/Gestures'; | ||
|
||
class TokenSelectBottomSheet { | ||
async tapTokenByName(token) { | ||
const tokenName = await Matchers.getElementByText(token); | ||
|
||
await Gestures.waitAndTap(tokenName); | ||
} | ||
} | ||
|
||
export default new TokenSelectBottomSheet(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
e2e/specs/ramps/deeplink-to-buy-flow-with-unsupported-network.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
'use strict'; | ||
import TestHelpers from '../../helpers'; | ||
|
||
import { loginToApp } from '../../viewHelper'; | ||
import { withFixtures } from '../../fixtures/fixture-helper'; | ||
import { SmokeCore } from '../../tags'; | ||
import FixtureBuilder from '../../fixtures/fixture-builder'; | ||
|
||
import SellGetStartedView from '../../pages/Ramps/SellGetStartedView'; | ||
import BuyGetStartedView from '../../pages/Ramps/BuyGetStartedView'; | ||
|
||
import Assertions from '../../utils/Assertions'; | ||
import NetworkAddedBottomSheet from '../../pages/Network/NetworkAddedBottomSheet'; | ||
import NetworkApprovalBottomSheet from '../../pages/Network/NetworkApprovalBottomSheet'; | ||
import NetworkEducationModal from '../../pages/Network/NetworkEducationModal'; | ||
|
||
describe(SmokeCore('Buy Crypto Deeplinks'), () => { | ||
beforeAll(async () => { | ||
await TestHelpers.reverseServerPort(); | ||
}); | ||
|
||
beforeEach(async () => { | ||
jest.setTimeout(150000); | ||
}); | ||
|
||
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().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(NetworkApprovalBottomSheet.container); | ||
await NetworkApprovalBottomSheet.tapApproveButton(); | ||
await NetworkAddedBottomSheet.tapSwitchToNetwork(); | ||
await Assertions.checkIfVisible(NetworkEducationModal.container); | ||
await NetworkEducationModal.tapGotItButton(); | ||
await Assertions.checkIfTextIsDisplayed('USD Coin'); | ||
}, | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
'use strict'; | ||
import TestHelpers from '../../helpers'; | ||
|
||
import { loginToApp } from '../../viewHelper'; | ||
import { withFixtures } from '../../fixtures/fixture-helper'; | ||
import { SmokeCore } from '../../tags'; | ||
import FixtureBuilder from '../../fixtures/fixture-builder'; | ||
|
||
import SellGetStartedView from '../../pages/Ramps/SellGetStartedView'; | ||
import BuyGetStartedView from '../../pages/Ramps/BuyGetStartedView'; | ||
|
||
import BuildQuoteView from '../../pages/Ramps/BuildQuoteView'; | ||
import TokenSelectBottomSheet from '../../pages/Ramps/TokenSelectBottomSheet'; | ||
import Assertions from '../../utils/Assertions'; | ||
|
||
describe(SmokeCore('Buy Crypto Deeplinks'), () => { | ||
beforeAll(async () => { | ||
await TestHelpers.reverseServerPort(); | ||
}); | ||
|
||
beforeEach(async () => { | ||
jest.setTimeout(150000); | ||
}); | ||
it('should deep link to onramp ETH', async () => { | ||
const buyLink = 'metamask://buy?chainId=1&amount=275'; | ||
|
||
await withFixtures( | ||
{ | ||
fixture: new FixtureBuilder() | ||
.withRampsSelectedPaymentMethod() | ||
.withRampsSelectedRegion() | ||
.build(), | ||
restartDevice: true, | ||
}, | ||
async () => { | ||
await loginToApp(); | ||
await device.sendToHome(); | ||
await device.launchApp({ | ||
url: buyLink, | ||
}); | ||
await Assertions.checkIfVisible( | ||
await SellGetStartedView.getStartedButton, | ||
); | ||
|
||
await BuyGetStartedView.tapGetStartedButton(); | ||
await Assertions.checkIfVisible(BuildQuoteView.getQuotesButton); | ||
await BuildQuoteView.tapDefaultToken('Ethereum'); | ||
|
||
await TokenSelectBottomSheet.tapTokenByName('DAI'); | ||
await Assertions.checkIfTextIsDisplayed('Dai Stablecoin'); | ||
await Assertions.checkIfTextIsDisplayed('$275'); | ||
}, | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
'use strict'; | ||
import { loginToApp } from '../../viewHelper'; | ||
|
||
import FixtureBuilder from '../../fixtures/fixture-builder'; | ||
import { withFixtures } from '../../fixtures/fixture-helper'; | ||
|
||
import TestHelpers from '../../helpers'; | ||
import SellGetStartedView from '../../pages/Ramps/SellGetStartedView'; | ||
import { SmokeCore } 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'; | ||
|
||
describe(SmokeCore('Sell Crypto Deeplinks'), () => { | ||
beforeAll(async () => { | ||
await TestHelpers.reverseServerPort(); | ||
}); | ||
|
||
beforeEach(async () => { | ||
jest.setTimeout(150000); | ||
}); | ||
it('should deep link to offramp ETH', async () => { | ||
const sellDeepLinkURL = | ||
'metamask://sell?chainId=1&address=0x0000000000000000000000000000000000000000&amount=50'; | ||
const franceRegion = { | ||
currencies: ['/currencies/fiat/eur'], | ||
emoji: '🇫🇷', | ||
id: '/regions/fr', | ||
name: 'France', | ||
support: { buy: true, sell: true, recurringBuy: true }, | ||
unsupported: false, | ||
recommended: false, | ||
detected: false, | ||
}; | ||
await withFixtures( | ||
{ | ||
fixture: new FixtureBuilder() | ||
.withRampsSelectedRegion(franceRegion) | ||
.build(), | ||
restartDevice: true, | ||
}, | ||
async () => { | ||
await loginToApp(); | ||
|
||
await device.openURL({ | ||
url: sellDeepLinkURL, | ||
}); | ||
await Assertions.checkIfVisible( | ||
await SellGetStartedView.getStartedButton, | ||
); | ||
|
||
await SellGetStartedView.tapGetStartedButton(); | ||
await Assertions.checkIfVisible(BuildQuoteView.getQuotesButton); | ||
|
||
await Assertions.checkIfTextIsDisplayed('50 ETH'); | ||
}, | ||
); | ||
}); | ||
it('Should deep link to an unsupported network in the off-ramp flow', async () => { | ||
const unsupportedNetworkSellDeepLink = 'metamask://sell?chainId=56'; | ||
|
||
await withFixtures( | ||
{ | ||
fixture: new FixtureBuilder().withRampsSelectedRegion().build(), | ||
restartDevice: true, | ||
}, | ||
async () => { | ||
await loginToApp(); | ||
|
||
await device.openURL({ | ||
url: unsupportedNetworkSellDeepLink, | ||
}); | ||
await Assertions.checkIfVisible( | ||
await SellGetStartedView.getStartedButton, | ||
); | ||
|
||
await SellGetStartedView.tapGetStartedButton(); | ||
|
||
await NetworkApprovalBottomSheet.tapApproveButton(); | ||
await NetworkAddedBottomSheet.tapSwitchToNetwork(); | ||
await Assertions.checkIfVisible(NetworkEducationModal.container); | ||
await NetworkEducationModal.tapGotItButton(); | ||
}, | ||
); | ||
}); | ||
}); |