diff --git a/e2e/pages/EnableDeviceNotificationsAlert.js b/e2e/pages/EnableDeviceNotificationsAlert.js index 3c9eebe0c55..a5e6e512451 100644 --- a/e2e/pages/EnableDeviceNotificationsAlert.js +++ b/e2e/pages/EnableDeviceNotificationsAlert.js @@ -1,4 +1,5 @@ -import TestHelpers from '../helpers'; +import Gestures from '../utils/Gestures'; +import Matchers from '../utils/Matchers'; import { ENABLE_DEVICE_NOTIFICATIONS_CONTAINER_ID, @@ -6,22 +7,30 @@ import { ENABLE_DEVICE_NOTIFICATIONS_YES_BUTTON_ID } from '../../wdio/screen-objects/testIDs/Screens/EnableDeviceNotificationsChecksAlert.testIds'; -export default class EnableDeviceNotificationsAlert { - static async tapNoThanks() { - await TestHelpers.waitAndTapByLabel( - ENABLE_DEVICE_NOTIFICATIONS_NO_THANKS_BUTTON_ID - ); +class EnableDeviceNotificationsAlert { + get stepOneContainer() { + return Matchers.getSystemElementByText(ENABLE_DEVICE_NOTIFICATIONS_CONTAINER_ID); } - static async tapYes() { - await TestHelpers.waitAndTapByLabel( + get getEnableDeviceNotificationsButton() { + return Matchers.getSystemElementByText( ENABLE_DEVICE_NOTIFICATIONS_YES_BUTTON_ID, ); } - static async isVisible() { - await TestHelpers.checkIfElementWithTextIsVisible( - ENABLE_DEVICE_NOTIFICATIONS_CONTAINER_ID, + get getNotEnableDeviceNotificationsButton() { + return Matchers.getSystemElementByText( + ENABLE_DEVICE_NOTIFICATIONS_NO_THANKS_BUTTON_ID, ); } + + async tapOnEnableDeviceNotificationsButton() { + await Gestures.waitAndTap(this.getEnableDeviceNotificationsButton); + } + + async tapOnNotEnableDeviceNotificationsButton() { + await Gestures.waitAndTap(this.getNotEnableDeviceNotificationsButton); + } } + +export default new EnableDeviceNotificationsAlert(); diff --git a/e2e/viewHelper.js b/e2e/viewHelper.js index ebcf468596a..ad7438dadc9 100644 --- a/e2e/viewHelper.js +++ b/e2e/viewHelper.js @@ -1,6 +1,7 @@ 'use strict'; import EnableAutomaticSecurityChecksView from './pages/EnableAutomaticSecurityChecksView'; +import EnableDeviceNotificationsAlert from './pages/EnableDeviceNotificationsAlert'; import ImportWalletView from './pages/Onboarding/ImportWalletView'; import MetaMetricsOptIn from './pages/Onboarding/MetaMetricsOptInView'; import NetworkEducationModal from './pages/modals/NetworkEducationModal'; @@ -68,6 +69,21 @@ have to have all these workarounds in the tests } }; +export const skipNotificationsDeviceSettings = async () => { + + await TestHelpers.delay(1000); + + try { + await Assertions.checkIfVisible(EnableDeviceNotificationsAlert.stepOneContainer); + await EnableDeviceNotificationsAlert.tapOnNotEnableDeviceNotificationsButton(); + await Assertions.checkIfNotVisible(EnableDeviceNotificationsAlert.stepOneContainer); + } catch { + /* eslint-disable no-console */ + + console.log('The notification device alert modal is not visible'); + } +}; + export const importWalletWithRecoveryPhrase = async () => { // tap on import seed phrase button await Assertions.checkIfVisible(OnboardingCarouselView.container); @@ -83,14 +99,13 @@ export const importWalletWithRecoveryPhrase = async () => { await ImportWalletView.enterPassword(validAccount.password); await ImportWalletView.reEnterPassword(validAccount.password); - - //'Should dismiss Enable device Notifications checks alert' await TestHelpers.delay(3500); await OnboardingSuccessView.tapDone(); + //'Should dismiss Enable device Notifications checks alert' + await this.skipNotificationsDeviceSettings(); // Should dismiss Automatic Security checks screen await EnableAutomaticSecurityChecksView.isVisible(); await EnableAutomaticSecurityChecksView.tapNoThanks(); - // should dismiss the onboarding wizard // dealing with flakiness on bitrise. await this.closeOnboardingModals(); @@ -122,9 +137,10 @@ export const CreateNewWallet = async () => { await device.enableSynchronization(); await Assertions.checkIfVisible(WalletView.container); - //'Should dismiss Enable device Notifications checks alert' await TestHelpers.delay(3500); await OnboardingSuccessView.tapDone(); + //'Should dismiss Enable device Notifications checks alert' + await this.skipNotificationsDeviceSettings(); //'Should dismiss Automatic Security checks screen' await EnableAutomaticSecurityChecksView.isVisible(); await EnableAutomaticSecurityChecksView.tapNoThanks();