Skip to content

Commit

Permalink
refactor e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathansoufer committed Sep 27, 2024
1 parent c3642ca commit 63aab3f
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 15 deletions.
31 changes: 20 additions & 11 deletions e2e/pages/EnableDeviceNotificationsAlert.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,36 @@
import TestHelpers from '../helpers';
import Gestures from '../utils/Gestures';
import Matchers from '../utils/Matchers';

import {
ENABLE_DEVICE_NOTIFICATIONS_CONTAINER_ID,
ENABLE_DEVICE_NOTIFICATIONS_NO_THANKS_BUTTON_ID,
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();
24 changes: 20 additions & 4 deletions e2e/viewHelper.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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);
Expand All @@ -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();
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 63aab3f

Please sign in to comment.