Skip to content

Commit

Permalink
test: Move files to Onboarding folder (#12511)
Browse files Browse the repository at this point in the history
## **Description**

We currently have a few of our page object files lingering outside of a
specific folder. As part of our ongoing efforts to improve the
organization and maintainability of our test automation codebase, we
need to move Page Object files into their respective folders. This will
help streamline the project structure, making it easier for team members
to locate and manage the files. The folder where each of the remaining
files should be moved have to reflect the functionality or feature on
the app. This same structure should be reflected on the selectors
folder.

Files to relocate to the Onboarding folder:

- e2e/pages/EnableDeviceNotificationsAlert.js
- e2e/pages/modals/EnableAutomaticSecurityChecksView.js
- e2e/pages/modals/ExperienceEnhancerModal.js
- e2e/pages/modals/OnboardingWizardModal.js
- e2e/pages/modals/ProtectYourWalletModal.js
- e2e/pages/modals/SkipAccountSecurityModal.js
- e2e/pages/modals/TermsOfUseModal.js
- e2e/pages/modals/WhatsNewModal.js

## **Related issues**

Fixes: 

## **Manual testing steps**

1. Go to this page...
2.
3.

## **Screenshots/Recordings**


https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/c8ecb663-d2d1-4522-a6e0-7145ba7bc1e7?tab=workflows

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->

## **Pre-merge author checklist**

- [ ] I’ve followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [ ] I've completed the PR template to the best of my ability
- [ ] I’ve included tests if applicable
- [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **Pre-merge reviewer checklist**

- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
  • Loading branch information
SamuelSalas authored Dec 3, 2024
1 parent 1a0dc3b commit a97e2ef
Show file tree
Hide file tree
Showing 53 changed files with 128 additions and 196 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import {
MandatoryModalProps,
} from './ModalMandatory.types';
import stylesheet from './ModalMandatory.styles';
import { TermsOfUseModalSelectorsIDs } from '../../../../../e2e/selectors/Modals/TermsOfUseModal.selectors';
import { TermsOfUseModalSelectorsIDs } from '../../../../../e2e/selectors/Onboarding/TermsOfUseModal.selectors';

const ModalMandatory = ({ route }: MandatoryModalProps) => {
const { colors } = useTheme();
Expand Down
2 changes: 1 addition & 1 deletion app/components/UI/BackupAlert/BackupAlert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { useDispatch, useSelector } from 'react-redux';
import { backUpSeedphraseAlertNotVisible } from '../../../actions/user';
import { findRouteNameFromNavigatorState } from '../../../util/general';
import { MetaMetricsEvents } from '../../../core/Analytics';
import { ProtectWalletModalSelectorsIDs } from '../../../../e2e/selectors/Modals/ProtectWalletModal.selectors';
import { ProtectWalletModalSelectorsIDs } from '../../../../e2e/selectors/Onboarding/ProtectWalletModal.selectors';
import styleSheet from './BackupAlert.styles';
import { useStyles } from '../../../component-library/hooks';
import { BackupAlertI } from './BackupAlert.types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
import { MetaMetricsEvents } from '../../../core/Analytics';

import { ScrollView } from 'react-native-gesture-handler';
import { EnableAutomaticSecurityChecksIDs } from '../../../../e2e/selectors/Modals/EnableAutomaticSecurityChecks.selectors';
import { EnableAutomaticSecurityChecksIDs } from '../../../../e2e/selectors/Onboarding/EnableAutomaticSecurityChecks.selectors';
import generateDeviceAnalyticsMetaData from '../../../util/metrics';
import { useMetrics } from '../../../components/hooks/useMetrics';

Expand Down
2 changes: 1 addition & 1 deletion app/components/UI/OnboardingWizard/Coachmark/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
ButtonWidthTypes,
} from '../../../../component-library/components/Buttons/Button';
import Button from '../../../../component-library/components/Buttons/Button/Button';
import { OnboardingWizardModalSelectorsIDs } from '../../../../../e2e/selectors/Modals/OnboardingWizardModal.selectors';
import { OnboardingWizardModalSelectorsIDs } from '../../../../../e2e/selectors/Onboarding/OnboardingWizardModal.selectors';

const createStyles = (colors) =>
StyleSheet.create({
Expand Down
2 changes: 1 addition & 1 deletion app/components/UI/OnboardingWizard/Step1/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
ONBOARDING_WIZARD_STEP_DESCRIPTION,
} from '../../../../core/Analytics';
import { ThemeContext, mockTheme } from '../../../../util/theme';
import { OnboardingWizardModalSelectorsIDs } from '../../../../../e2e/selectors/Modals/OnboardingWizardModal.selectors';
import { OnboardingWizardModalSelectorsIDs } from '../../../../../e2e/selectors/Onboarding/OnboardingWizardModal.selectors';
import { useMetrics } from '../../../../components/hooks/useMetrics';

const styles = StyleSheet.create({
Expand Down
2 changes: 1 addition & 1 deletion app/components/UI/OnboardingWizard/Step2/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
ONBOARDING_WIZARD_STEP_DESCRIPTION,
} from '../../../../core/Analytics';
import { useTheme } from '../../../../util/theme';
import { OnboardingWizardModalSelectorsIDs } from '../../../../../e2e/selectors/Modals/OnboardingWizardModal.selectors';
import { OnboardingWizardModalSelectorsIDs } from '../../../../../e2e/selectors/Onboarding/OnboardingWizardModal.selectors';
import { useMetrics } from '../../../hooks/useMetrics';
import useHandleLayout from '../useHandleLayout';

Expand Down
2 changes: 1 addition & 1 deletion app/components/UI/OnboardingWizard/Step3/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
} from '../../../../core/Analytics';
import { useTheme } from '../../../../util/theme';
import { useMetrics } from '../../../hooks/useMetrics';
import { OnboardingWizardModalSelectorsIDs } from '../../../../../e2e/selectors/Modals/OnboardingWizardModal.selectors';
import { OnboardingWizardModalSelectorsIDs } from '../../../../../e2e/selectors/Onboarding/OnboardingWizardModal.selectors';
import useHandleLayout from '../useHandleLayout';

const styles = StyleSheet.create({
Expand Down
2 changes: 1 addition & 1 deletion app/components/UI/OnboardingWizard/Step4/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
ONBOARDING_WIZARD_STEP_DESCRIPTION,
} from '../../../../core/Analytics';
import { useTheme } from '../../../../util/theme';
import { OnboardingWizardModalSelectorsIDs } from '../../../../../e2e/selectors/Modals/OnboardingWizardModal.selectors';
import { OnboardingWizardModalSelectorsIDs } from '../../../../../e2e/selectors/Onboarding/OnboardingWizardModal.selectors';

import { useMetrics } from '../../../hooks/useMetrics';

Expand Down
2 changes: 1 addition & 1 deletion app/components/UI/OnboardingWizard/Step5/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
import { useTheme } from '../../../../util/theme';

import { useMetrics } from '../../../hooks/useMetrics';
import { OnboardingWizardModalSelectorsIDs } from '../../../../../e2e/selectors/Modals/OnboardingWizardModal.selectors';
import { OnboardingWizardModalSelectorsIDs } from '../../../../../e2e/selectors/Onboarding/OnboardingWizardModal.selectors';

const styles = StyleSheet.create({
main: {
Expand Down
2 changes: 1 addition & 1 deletion app/components/UI/OnboardingWizard/Step6/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
ONBOARDING_WIZARD_STEP_DESCRIPTION,
} from '../../../../core/Analytics';
import { useTheme } from '../../../../util/theme';
import { OnboardingWizardModalSelectorsIDs } from '../../../../../e2e/selectors/Modals/OnboardingWizardModal.selectors';
import { OnboardingWizardModalSelectorsIDs } from '../../../../../e2e/selectors/Onboarding/OnboardingWizardModal.selectors';
import { useMetrics } from '../../../hooks/useMetrics';

const styles = StyleSheet.create({
Expand Down
2 changes: 1 addition & 1 deletion app/components/UI/OnboardingWizard/Step7/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
} from '../../../../core/Analytics';
import { useTheme } from '../../../../util/theme';

import { OnboardingWizardModalSelectorsIDs } from '../../../../../e2e/selectors/Modals/OnboardingWizardModal.selectors';
import { OnboardingWizardModalSelectorsIDs } from '../../../../../e2e/selectors/Onboarding/OnboardingWizardModal.selectors';
import { useMetrics } from '../../../hooks/useMetrics';

const styles = StyleSheet.create({
Expand Down
2 changes: 1 addition & 1 deletion app/components/UI/ProtectYourWalletModal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import scaling from '../../../util/scaling';
import { MetaMetricsEvents } from '../../../core/Analytics';

import { ThemeContext, mockTheme } from '../../../util/theme';
import { ProtectWalletModalSelectorsIDs } from '../../../../e2e/selectors/Modals/ProtectWalletModal.selectors';
import { ProtectWalletModalSelectorsIDs } from '../../../../e2e/selectors/Onboarding/ProtectWalletModal.selectors';
import { withMetricsAwareness } from '../../../components/hooks/useMetrics';

const protectWalletImage = require('../../../images/explain-backup-seedphrase.png'); // eslint-disable-line
Expand Down
2 changes: 1 addition & 1 deletion app/components/UI/SkipAccountSecurityModal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import PropTypes from 'prop-types';
import { fontStyles } from '../../../styles/common';
import { useTheme } from '../../../util/theme';
import generateTestId from '../../../../wdio/utils/generateTestId';
import { SkipAccountSecurityModalSelectorsIDs } from '../../../../e2e/selectors/Modals/SkipAccountSecurityModal.selectors';
import { SkipAccountSecurityModalSelectorsIDs } from '../../../../e2e/selectors/Onboarding/SkipAccountSecurityModal.selectors';

const createStyles = (colors) =>
StyleSheet.create({
Expand Down
2 changes: 1 addition & 1 deletion app/components/UI/WhatsNewModal/WhatsNewModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import Icon, {
import ReusableModal, { ReusableModalRef } from '../ReusableModal';
import { whatsNewList } from './';
import { Colors } from '../../../util/theme/models';
import { WhatsNewModalSelectorsIDs } from '../../../../e2e/selectors/Modals/WhatsNewModal.selectors';
import { WhatsNewModalSelectorsIDs } from '../../../../e2e/selectors/Onboarding/WhatsNewModal.selectors';
import { ScrollView } from 'react-native-gesture-handler';
import { useNavigation } from '@react-navigation/native';

Expand Down
8 changes: 4 additions & 4 deletions app/components/Views/ExperienceEnhancerModal/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useDispatch } from 'react-redux';
import { setDataCollectionForMarketing } from '../../../actions/security';
import { HOW_TO_MANAGE_METRAMETRICS_SETTINGS } from '../../../constants/urls';
import ExperienceEnhancerModal from './';
import { ExperienceEnhancerModalSelectorsIDs } from '../../../../e2e/selectors/Modals/ExperienceEnhancerModal.selectors.js';
import { ExperienceEnhancerBottomSheetSelectorsIDs } from '../../../../e2e/selectors/Onboarding/ExperienceEnhancerModal.selectors.js';

// Mock the BottomSheet component
jest.mock(
Expand Down Expand Up @@ -52,7 +52,7 @@ describe('ExperienceEnhancerModal', () => {
const { getByTestId } = render(<ExperienceEnhancerModal />);

const cancelButton = getByTestId(
ExperienceEnhancerModalSelectorsIDs.CANCEL_BUTTON,
ExperienceEnhancerBottomSheetSelectorsIDs.CANCEL_BUTTON,
);
expect(cancelButton).toBeTruthy();

Expand All @@ -66,7 +66,7 @@ describe('ExperienceEnhancerModal', () => {
const { getByTestId } = render(<ExperienceEnhancerModal />);

const acceptButton = getByTestId(
ExperienceEnhancerModalSelectorsIDs.ACCEPT_BUTTON,
ExperienceEnhancerBottomSheetSelectorsIDs.ACCEPT_BUTTON,
);
expect(acceptButton).toBeTruthy();

Expand All @@ -80,7 +80,7 @@ describe('ExperienceEnhancerModal', () => {
const { getByTestId } = render(<ExperienceEnhancerModal />);

const linkButton = getByTestId(
ExperienceEnhancerModalSelectorsIDs.LINK_BUTTON,
ExperienceEnhancerBottomSheetSelectorsIDs.LINK_BUTTON,
);
expect(linkButton).toBeTruthy();

Expand Down
24 changes: 12 additions & 12 deletions app/components/Views/ExperienceEnhancerModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
useMetrics,
} from '../../../components/hooks/useMetrics';
import { HOW_TO_MANAGE_METRAMETRICS_SETTINGS } from '../../../constants/urls';
import { ExperienceEnhancerModalSelectorsIDs } from '../../../../e2e/selectors/Modals/ExperienceEnhancerModal.selectors.js';
import { ExperienceEnhancerBottomSheetSelectorsIDs } from '../../../../e2e/selectors/Onboarding/ExperienceEnhancerModal.selectors.js';

const ExperienceEnhancerModal = () => {
const dispatch = useDispatch();
Expand Down Expand Up @@ -53,7 +53,7 @@ const ExperienceEnhancerModal = () => {
.build(),
);
},
testID: ExperienceEnhancerModalSelectorsIDs.CANCEL_BUTTON,
testID: ExperienceEnhancerBottomSheetSelectorsIDs.CANCEL_BUTTON,
};

const acceptButtonProps: ButtonProps = {
Expand All @@ -75,68 +75,68 @@ const ExperienceEnhancerModal = () => {
.build(),
);
},
testID: ExperienceEnhancerModalSelectorsIDs.ACCEPT_BUTTON,
testID: ExperienceEnhancerBottomSheetSelectorsIDs.ACCEPT_BUTTON,
};

return (
<BottomSheet
ref={bottomSheetRef}
testID={ExperienceEnhancerModalSelectorsIDs.BOTTOM_SHEET}
testID={ExperienceEnhancerBottomSheetSelectorsIDs.BOTTOM_SHEET}
>
<Text
variant={TextVariant.HeadingMD}
style={styles.title}
testID={ExperienceEnhancerModalSelectorsIDs.TITLE}
testID={ExperienceEnhancerBottomSheetSelectorsIDs.TITLE}
>
{strings('experience_enhancer_modal.title')}
</Text>
<View
style={styles.content}
testID={ExperienceEnhancerModalSelectorsIDs.CONTENT}
testID={ExperienceEnhancerBottomSheetSelectorsIDs.CONTENT}
>
<Text variant={TextVariant.BodyMD}>
{strings('experience_enhancer_modal.paragraph1a')}
<Button
variant={ButtonVariants.Link}
label={strings('experience_enhancer_modal.link')}
onPress={() => Linking.openURL(HOW_TO_MANAGE_METRAMETRICS_SETTINGS)}
testID={ExperienceEnhancerModalSelectorsIDs.LINK_BUTTON}
testID={ExperienceEnhancerBottomSheetSelectorsIDs.LINK_BUTTON}
/>
{strings('experience_enhancer_modal.paragraph1b')}
</Text>

<Text
variant={TextVariant.BodyMD}
testID={ExperienceEnhancerModalSelectorsIDs.PARAGRAPH_2}
testID={ExperienceEnhancerBottomSheetSelectorsIDs.PARAGRAPH_2}
>
{strings('experience_enhancer_modal.paragraph2')}
</Text>
<View style={styles.list}>
<Text
style={styles.line}
testID={ExperienceEnhancerModalSelectorsIDs.BULLET_1}
testID={ExperienceEnhancerBottomSheetSelectorsIDs.BULLET_1}
>
<Text style={styles.dot}></Text>{' '}
{strings('experience_enhancer_modal.bullet1')}
</Text>
<Text
style={styles.line}
testID={ExperienceEnhancerModalSelectorsIDs.BULLET_2}
testID={ExperienceEnhancerBottomSheetSelectorsIDs.BULLET_2}
>
<Text style={styles.dot}></Text>{' '}
{strings('experience_enhancer_modal.bullet2')}
</Text>
<Text
style={styles.line}
testID={ExperienceEnhancerModalSelectorsIDs.BULLET_3}
testID={ExperienceEnhancerBottomSheetSelectorsIDs.BULLET_3}
>
<Text style={styles.dot}></Text>{' '}
{strings('experience_enhancer_modal.bullet3')}
</Text>
</View>
<Text
variant={TextVariant.BodyMD}
testID={ExperienceEnhancerModalSelectorsIDs.FOOTER}
testID={ExperienceEnhancerBottomSheetSelectorsIDs.FOOTER}
>
{strings('experience_enhancer_modal.footer')}
</Text>
Expand Down
2 changes: 1 addition & 1 deletion app/util/termsOfUse/termsOfUse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { MetricsEventBuilder } from '../../core/Analytics/MetricsEventBuilder';
import { TRUE, USE_TERMS } from '../../constants/storage';
import Routes from '../../constants/navigation/Routes';
import { strings } from '../../../locales/i18n';
import { TermsOfUseModalSelectorsIDs } from '../../../e2e/selectors/Modals/TermsOfUseModal.selectors';
import { TermsOfUseModalSelectorsIDs } from '../../../e2e/selectors/Onboarding/TermsOfUseModal.selectors';
import StorageWrapper from '../../store/storage-wrapper';
import termsOfUse from './termsOfUseContent';

Expand Down
36 changes: 0 additions & 36 deletions e2e/pages/EnableDeviceNotificationsAlert.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Matchers from '../../utils/Matchers';
import Gestures from '../../utils/Gestures';
import { EnableAutomaticSecurityChecksIDs } from '../../selectors/Modals/EnableAutomaticSecurityChecks.selectors';
import { EnableAutomaticSecurityChecksIDs } from '../../selectors/Onboarding/EnableAutomaticSecurityChecks.selectors';

class EnableAutomaticSecurityChecksView {
get container() {
Expand Down
24 changes: 24 additions & 0 deletions e2e/pages/Onboarding/EnableDeviceNotificationsAlert.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import Gestures from '../../utils/Gestures';
import Matchers from '../../utils/Matchers';

import {
EnableDeviceNotificationsAlertSelectorText
} from '../../selectors/Onboarding/EnableDeviceNotificationsAlert.selectors';

class EnableDeviceNotificationsAlert {
get stepOneContainer() {
return Matchers.getSystemElementByText(EnableDeviceNotificationsAlertSelectorText.CONTAINER);
}

get getEnableDeviceNotificationsButton() {
return Matchers.getSystemElementByText(
EnableDeviceNotificationsAlertSelectorText.YES_BUTTON,
);
}

async tapOnEnableDeviceNotificationsButton() {
await Gestures.waitAndTap(this.getEnableDeviceNotificationsButton);
}
}

export default new EnableDeviceNotificationsAlert();
23 changes: 23 additions & 0 deletions e2e/pages/Onboarding/ExperienceEnhancerBottomSheet.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { ExperienceEnhancerBottomSheetSelectorsIDs } from '../../selectors/Onboarding/ExperienceEnhancerModal.selectors';
import Matchers from '../../utils/Matchers';
import Gestures from '../../utils/Gestures';

class ExperienceEnhancerBottomSheet {
get container() {
return Matchers.getElementByID(
ExperienceEnhancerBottomSheetSelectorsIDs.BOTTOM_SHEET,
);
}

get iAgree() {
return Matchers.getElementByID(
ExperienceEnhancerBottomSheetSelectorsIDs.ACCEPT_BUTTON,
);
}

async tapIAgree() {
await Gestures.waitAndTap(this.iAgree);
}
}

export default new ExperienceEnhancerBottomSheet();
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { OnboardingWizardModalSelectorsIDs } from '../../selectors/Modals/OnboardingWizardModal.selectors';
import { OnboardingWizardModalSelectorsIDs } from '../../selectors/Onboarding/OnboardingWizardModal.selectors';
import Matchers from '../../utils/Matchers';
import Gestures from '../../utils/Gestures';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ProtectWalletModalSelectorsIDs } from '../../selectors/Modals/ProtectWalletModal.selectors';
import { ProtectWalletModalSelectorsIDs } from '../../selectors/Onboarding/ProtectWalletModal.selectors';
import Matchers from '../../utils/Matchers';
import Gestures from '../../utils/Gestures';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import { SkipAccountSecurityModalSelectorsIDs } from '../../selectors/Modals/SkipAccountSecurityModal.selectors';
import { SkipAccountSecurityModalSelectorsIDs } from '../../selectors/Onboarding/SkipAccountSecurityModal.selectors';
import Gestures from '../../utils/Gestures';
import Matchers from '../../utils/Matchers';

class SkipAccountSecurityModal {
get container() {
return Matchers.getElementByID(
SkipAccountSecurityModalSelectorsIDs.CONTAINER,
);
}
get iUnderstandCheckbox() {
return device.getPlatform() === 'android'
? Matchers.getElementByID(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { TermsOfUseModalSelectorsIDs } from '../../selectors/Modals/TermsOfUseModal.selectors';
import { TermsOfUseModalSelectorsIDs } from '../../selectors/Onboarding/TermsOfUseModal.selectors';
import Matchers from '../../utils/Matchers';
import Gestures from '../../utils/Gestures';

Expand Down
Loading

0 comments on commit a97e2ef

Please sign in to comment.