-
-
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.
test: 1452 refactor modal pages batch 2 (#8257)
## **Description** We are aiming to refactor the page objects in the modal folder so that they strictly follow the page object model pattern. This would aide in providing more readable and help standardize the way we create our tests. Because of the amount of files inside of the modal folder, the scope was divided into a batch of 4. ## **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
bad7725
commit 1bec601
Showing
25 changed files
with
183 additions
and
146 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
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,38 +1,40 @@ | ||
import TestHelpers from '../../helpers'; | ||
import { | ||
DeleteWalletModalSelectorsIDs, | ||
DeleteWalletModalSelectorsText, | ||
} from '../../selectors/Modals/DeleteWalletModal.selectors'; | ||
import { CommonSelectorsText } from '../../selectors/Common.selectors'; | ||
import Matchers from '../../utils/Matchers'; | ||
import Gestures from '../../utils/Gestures'; | ||
|
||
export default class DeleteWalletModal { | ||
static async tapIUnderstandButton() { | ||
await TestHelpers.delay(2000); | ||
await TestHelpers.tapByText( | ||
class DeleteWalletModal { | ||
get container() { | ||
return Matchers.getElementByID(DeleteWalletModalSelectorsIDs.CONTAINER); | ||
} | ||
|
||
get understandButton() { | ||
return Matchers.getElementByText( | ||
DeleteWalletModalSelectorsText.UNDERSTAND_BUTTON, | ||
); | ||
} | ||
|
||
static async tapCancelButton() { | ||
await TestHelpers.tapByText(CommonSelectorsText.CANCEL_BUTTON); | ||
get deleteWalletButton() { | ||
return Matchers.getElementByText(DeleteWalletModalSelectorsText.DELETE_MY); | ||
} | ||
static async tapDeleteMyWalletButton() { | ||
await TestHelpers.tapByText(DeleteWalletModalSelectorsText.DELETE_MY); | ||
|
||
get deleteInput() { | ||
return Matchers.getElementByID(DeleteWalletModalSelectorsIDs.INPUT); | ||
} | ||
static async typeDeleteInInputBox() { | ||
await TestHelpers.typeTextAndHideKeyboard( | ||
DeleteWalletModalSelectorsIDs.INPUT, | ||
'delete', | ||
); | ||
|
||
async tapIUnderstandButton() { | ||
await Gestures.waitAndTap(this.understandButton); | ||
} | ||
|
||
static async isVisible() { | ||
await TestHelpers.checkIfVisible(DeleteWalletModalSelectorsIDs.CONTAINER); | ||
async tapDeleteMyWalletButton() { | ||
await Gestures.waitAndTap(this.deleteWalletButton); | ||
} | ||
|
||
static async isNotVisible() { | ||
await TestHelpers.checkIfNotVisible( | ||
DeleteWalletModalSelectorsIDs.CONTAINER, | ||
); | ||
async typeDeleteInInputBox() { | ||
await Gestures.typeTextAndHideKeyboard(this.deleteInput, 'delete'); | ||
} | ||
} | ||
|
||
export default new DeleteWalletModal(); |
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,32 +1,43 @@ | ||
import TestHelpers from '../../helpers'; | ||
import { | ||
DETAILS_MODAL_TITLE, | ||
DETAILS_MODAL_STATUS_CONFIRMED, | ||
DETAILS_MODAL_CLOSE_ICON, | ||
} from '../../../wdio/screen-objects/testIDs/Components/DetailsModal.js'; | ||
import { TransactionDetailsModalSelectorsText } from '../../selectors/Modals/TransactionDetailsModal.selectors'; | ||
TransactionDetailsModalSelectorsText, | ||
TransactionDetailsModalSelectorsIDs, | ||
} from '../../selectors/Modals/TransactionDetailsModal.selectors'; | ||
import Matchers from '../../utils/Matchers'; | ||
import Gestures from '../../utils/Gestures'; | ||
import { CommonSelectorsIDs } from '../../selectors/Common.selectors'; | ||
|
||
export default class DetailsModal { | ||
static async isTitleVisible(sourceToken, destinationToken) { | ||
let title = TransactionDetailsModalSelectorsText.TITLE; | ||
title = title.replace('{{sourceToken}}', sourceToken); | ||
title = title.replace('{{destinationToken}}', destinationToken); | ||
await TestHelpers.checkIfElementHasString(DETAILS_MODAL_TITLE, title); | ||
class DetailsModal { | ||
get title() { | ||
return Matchers.getElementByID(TransactionDetailsModalSelectorsIDs.TITLE); | ||
} | ||
|
||
get closeIcon() { | ||
return Matchers.getElementByID( | ||
TransactionDetailsModalSelectorsIDs.CLOSE_ICON, | ||
); | ||
} | ||
|
||
static async isStatusCorrect(status) { | ||
await TestHelpers.checkIfElementHasString( | ||
DETAILS_MODAL_STATUS_CONFIRMED, | ||
status, | ||
get statusConfirmed() { | ||
return Matchers.getElementIDWithAncestor( | ||
CommonSelectorsIDs.STATUS_CONFIRMED, | ||
TransactionDetailsModalSelectorsIDs.BODY, | ||
); | ||
} | ||
|
||
static async tapOnCloseIcon() { | ||
generateExpectedTitle(sourceToken, destinationToken) { | ||
let title = TransactionDetailsModalSelectorsText.TITLE; | ||
title = title.replace('{{sourceToken}}', sourceToken); | ||
title = title.replace('{{destinationToken}}', destinationToken); | ||
return title; | ||
} | ||
|
||
async tapOnCloseIcon() { | ||
try { | ||
await TestHelpers.waitAndTap(DETAILS_MODAL_CLOSE_ICON); | ||
await TestHelpers.delay(1000); | ||
await Gestures.waitAndTap(this.closeIcon); | ||
} catch { | ||
// | ||
} | ||
} | ||
} | ||
|
||
export default new DetailsModal(); |
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,37 +1,44 @@ | ||
import TestHelpers from '../../helpers'; | ||
import { | ||
NetworkAddedModalSelectorsIDs, | ||
NetworkAddedModalSelectorsText, | ||
} from '../../selectors/Modals/NetworkAddedModal.selectors'; | ||
import Matchers from '../../utils/Matchers'; | ||
import Gestures from '../../utils/Gestures'; | ||
|
||
export default class NetworkAddedModal { | ||
static async tapSwitchToNetwork() { | ||
await TestHelpers.tap(NetworkAddedModalSelectorsIDs.SWITCH_NETWORK_BUTTON); | ||
class NetworkAddedModal { | ||
get switchNetwork() { | ||
return Matchers.getElementByText( | ||
NetworkAddedModalSelectorsText.SWITCH_NETWORK, | ||
); | ||
} | ||
static async tapCloseButton() { | ||
await TestHelpers.tap(NetworkAddedModalSelectorsIDs.CLOSE_NETWORK_BUTTON); | ||
|
||
get switchNetworkButton() { | ||
return device.getPlatform() === 'android' | ||
? Matchers.getElementByLabel( | ||
NetworkAddedModalSelectorsIDs.SWITCH_NETWORK_BUTTON, | ||
) | ||
: Matchers.getElementByID( | ||
NetworkAddedModalSelectorsIDs.SWITCH_NETWORK_BUTTON, | ||
); | ||
} | ||
|
||
static async isVisible() { | ||
await TestHelpers.checkIfElementWithTextIsVisible( | ||
NetworkAddedModalSelectorsText.SWITCH_NETWORK, | ||
); | ||
get closeNetworkButton() { | ||
return device.getPlatform() === 'android' | ||
? Matchers.getElementByLabel( | ||
NetworkAddedModalSelectorsIDs.CLOSE_NETWORK_BUTTON, | ||
) | ||
: Matchers.getElementByID( | ||
NetworkAddedModalSelectorsIDs.CLOSE_NETWORK_BUTTON, | ||
); | ||
} | ||
static async isNotVisible() { | ||
await TestHelpers.checkIfElementWithTextIsVisible( | ||
NetworkAddedModalSelectorsText.SWITCH_NETWORK, | ||
); | ||
|
||
async tapSwitchToNetwork() { | ||
await Gestures.waitAndTap(this.switchNetworkButton); | ||
} | ||
|
||
static async tapSwitchToNetworkButton() { | ||
if (device.getPlatform() === 'android') { | ||
await TestHelpers.waitAndTapByLabel( | ||
NetworkAddedModalSelectorsIDs.SWITCH_NETWORK_BUTTON, | ||
); | ||
} else { | ||
await TestHelpers.tap( | ||
NetworkAddedModalSelectorsIDs.SWITCH_NETWORK_BUTTON, | ||
); | ||
} | ||
async tapCloseButton() { | ||
await Gestures.waitAndTap(this.closeNetworkButton); | ||
} | ||
} | ||
|
||
export default new NetworkAddedModal(); |
Oops, something went wrong.