Skip to content

Commit 0b6a6a0

Browse files
authored
test: 1/3 remove wdio folder dependencies (#29820)
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until this PR meets the canonical Definition of Ready For Review in `docs/readme/ready-for-review.md`. In short: the template must be materially complete (not just section titles present), all status checks must be currently passing, and the only expected follow-up commits must be reviewer-driven. --> ## **Description** > Removes the WDIO `generateTestId` helper and updates many UI components to pass `testID` directly (dropping `Platform`-dependent spreading) across buttons, toggles, list items, and modals. > > Introduces/standardizes colocated `*.testIds.ts` selector constants for several screens/components (e.g., `Navbar`, `EthereumAddress`, `AccountSelector`, `BrowserTab` options, `PhishingModal`, `WebviewError`, `TermsAndConditions`, `ConnectQRHardware`) and updates unit tests/components to import selectors from the new `tests/selectors`/local testId modules instead of `wdio` paths. > ## **Changelog** <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> CHANGELOG entry: ## **Related issues** Fixes: ## **Manual testing steps** ```gherkin Feature: my feature name Scenario: user [verb for user action] Given [describe expected initial app state] When user [verb for user action] Then [describe expected outcome] ``` ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** <!-- Every checklist item must be consciously assessed before marking this PR as "Ready for review". A checked box means you deliberately considered that responsibility, not that you literally performed every action listed. Unchecked boxes are ambiguous: they are not an implicit "N/A" and they are not a silent "skip". See `docs/readme/ready-for-review.md` for the full checklist semantics. --> - [ ] 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. #### Performance checks (if applicable) - [ ] I've tested on Android - Ideally on a mid-range device; emulator is acceptable - [ ] I've tested with a power user scenario - Use these [power-user SRPs](https://consensyssoftware.atlassian.net/wiki/spaces/TL1/pages/edit-v2/401401446401?draftShareId=9d77e1e1-4bdc-4be1-9ebb-ccd916988d93) to import wallets with many accounts and tokens - [ ] I've instrumented key operations with Sentry traces for production performance metrics - See [`trace()`](/app/util/trace.ts) for usage and [`addToken`](/app/components/Views/AddAsset/components/AddCustomToken/AddCustomToken.tsx#L274) for an example For performance guidelines and tooling, see the [Performance Guide](https://consensyssoftware.atlassian.net/wiki/spaces/TL1/pages/400085549067/Performance+Guide+for+Engineers). ## **Pre-merge reviewer checklist** <!-- Reviewer checklist items follow the same semantics as the author checklist: an unchecked box is ambiguous, a checked box means the reviewer consciously assessed that responsibility. See `docs/readme/ready-for-review.md`. --> - [ ] 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. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Low risk refactor focused on test selectors: changes only how `testID`s are assigned and referenced, with minimal runtime impact beyond potential selector/name mismatches in tests/automation. > > **Overview** > Removes the WDIO `generateTestId` utility and updates multiple UI components to pass `testID` directly (dropping `Platform`-dependent spreading) across buttons, toggles, list items, and modals. > > Introduces/standardizes co-located `*.testIds.ts` selector constants (e.g., `Navbar`, `EthereumAddress`, `AccountSelector`, browser options, phishing/webview error modals, terms, QR hardware connect) and updates unit tests/components to import selectors from these modules (and from `tests/selectors`) instead of `wdio` paths. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 7d696af. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 33eaccf commit 0b6a6a0

39 files changed

Lines changed: 145 additions & 169 deletions

File tree

app/component-library/components-temp/SheetActions/SheetActions.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Third party dependencies.
22
import React, { useCallback } from 'react';
3-
import { Platform, View } from 'react-native';
3+
import { View } from 'react-native';
44

55
// External dependencies.
66
import { useStyles } from '../../hooks';
@@ -10,7 +10,6 @@ import Button, {
1010
ButtonWidthTypes,
1111
} from '../../components/Buttons/Button';
1212
import Loader from '../Loader';
13-
import generateTestId from '../../../../wdio/utils/generateTestId';
1413

1514
// Internal dependencies.
1615
import { SheetActionsProps } from './SheetActions.types';
@@ -46,7 +45,7 @@ const SheetActions = ({ actions }: SheetActionsProps) => {
4645
disabled={disabled || isLoading}
4746
style={buttonStyle}
4847
isDanger={isDanger}
49-
{...generateTestId(Platform, testID)}
48+
testID={testID}
5049
/>
5150
{isLoading && <Loader size={'small'} />}
5251
</View>

app/component-library/components/Avatars/Avatar/variants/AvatarNetwork/AvatarNetwork.constants.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
/* eslint-disable import-x/prefer-default-export */
22

33
// Third party dependencies.
4-
import { ImageSourcePropType, Platform } from 'react-native';
4+
import { ImageSourcePropType } from 'react-native';
55

66
// External dependencies.
77
import { AvatarSize } from '../../Avatar.types';
88
import { BrowserViewSelectorsIDs } from '../../../../../../components/Views/BrowserTab/BrowserView.testIds';
9-
import generateTestId from '../../../../../../../wdio/utils/generateTestId';
109

1110
// Internal dependencies.
1211
import { AvatarNetworkProps } from './AvatarNetwork.types';
@@ -16,10 +15,7 @@ export const DEFAULT_AVATARNETWORK_SIZE = AvatarSize.Md;
1615
export const DEFAULT_AVATARNETWORK_ERROR_TEXT = '?';
1716

1817
// Test IDs
19-
export const AVATARNETWORK_IMAGE_TESTID = generateTestId(
20-
Platform,
21-
BrowserViewSelectorsIDs.AVATAR_IMAGE,
22-
).testID;
18+
export const AVATARNETWORK_IMAGE_TESTID = BrowserViewSelectorsIDs.AVATAR_IMAGE;
2319

2420
// Sample consts
2521
const SAMPLE_AVATARNETWORK_IMAGESOURCE_REMOTE: ImageSourcePropType = {

app/components/UI/AddToAddressBookWrapper/AddToAddressBookWrapper.tsx

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import React, { ReactElement, useState } from 'react';
22
import { useSelector } from 'react-redux';
3-
import { View, Platform, TextInput, TouchableOpacity } from 'react-native';
3+
import { View, TextInput, TouchableOpacity } from 'react-native';
44

5-
import generateTestId from '../../../../wdio/utils/generateTestId';
65
import { AddAddressModalSelectorsIDs } from './AddAddressModal.testIds';
76
import { strings } from '../../../../locales/i18n';
87
import Engine from '../../../core/Engine';
@@ -91,10 +90,7 @@ export const AddToAddressBookWrapper = ({
9190
<View style={baseStyles.flexGrow}>
9291
<Text
9392
style={styles.addTextTitle}
94-
{...generateTestId(
95-
Platform,
96-
AddAddressModalSelectorsIDs.TITLE,
97-
)}
93+
testID={AddAddressModalSelectorsIDs.TITLE}
9894
>
9995
{strings('address_book.add_to_address_book')}
10096
</Text>
@@ -117,10 +113,7 @@ export const AddToAddressBookWrapper = ({
117113
numberOfLines={1}
118114
value={alias}
119115
keyboardAppearance={themeAppearance}
120-
{...generateTestId(
121-
Platform,
122-
AddAddressModalSelectorsIDs.ENTER_ALIAS_INPUT,
123-
)}
116+
testID={AddAddressModalSelectorsIDs.ENTER_ALIAS_INPUT}
124117
/>
125118
</View>
126119
</View>

app/components/UI/AssetElement/index.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import { render, fireEvent } from '@testing-library/react-native';
33
import AssetElement from './';
4-
import { getAssetTestId } from '../../../../wdio/screen-objects/testIDs/Screens/WalletView.testIds';
4+
import { getAssetTestId } from '../../../../tests/selectors/Wallet/WalletView.selectors';
55
import {
66
BALANCE_TEST_ID,
77
SECONDARY_BALANCE_BUTTON_TEST_ID,

app/components/UI/AssetElement/index.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
/* eslint-disable react/prop-types */
22
import React from 'react';
3-
import { TouchableOpacity, StyleSheet, Platform, View } from 'react-native';
3+
import { TouchableOpacity, StyleSheet, View } from 'react-native';
44
import {
55
TextVariant,
66
TextColor,
77
} from '../../../component-library/components/Texts/Text';
88
import SkeletonText from '../Ramp/Aggregator/components/SkeletonText';
99
import { TokenI } from '../Tokens/types';
10-
import generateTestId from '../../../../wdio/utils/generateTestId';
11-
import { getAssetTestId } from '../../../../wdio/screen-objects/testIDs/Screens/WalletView.testIds';
10+
import { getAssetTestId } from '../../../../tests/selectors/Wallet/WalletView.selectors';
1211
import SensitiveText, {
1312
SensitiveTextLength,
1413
} from '../../../component-library/components/Texts/SensitiveText';
@@ -113,7 +112,7 @@ const AssetElement: React.FC<AssetElementProps> = ({
113112
onPress={handleOnPress}
114113
onLongPress={handleOnLongPress}
115114
style={styles.itemWrapper}
116-
{...generateTestId(Platform, getAssetTestId(asset.symbol))}
115+
testID={getAssetTestId(asset.symbol)}
117116
>
118117
{children}
119118
<View style={styles.arrow}>

app/components/UI/AssetOverview/AssetActionButton/AssetActionButton.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import React from 'react';
2-
import { Platform, TouchableOpacity, View } from 'react-native';
2+
import { TouchableOpacity, View } from 'react-native';
33
import FeatherIcon from 'react-native-vector-icons/Feather';
44
import Ionicon from 'react-native-vector-icons/Ionicons';
55
import MaterialCommunityIcon from 'react-native-vector-icons/MaterialCommunityIcons';
6-
import generateTestId from '../../../../../wdio/utils/generateTestId';
76
import { useTheme } from '../../../../util/theme';
87
import Text from '../../../Base/Text';
98
import styleSheet from './AssetActionButton.styles';
@@ -84,7 +83,7 @@ const AssetActionButton = ({
8483

8584
return (
8685
<TouchableOpacity
87-
{...generateTestId(Platform, testID)}
86+
testID={testID}
8887
onPress={onPress}
8988
style={[styles.button, disabled && styles.disabledButton]}
9089
disabled={disabled}

app/components/UI/Bridge/components/TokenSelectorItem.test.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,6 @@ jest.mock('../../../../component-library/hooks', () => ({
5050
}),
5151
}));
5252

53-
jest.mock('../../../../../wdio/utils/generateTestId', () => ({
54-
__esModule: true,
55-
default: () => ({}),
56-
}));
57-
5853
jest.mock(
5954
'../../../../component-library/components/Badges/BadgeWrapper',
6055
() => ({

app/components/UI/Bridge/components/TokenSelectorItem.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,12 @@ import {
44
ImageSourcePropType,
55
View,
66
TouchableOpacity,
7-
Platform,
87
StyleProp,
98
TextStyle,
109
} from 'react-native';
1110
import { useSelector } from 'react-redux';
1211
import { strings } from '../../../../../locales/i18n';
13-
import { getAssetTestId } from '../../../../../wdio/screen-objects/testIDs/Screens/WalletView.testIds';
14-
import generateTestId from '../../../../../wdio/utils/generateTestId';
12+
import { getAssetTestId } from '../../../../../tests/selectors/Wallet/WalletView.selectors';
1513
import TagBase, {
1614
TagSeverity,
1715
TagShape,
@@ -334,10 +332,7 @@ export const TokenSelectorItem: React.FC<TokenSelectorItemProps> = ({
334332
key={token.address}
335333
onPress={() => onPress(token)}
336334
style={styles.itemWrapper}
337-
{...generateTestId(
338-
Platform,
339-
getAssetTestId(`${token.chainId}-${token.symbol}`),
340-
)}
335+
testID={getAssetTestId(`${token.chainId}-${token.symbol}`)}
341336
>
342337
<Box
343338
flexDirection={FlexDirection.Row}

app/components/UI/Card/components/ManageCardListItem/ManageCardListItem.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React from 'react';
2-
import { TouchableOpacity, Platform, ActivityIndicator } from 'react-native';
2+
import { TouchableOpacity, ActivityIndicator } from 'react-native';
33
import { useTheme } from '../../../../../util/theme';
4-
import generateTestId from '../../../../../../wdio/utils/generateTestId';
54
import Icon, {
65
IconName,
76
IconSize,
@@ -43,7 +42,7 @@ const ManageCardListItem: React.FC<ManageCardListItemProps> = ({
4342
const styles = createStyles(colors, descriptionOrientation);
4443

4544
return (
46-
<TouchableOpacity onPress={onPress} {...generateTestId(Platform, testID)}>
45+
<TouchableOpacity onPress={onPress} testID={testID}>
4746
<ListItem style={styles.root}>
4847
<ListItemColumn widthType={WidthType.Fill} style={styles.description}>
4948
<Text variant={TextVariant.BodyMd} fontWeight={FontWeight.Medium}>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const EthereumAddressSelectorsIDs = {
2+
ADDRESS_LABEL: 'wallet-account-address-label',
3+
};

0 commit comments

Comments
 (0)