Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add e2e to clear privacy data #12715

Merged
merged 4 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ import Button, {
ButtonWidthTypes,
} from '../../../../../../component-library/components/Buttons/Button';
import SDKConnect from '../../../../../../../app/core/SDKConnect/SDKConnect';
import { SecurityPrivacyViewSelectorsIDs } from '../../../../../../../e2e/selectors/Settings/SecurityAndPrivacy/SecurityPrivacyView.selectors';
import { ClearPrivacyModalSelectorsIDs } from '../../../../../../../e2e/selectors/Settings/SecurityAndPrivacy/ClearPrivacyModal.selectors';


const ClearPrivacy = () => {
const { styles } = useStyles(styleSheet, {});
Expand All @@ -40,7 +43,7 @@ const ClearPrivacy = () => {
onRequestClose={() => setModalVisible(false)}
onConfirmPress={clearApprovals}
>
<View style={styles.modalView}>
<View style={styles.modalView} testID={ClearPrivacyModalSelectorsIDs.CONTAINER}>
cortisiko marked this conversation as resolved.
Show resolved Hide resolved
<Text variant={TextVariant.HeadingMD} style={styles.modalTitle}>
{strings('app_settings.clear_approvals_modal_title')}
</Text>
Expand All @@ -66,6 +69,7 @@ const ClearPrivacy = () => {
<View style={styles.accessory}>
<Button
variant={ButtonVariants.Secondary}
testID={SecurityPrivacyViewSelectorsIDs.CLEAR_PRIVACY_DATA_BUTTON}
cortisiko marked this conversation as resolved.
Show resolved Hide resolved
size={ButtonSize.Lg}
width={ButtonWidthTypes.Full}
label={strings('app_settings.clear_privacy_title')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1029,6 +1029,7 @@ exports[`SecuritySettings should render correctly 1`] = `
"paddingHorizontal": 16,
}
}
testID="clear-privacy-data-button"
>
<Text
accessibilityRole="text"
Expand Down
29 changes: 29 additions & 0 deletions e2e/pages/Settings/SecurityAndPrivacy/ClearPrivacyModal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import {
cortisiko marked this conversation as resolved.
Show resolved Hide resolved
ClearPrivacyModalSelectorsIDs,
ClearPrivacyModalSelectorsText,
} from '../../../selectors/Settings/SecurityAndPrivacy/ClearPrivacyModal.selectors';
import Matchers from '../../../utils/Matchers';
import Gestures from '../../../utils/Gestures';

class ClearPrivacyModal {
get container() {
return Matchers.getElementByID(ClearPrivacyModalSelectorsIDs.CONTAINER);
}

get clearButton() {
return Matchers.getElementByText(
ClearPrivacyModalSelectorsText.CLEAR_BUTTON,
);
}
get cancelButton() {
return Matchers.getElementByText(
ClearPrivacyModalSelectorsText.CANCEL_BUTTON,
);
}

async tapClearButton() {
await Gestures.waitAndTap(this.clearButton);
}
}

export default new ClearPrivacyModal();
15 changes: 15 additions & 0 deletions e2e/pages/Settings/SecurityAndPrivacy/SecurityAndPrivacyView.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ class SecurityAndPrivacy {
SecurityPrivacyViewSelectorsIDs.REVEAL_SEED_BUTTON,
);
}
get clearPrivacyDataButton() {
cortisiko marked this conversation as resolved.
Show resolved Hide resolved
return Matchers.getElementByID(
SecurityPrivacyViewSelectorsIDs.CLEAR_PRIVACY_DATA_BUTTON,
);
}

get securityAndPrivacyHeading() {
return Matchers.getElementByText(
Expand Down Expand Up @@ -144,6 +149,13 @@ class SecurityAndPrivacy {
);
}

async scrollToClearPrivacyData() {
cortisiko marked this conversation as resolved.
Show resolved Hide resolved
await Gestures.scrollToElement(
this.clearPrivacyDataButton,
this.scrollViewIdentifier,
);
}

async scrollToMetaMetrics() {
await Gestures.scrollToElement(
this.metaMetricsToggle,
Expand All @@ -165,6 +177,9 @@ class SecurityAndPrivacy {
async tapMetaMetricsToggle() {
await Gestures.waitAndTap(this.metaMetricsToggle);
}
async tapClearPrivacyData() {
cortisiko marked this conversation as resolved.
Show resolved Hide resolved
await Gestures.waitAndTap(this.clearPrivacyDataButton);
}

async tapTurnOnRememberMeToggle() {
await Gestures.waitAndTap(this.rememberMeToggle);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import enContent from '../../../../locales/languages/en.json';
cortisiko marked this conversation as resolved.
Show resolved Hide resolved

export const ClearPrivacyModalSelectorsText = {
CLEAR_BUTTON: enContent.app_settings.clear,
CANCEL_BUTTON: enContent.app_settings.reset_account_cancel_button,
};

export const ClearPrivacyModalSelectorsIDs = {
CONTAINER: 'privacy-modal-container',
};
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ export const SecurityPrivacyViewSelectorsIDs = {
REMEMBER_ME_TOGGLE: 'turn-on-remember-me',
SHOW_PRIVATE_KEY: 'show-private-key',
BIOMETRICS_TOGGLE: 'biometrics-option',
DEVICE_PASSCODE_TOGGLE: 'DevicePasscodeOption',
DEVICE_PASSCODE_TOGGLE: 'device-passcode-option',
cortisiko marked this conversation as resolved.
Show resolved Hide resolved
CLEAR_PRIVACY_DATA_BUTTON: 'clear-privacy-data-button',
cortisiko marked this conversation as resolved.
Show resolved Hide resolved
};

export const SecurityPrivacyViewSelectorsText = {
Expand Down
56 changes: 56 additions & 0 deletions e2e/specs/settings/clear-privacy-data.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
'use strict';
import TestHelpers from '../../helpers';
import { Regression } from '../../tags';

import SettingsView from '../../pages/Settings/SettingsView';
import SecurityAndPrivacyView from '../../pages/Settings/SecurityAndPrivacy/SecurityAndPrivacyView';

import { loginToApp } from '../../viewHelper';
import TabBarComponent from '../../pages/wallet/TabBarComponent';
import FixtureBuilder from '../../fixtures/fixture-builder';
import { withFixtures } from '../../fixtures/fixture-helper';
import Assertions from '../../utils/Assertions';
import ClearPrivacyModal from '../../pages/Settings/SecurityAndPrivacy/ClearPrivacyModal';
import BrowserView from '../../pages/Browser/BrowserView';
import ConnectedAccountsModal from '../../pages/Browser/ConnectedAccountsModal';

describe(Regression('Clear Privacy data'), () => {
beforeAll(async () => {
jest.setTimeout(150000);
await TestHelpers.reverseServerPort();
});

it('should clear all dapp connections', async () => {
await withFixtures(
{
dapp: true,
fixture: new FixtureBuilder()
.withPermissionControllerConnectedToTestDapp()
.build(),
restartDevice: true,
},
async () => {
await loginToApp();

await TabBarComponent.tapBrowser();
await BrowserView.navigateToTestDApp();
await BrowserView.tapNetworkAvatarButtonOnBrowser();
await Assertions.checkIfVisible(ConnectedAccountsModal.title);
await ConnectedAccountsModal.scrollToBottomOfModal();

// should go to settings then security & privacy
await TabBarComponent.tapSettings();
await SettingsView.tapSecurityAndPrivacy();
await SecurityAndPrivacyView.scrollToClearPrivacyData();
await SecurityAndPrivacyView.tapClearPrivacyData();

await Assertions.checkIfVisible(ClearPrivacyModal.container);
await ClearPrivacyModal.tapClearButton();

await TabBarComponent.tapBrowser();
await BrowserView.tapNetworkAvatarButtonOnBrowser();
await Assertions.checkIfNotVisible(ConnectedAccountsModal.title);
},
);
});
});
18 changes: 9 additions & 9 deletions e2e/tags.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
const tags = {
regression: 'Regression',
smokeAccounts: 'SmokeAccounts',
smokeCore: 'SmokeCore',
smokeConfirmations: 'SmokeConfirmations',
SmokeSwaps: 'SmokeSwaps',
SmokeRest: 'SmokeRest',
smokeAssets: 'smokeAssets',
smokeIdentity: 'smokeIdentity',
smokeMultiChain: 'SmokeMultiChain',
regression: 'Regression:',
cortisiko marked this conversation as resolved.
Show resolved Hide resolved
smokeAccounts: 'SmokeAccounts:',
smokeCore: 'SmokeCore:',
smokeConfirmations: 'SmokeConfirmations:',
SmokeSwaps: 'SmokeSwaps:',
SmokeRest: 'SmokeRest:',
smokeAssets: 'smokeAssets:',
smokeIdentity: 'smokeIdentity:',
smokeMultiChain: 'SmokeMultiChain:',
};

const Regression = (testName) => `${tags.regression} ${testName}`;
Expand Down
Loading