diff --git a/e2e/pages/Ramps/BuildQuoteView.js b/e2e/pages/Ramps/BuildQuoteView.js new file mode 100644 index 00000000000..dbdc2e524ed --- /dev/null +++ b/e2e/pages/Ramps/BuildQuoteView.js @@ -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(); diff --git a/e2e/pages/Ramps/BuyGetStartedView.js b/e2e/pages/Ramps/BuyGetStartedView.js new file mode 100644 index 00000000000..9a3b7c202b6 --- /dev/null +++ b/e2e/pages/Ramps/BuyGetStartedView.js @@ -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(); diff --git a/e2e/pages/Ramps/SelectPaymentMethodView.js b/e2e/pages/Ramps/SelectPaymentMethodView.js new file mode 100644 index 00000000000..4483c4da706 --- /dev/null +++ b/e2e/pages/Ramps/SelectPaymentMethodView.js @@ -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(); diff --git a/e2e/pages/Ramps/SelectRegionView.js b/e2e/pages/Ramps/SelectRegionView.js new file mode 100644 index 00000000000..0f697581802 --- /dev/null +++ b/e2e/pages/Ramps/SelectRegionView.js @@ -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(); diff --git a/e2e/pages/modals/WalletActionsModal.js b/e2e/pages/modals/WalletActionsModal.js index 1c174a01ce3..1b8ac8b3fc6 100644 --- a/e2e/pages/modals/WalletActionsModal.js +++ b/e2e/pages/modals/WalletActionsModal.js @@ -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); } @@ -28,6 +32,10 @@ class WalletActionsModal { async tapSwapButton() { await Gestures.waitAndTap(this.swapButton); } + + async tapBuyButton() { + await Gestures.waitAndTap(this.buyButton); + } } export default new WalletActionsModal(); diff --git a/e2e/selectors/Ramps/BuildQuote.selectors.js b/e2e/selectors/Ramps/BuildQuote.selectors.js new file mode 100644 index 00000000000..6f31cad907d --- /dev/null +++ b/e2e/selectors/Ramps/BuildQuote.selectors.js @@ -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, +}; diff --git a/e2e/selectors/Ramps/GetStarted.selectors.js b/e2e/selectors/Ramps/GetStarted.selectors.js new file mode 100644 index 00000000000..6249b672af5 --- /dev/null +++ b/e2e/selectors/Ramps/GetStarted.selectors.js @@ -0,0 +1,5 @@ +import enContent from '../../../locales/languages/en.json'; + +export const GetStartedSelectors = { + GET_STARTED: enContent.fiat_on_ramp_aggregator.onboarding.get_started, +}; diff --git a/e2e/selectors/Ramps/SelectPaymentMethod.selectors.js b/e2e/selectors/Ramps/SelectPaymentMethod.selectors.js new file mode 100644 index 00000000000..d7d028696e7 --- /dev/null +++ b/e2e/selectors/Ramps/SelectPaymentMethod.selectors.js @@ -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, +}; diff --git a/e2e/selectors/Ramps/SelectRegion.selectors.js b/e2e/selectors/Ramps/SelectRegion.selectors.js new file mode 100644 index 00000000000..c402d742608 --- /dev/null +++ b/e2e/selectors/Ramps/SelectRegion.selectors.js @@ -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, +}; diff --git a/e2e/specs/ramps/onramp.spec.js b/e2e/specs/ramps/onramp.spec.js new file mode 100644 index 00000000000..90f170d2ef6 --- /dev/null +++ b/e2e/specs/ramps/onramp.spec.js @@ -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); + }); + +});