Skip to content

Commit

Permalink
chore: cherry-pick #10055 (#10072)
Browse files Browse the repository at this point in the history
This PR cherry-picks #10055

Co-authored-by: SamuelSalas <samuel.salas.reyes@gmail.com>
  • Loading branch information
github-actions[bot] and SamuelSalas authored Jun 21, 2024
1 parent 17c7246 commit 87bc107
Show file tree
Hide file tree
Showing 13 changed files with 92 additions and 120 deletions.
4 changes: 2 additions & 2 deletions app/components/UI/Notification/BaseNotification/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import IonicIcon from 'react-native-vector-icons/Ionicons';
import AntIcon from 'react-native-vector-icons/AntDesign';
import Text from '../../../Base/Text';
import { useTheme } from '../../../../util/theme';
import { CommonSelectorsIDs } from '../../../../../e2e/selectors/Common.selectors';
import { ToastSelectorsIDs } from '../../../../../e2e/selectors/Modals/ToastModal.selectors';

const createStyles = (colors) =>
StyleSheet.create({
Expand Down Expand Up @@ -185,7 +185,7 @@ const BaseNotification = ({
<View style={styles.flashLabel}>
<Text
style={styles.flashTitle}
testID={CommonSelectorsIDs.TOAST_NOTIFICATION_TITLE}
testID={ToastSelectorsIDs.NOTIFICATION_TITLE}
>
{!title ? getTitle(status, data) : title}
</Text>
Expand Down
2 changes: 1 addition & 1 deletion e2e/pages/AccountListView.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default class AccountListView {
static async isAccount2VisibleAtIndex(index) {
await expect(
element(by.id(CellModalSelectorsIDs.BASE_TITLE)).atIndex(index),
).toHaveText('Account 2');
).not.toHaveText('Account 1');
}

static async accountNameNotVisible() {
Expand Down
13 changes: 1 addition & 12 deletions e2e/pages/CommonView.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import Matchers from '../utils/Matchers';
import Gestures from '../utils/Gestures';
import {
CommonSelectorsIDs,
CommonSelectorsText,
} from '../selectors/Common.selectors';
import { CommonSelectorsIDs } from '../selectors/Common.selectors';

class CommonView {
get okAlertByText() {
Expand All @@ -14,18 +11,10 @@ class CommonView {
return Matchers.getElementByID(CommonSelectorsIDs.BACK_ARROW_BUTTON);
}

get toast() {
return Matchers.getElementByID(CommonSelectorsIDs.TOAST_NOTIFICATION_TITLE);
}

get errorMessage() {
return Matchers.getElementByID(CommonSelectorsIDs.ERROR_MESSAGE);
}

get disconnectedAccountsText() {
return Matchers.getElementByText(CommonSelectorsText.TOAST_REVOKE_ACCOUNTS);
}

async tapBackButton() {
await Gestures.waitAndTap(this.backButton);
}
Expand Down
26 changes: 26 additions & 0 deletions e2e/pages/modals/ToastModal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import {
ToastSelectorsIDs,
ToastSelectorsText,
} from '../../selectors/Modals/ToastModal.selectors';
import Gestures from '../../utils/Gestures';
import Matchers from '../../utils/Matchers';

class ToastModal {
get container() {
return Matchers.getElementByID(ToastSelectorsIDs.CONTAINER);
}

get notificationTitle() {
return Matchers.getElementByID(ToastSelectorsIDs.NOTIFICATION_TITLE);
}

get toastCloseButton() {
return Matchers.getElementByText(ToastSelectorsText.CLOSE_BUTTON);
}

async tapToastCloseButton() {
await Gestures.waitAndTap(this.toastCloseButton);
}
}

export default new ToastModal();
3 changes: 0 additions & 3 deletions e2e/selectors/Common.selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ export const CommonSelectorsIDs = {
BACK_ARROW_BUTTON: 'back-arrow-button',
CONNECT_BUTTON: 'connect-button',
CANCEL_BUTTON: 'cancel-button',
TOAST_NOTIFICATION_TITLE: 'notification-title',
NOTIFICATION_CONFIRM_BUTTON: 'confirm-notification-button',
EDIT_CONTACT_BACK_BUTTON: 'edit-contact-back-button',
CONFIRM_TXN_EDIT_BUTTON: 'confirm-txn-edit-button',
Expand All @@ -20,7 +19,5 @@ export const CommonSelectorsIDs = {
export const CommonSelectorsText = {
OK_ALERT_BUTTON: enContent.template_confirmation.ok,
CANCEL_BUTTON: enContent.template_confirmation.cancel,
TOAST_REVOKE_ACCOUNTS: enContent.toast.revoked_all,
TOAST_CONNECTED_ACCOUNTS: enContent.toast.connected_and_active,
YES_ALERT_BUTTON: enContent.drawer.lock_ok,
};
10 changes: 10 additions & 0 deletions e2e/selectors/Modals/ToastModal.selectors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import enContent from '../../../locales/languages/en.json';

export const ToastSelectorsText = {
CLOSE_BUTTON: enContent.privacy_policy.toast_action_button,
};

export const ToastSelectorsIDs = {
CONTAINER: 'toast',
NOTIFICATION_TITLE: 'notification-title',
};
4 changes: 2 additions & 2 deletions e2e/specs/browser/browser-tests.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ describe(SmokeCore('Browser Tests'), () => {
await Browser.tapOptionsButton();
await Browser.tapAddToFavoritesButton();

await Assertions.checkIfVisible(await AddBookmarkView.container);
await Assertions.checkIfVisible(AddBookmarkView.container);

await AddBookmarkView.tapAddBookmarksButton();
await Assertions.checkIfNotVisible(await AddBookmarkView.container);
await Assertions.checkIfNotVisible(AddBookmarkView.container);
});

it('should tap on the test dapp in favorites on the home page', async () => {
Expand Down
8 changes: 3 additions & 5 deletions e2e/specs/onboarding/onboarding-wizard-opt-in.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ describe(
// dealing with flakiness on bitrise.
await TestHelpers.delay(2500);
try {
await WhatsNewModal.isVisible();
await Assertions.checkIfVisible(WhatsNewModal.container);
await WhatsNewModal.tapCloseButton();
} catch {
/* eslint-disable no-console */
Expand All @@ -95,15 +95,13 @@ describe(
// dealing with flakiness on bitrise.
await TestHelpers.delay(1000);
try {
await Assertions.checkIfVisible(
await ExperienceEnhancerModal.container,
);
await Assertions.checkIfVisible(ExperienceEnhancerModal.container);
await ExperienceEnhancerModal.tapIagree();
} catch {
console.log('The marketing consent sheet is not visible');
}
try {
await WhatsNewModal.isVisible();
await Assertions.checkIfVisible(WhatsNewModal.container);
await WhatsNewModal.tapCloseButton();
} catch {
/* eslint-disable no-console */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import MetaMetricsOptIn from '../../pages/Onboarding/MetaMetricsOptInView';
import ProtectYourWalletModal from '../../pages/modals/ProtectYourWalletModal';
import OnboardingSuccessView from '../../pages/Onboarding/OnboardingSuccessView';
import Assertions from '../../utils/Assertions';
import CommonView from '../../pages/CommonView';
import ToastModal from '../../pages/modals/ToastModal';

const PASSWORD = '12345678';

Expand Down Expand Up @@ -71,9 +71,9 @@ describe(
await TestHelpers.delay(2000);
await Assertions.checkIfVisible(OnboardingView.container);
if (device.getPlatform() === 'ios') {
await Assertions.checkIfVisible(await CommonView.toast);
await Assertions.checkIfVisible(ToastModal.notificationTitle);
}
await Assertions.checkIfNotVisible(await CommonView.toast);
await Assertions.checkIfNotVisible(ToastModal.notificationTitle);
await OnboardingView.tapCreateWallet();

// Create new wallet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import FixtureBuilder from '../../fixtures/fixture-builder';
import { withFixtures } from '../../fixtures/fixture-helper';
import { loginToApp } from '../../viewHelper';
import Assertions from '../../utils/Assertions';
import CommonView from '../../pages/CommonView';
import ToastModal from '../../pages/modals/ToastModal';

describe(SmokeCore('Revoke Single Account after connecting to a dapp'), () => {
beforeAll(async () => {
Expand Down Expand Up @@ -37,7 +37,7 @@ describe(SmokeCore('Revoke Single Account after connecting to a dapp'), () => {
await TestHelpers.delay(5500); // this is because the toast is delayed.

await ConnectedAccountsModal.tapDisconnectAllButton();
await Assertions.checkIfNotVisible(await CommonView.toast);
await Assertions.checkIfNotVisible(ToastModal.notificationTitle);

await Browser.tapNetworkAvatarButtonOnBrowser();
await Assertions.checkIfNotVisible(ConnectedAccountsModal.title);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@ import TestHelpers from '../../helpers';
import Browser from '../../pages/Browser/BrowserView';
import AccountListView from '../../pages/AccountListView';
import TabBarComponent from '../../pages/TabBarComponent';
import ToastModal from '../../pages/modals/ToastModal';
import ConnectedAccountsModal from '../../pages/modals/ConnectedAccountsModal';

import CommonView from '../../pages/CommonView';

import { loginToApp } from '../../viewHelper';
import NetworkListModal from '../../pages/modals/NetworkListModal';
import { loginToApp } from '../../viewHelper';
import FixtureBuilder from '../../fixtures/fixture-builder';
import { withFixtures } from '../../fixtures/fixture-helper';
import Assertions from '../../utils/Assertions';
Expand Down Expand Up @@ -41,7 +39,7 @@ describe('Connecting to multiple dapps and revoking permission on one but stayin
await Assertions.checkIfVisible(ConnectedAccountsModal.title);
await TestHelpers.delay(2000);

await Assertions.checkIfNotVisible(CommonView.toast);
await Assertions.checkIfNotVisible(ToastModal.notificationTitle);
await ConnectedAccountsModal.tapConnectMoreAccountsButton();
await AccountListView.tapAddAccountButton();
await AccountListView.tapCreateAccountButton();
Expand All @@ -54,7 +52,7 @@ describe('Connecting to multiple dapps and revoking permission on one but stayin
await ConnectedAccountsModal.tapPermissionsButton();
await TestHelpers.delay(1500);
await ConnectedAccountsModal.tapDisconnectAllButton();
await Assertions.checkIfNotVisible(await CommonView.toast);
await Assertions.checkIfNotVisible(ToastModal.notificationTitle);

await Browser.tapNetworkAvatarButtonOnBrowser();
await Assertions.checkIfNotVisible(ConnectedAccountsModal.title);
Expand Down
21 changes: 14 additions & 7 deletions e2e/specs/swaps/swap-action-regression.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,20 @@ describe(Regression('Multiple Swaps from Actions'), () => {
sourceTokenSymbol,
destTokenSymbol,
);
await Assertions.checkIfVisible(DetailsModal.title);
await Assertions.checkIfElementToHaveText(
DetailsModal.title,
DetailsModal.generateExpectedTitle(sourceTokenSymbol, destTokenSymbol),
);
await Assertions.checkIfVisible(DetailsModal.statusConfirmed);
await DetailsModal.tapOnCloseIcon();

if (device.getPlatform() === 'android') {
await Assertions.checkIfVisible(DetailsModal.title);
await Assertions.checkIfElementToHaveText(
DetailsModal.title,
DetailsModal.generateExpectedTitle(
sourceTokenSymbol,
destTokenSymbol,
),
);
await Assertions.checkIfVisible(DetailsModal.statusConfirmed);
await DetailsModal.tapOnCloseIcon();
await Assertions.checkIfNotVisible(DetailsModal.title);
}
},
);
});
Loading

0 comments on commit 87bc107

Please sign in to comment.