-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Fix add custom rpc detox test script (#8615)
## **Description** Currently, the tabs Popular and Custom Network in the Add Network screen are creating issues for the detox tests. Detox is not capable to Match the element with the current implementation. Also, we have found that using the byLabel Matcher also do not work as well. This issue affects both ios and android. ## **Related issues** Fixes: ## **Manual testing steps** 1. Go to this page... 2. 3. ## **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** - [ ] I’ve followed [MetaMask Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've clearly explained what problem this PR is solving and how it is solved. - [ ] I've linked related issues - [ ] I've included manual testing steps - [ ] I've included screenshots/recordings if applicable - [ ] 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. - [ ] I’ve properly set the pull request status: - [ ] In case it's not yet "ready for review", I've set it to "draft". - [ ] In case it's "ready for review", I've changed it from "draft" to "non-draft". ## **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
1 parent
a20df64
commit c88a502
Showing
8 changed files
with
136 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,97 +1,127 @@ | ||
import TestHelpers from '../../helpers'; | ||
import { | ||
INPUT_NETWORK_NAME, | ||
INPUT_RPC_URL_FIELD, | ||
INPUT_CHAIN_ID_FIELD, | ||
NETWORKS_SYMBOL_INPUT_FIELD, | ||
RPC_WARNING_BANNER_ID, | ||
NETWORK_SCREEN_ID, | ||
CUSTOM_NETWORK_NAME_NETWORK_LIST, | ||
} from '../../../wdio/screen-objects/testIDs/Screens/NetworksScreen.testids'; | ||
import { | ||
NetworksViewSelectorsIDs, | ||
NetworkViewSelectorsText, | ||
} from '../../selectors/Settings/NetworksView.selectors'; | ||
import Matchers from '../../utils/Matchers'; | ||
import Gestures from '../../utils/Gestures'; | ||
|
||
class NetworkView { | ||
get networkContainer() { | ||
return Matchers.getElementByID(NetworksViewSelectorsIDs.NETWORK_CONTAINER); | ||
} | ||
|
||
get rpcContainer() { | ||
return Matchers.getElementByID(NetworksViewSelectorsIDs.RPC_CONTAINER); | ||
} | ||
|
||
export default class NetworkView { | ||
static async tapAddNetworkButton() { | ||
if (device.getPlatform() === 'ios') { | ||
await TestHelpers.tap(NetworksViewSelectorsIDs.ADD_NETWORKS_BUTTON); | ||
} else { | ||
await TestHelpers.waitAndTapByLabel( | ||
NetworksViewSelectorsIDs.ADD_NETWORKS_BUTTON, | ||
); | ||
} | ||
get addNetworkButton() { | ||
return device.getPlatform() === 'ios' | ||
? Matchers.getElementByID(NetworksViewSelectorsIDs.ADD_NETWORKS_BUTTON) | ||
: Matchers.getElementByLabel( | ||
NetworksViewSelectorsIDs.ADD_NETWORKS_BUTTON, | ||
); | ||
} | ||
|
||
static async switchToCustomNetworks() { | ||
await TestHelpers.waitAndTapText( | ||
get customNetworkTab() { | ||
return Matchers.getElementByText( | ||
NetworkViewSelectorsText.CUSTOM_NETWORK_TAB, | ||
); | ||
} | ||
|
||
static async tapPopularNetworkByName(networkName) { | ||
await TestHelpers.tapByText(networkName); | ||
} | ||
static async typeInNetworkName(networkName) { | ||
await TestHelpers.typeTextAndHideKeyboard(INPUT_NETWORK_NAME, networkName); | ||
get networkNameInput() { | ||
return Matchers.getElementByID(NetworksViewSelectorsIDs.NETWORK_NAME_INPUT); | ||
} | ||
static async typeInRpcUrl(rPCUrl) { | ||
await TestHelpers.typeTextAndHideKeyboard(INPUT_RPC_URL_FIELD, rPCUrl); | ||
|
||
get rpcURLInput() { | ||
return Matchers.getElementByID(NetworksViewSelectorsIDs.RPC_URL_INPUT); | ||
} | ||
static async typeInChainId(chainID) { | ||
await TestHelpers.typeTextAndHideKeyboard(INPUT_CHAIN_ID_FIELD, chainID); | ||
|
||
get chainIDInput() { | ||
return Matchers.getElementByID(NetworksViewSelectorsIDs.CHAIN_INPUT); | ||
} | ||
static async typeInNetworkSymbol(networkSymbol) { | ||
await TestHelpers.typeTextAndHideKeyboard( | ||
NETWORKS_SYMBOL_INPUT_FIELD, | ||
networkSymbol, | ||
|
||
get networkSymbolInput() { | ||
return Matchers.getElementByID( | ||
NetworksViewSelectorsIDs.NETWORKS_SYMBOL_INPUT, | ||
); | ||
} | ||
|
||
static async clearRpcInputBox() { | ||
await TestHelpers.clearField(INPUT_RPC_URL_FIELD); | ||
get rpcAddButton() { | ||
return device.getPlatform() === 'android' | ||
? Matchers.getElementByLabel( | ||
NetworksViewSelectorsIDs.ADD_CUSTOM_NETWORK_BUTTON, | ||
) | ||
: Matchers.getElementByID( | ||
NetworksViewSelectorsIDs.ADD_CUSTOM_NETWORK_BUTTON, | ||
); | ||
} | ||
|
||
static async tapRpcNetworkAddButton() { | ||
if (device.getPlatform() === 'android') { | ||
await TestHelpers.waitAndTapByLabel( | ||
NetworksViewSelectorsIDs.ADD_CUSTOM_NETWORK_BUTTON, | ||
); // make me better | ||
} else { | ||
await TestHelpers.waitAndTap( | ||
NetworksViewSelectorsIDs.ADD_CUSTOM_NETWORK_BUTTON, | ||
); | ||
} | ||
get blockExplorer() { | ||
return Matchers.getElementByLabel(NetworkViewSelectorsText.BLOCK_EXPLORER); | ||
} | ||
|
||
static async swipeToRPCTitleAndDismissKeyboard() { | ||
// Because in bitrise the keyboard is blocking the "Add" CTA | ||
await TestHelpers.waitAndTapByLabel( | ||
NetworkViewSelectorsText.BLOCK_EXPLORER, | ||
get rpcWarningBanner() { | ||
return Matchers.getElementByID(NetworksViewSelectorsIDs.RPC_WARNING_BANNER); | ||
} | ||
|
||
get customNetworkList() { | ||
return Matchers.getElementByID( | ||
NetworksViewSelectorsIDs.CUSTOM_NETWORK_LIST, | ||
); | ||
await TestHelpers.delay(3000); | ||
} | ||
|
||
static async removeNetwork() { | ||
await TestHelpers.tapAndLongPressAtIndex( | ||
CUSTOM_NETWORK_NAME_NETWORK_LIST, | ||
0, | ||
get removeNetwork() { | ||
return Matchers.getElementByText(NetworkViewSelectorsText.REMOVE_NETWORK); | ||
} | ||
|
||
async tapAddNetworkButton() { | ||
await Gestures.waitAndTap(this.addNetworkButton); | ||
} | ||
|
||
async switchToCustomNetworks() { | ||
await Gestures.waitAndTap(this.customNetworkTab); | ||
} | ||
|
||
async tapPopularNetworkByName(networkName) { | ||
const element = Matchers.getElementByText(networkName); | ||
await TestHelpers.tapByText(element); | ||
} | ||
async typeInNetworkName(networkName) { | ||
await Gestures.typeTextAndHideKeyboard(this.networkNameInput, networkName); | ||
} | ||
async typeInRpcUrl(rPCUrl) { | ||
await Gestures.typeTextAndHideKeyboard(this.rpcURLInput, rPCUrl); | ||
} | ||
async typeInChainId(chainID) { | ||
await Gestures.typeTextAndHideKeyboard(this.chainIDInput, chainID); | ||
} | ||
|
||
async typeInNetworkSymbol(networkSymbol) { | ||
await Gestures.typeTextAndHideKeyboard( | ||
this.networkSymbolInput, | ||
networkSymbol, | ||
); | ||
//Remove xDAI and verify removed on wallet view | ||
//Tap remove | ||
await TestHelpers.tapByText(NetworkViewSelectorsText.REMOVE_NETWORK); | ||
} | ||
|
||
static async isNetworkViewVisible() { | ||
await TestHelpers.checkIfVisible(NETWORK_SCREEN_ID); | ||
async clearRpcInputBox() { | ||
await Gestures.clearField(this.rpcURLInput); | ||
} | ||
|
||
static async isRpcViewVisible() { | ||
await TestHelpers.checkIfVisible(NetworksViewSelectorsIDs.CONTAINER); | ||
async tapRpcNetworkAddButton() { | ||
await Gestures.waitAndTap(this.rpcAddButton); | ||
} | ||
|
||
static async isRPCWarningVisble() { | ||
await TestHelpers.checkIfVisible(RPC_WARNING_BANNER_ID); | ||
async swipeToRPCTitleAndDismissKeyboard() { | ||
// Because in bitrise the keyboard is blocking the "Add" CTA | ||
await Gestures.waitAndTap(this.blockExplorer); | ||
} | ||
|
||
async tapRemoveNetwork(networkName) { | ||
const network = Matchers.getElementByText(networkName); | ||
await Gestures.tapAndLongPress(network); | ||
await Gestures.waitAndTap(this.removeNetwork); | ||
} | ||
} | ||
|
||
export default new NetworkView(); |
Oops, something went wrong.