-
Notifications
You must be signed in to change notification settings - Fork 5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: [POM] Create base classes and methods for bitcoin e2e tests (#2…
…9235) ## **Description** - Create a Bitcoin home page class and methods. The locators on homepage for Bitcoin accounts are different from the locators for other accounts. I think the best way to implement this is to create a `BitcoinHomepage` class that extends from `Homepage`. This approach will be flexible and easier to implement when we have new modifications for Bitcoin account functionalities. - Migrate bitcoin account e2e tests to TS and Page Object Model ``` test/e2e/flask/btc/btc-account-overview.spec.ts test/e2e/flask/btc/btc-dapp-connection.spec.ts test/e2e/flask/btc/btc-experimental-settings.spec.ts ``` [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/27155?quickstart=1) ## **Related issues** ## **Manual testing steps** Check code readability, make sure tests pass. ## **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** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [x] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [x] 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. --------- Co-authored-by: seaona <[email protected]>
- Loading branch information
Showing
13 changed files
with
253 additions
and
144 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
import HomePage from './homepage'; | ||
|
||
class BitcoinHomepage extends HomePage { | ||
protected readonly balance = | ||
'[data-testid="coin-overview__primary-currency"]'; | ||
|
||
private readonly bridgeButton = { | ||
text: 'Bridge', | ||
tag: 'button', | ||
}; | ||
|
||
private readonly buySellButton = '[data-testid="coin-overview-buy"]'; | ||
|
||
private readonly receiveButton = '[data-testid="coin-overview-receive"]'; | ||
|
||
protected readonly sendButton = '[data-testid="coin-overview-send"]'; | ||
|
||
private readonly swapButton = { | ||
text: 'Swap', | ||
tag: 'button', | ||
}; | ||
|
||
async check_pageIsLoaded(): Promise<void> { | ||
try { | ||
await this.driver.waitForMultipleSelectors([ | ||
this.sendButton, | ||
this.buySellButton, | ||
this.receiveButton, | ||
]); | ||
} catch (e) { | ||
console.log('Timeout while waiting for bitcoin homepage to be loaded', e); | ||
throw e; | ||
} | ||
console.log('Bitcoin homepage is loaded'); | ||
} | ||
|
||
/** | ||
* Checks if the bridge button is enabled on bitcoin account homepage. | ||
* | ||
*/ | ||
async check_isBridgeButtonEnabled(): Promise<boolean> { | ||
try { | ||
await this.driver.findClickableElement(this.bridgeButton, 1000); | ||
} catch (e) { | ||
console.log('Bridge button not enabled', e); | ||
return false; | ||
} | ||
console.log('Bridge button is enabled'); | ||
return true; | ||
} | ||
|
||
/** | ||
* Checks if the buy/sell button is enabled on bitcoin account homepage. | ||
*/ | ||
async check_isBuySellButtonEnabled(): Promise<boolean> { | ||
try { | ||
await this.driver.findClickableElement(this.buySellButton, 1000); | ||
} catch (e) { | ||
console.log('Buy/Sell button not enabled', e); | ||
return false; | ||
} | ||
console.log('Buy/Sell button is enabled'); | ||
return true; | ||
} | ||
|
||
/** | ||
* Checks if the expected bitcoin balance is displayed on homepage. | ||
* | ||
* @param expectedBalance - The expected bitcoin balance to be displayed. Defaults to '0'. | ||
*/ | ||
async check_isExpectedBitcoinBalanceDisplayed( | ||
expectedBalance: number = 0, | ||
): Promise<void> { | ||
console.log( | ||
`Check if expected bitcoin balance is displayed: ${expectedBalance} BTC`, | ||
); | ||
await this.driver.waitForSelector({ | ||
css: this.balance, | ||
text: `${expectedBalance}BTC`, | ||
}); | ||
} | ||
|
||
/** | ||
* Checks if the receive button is enabled on bitcoin account homepage. | ||
*/ | ||
async check_isReceiveButtonEnabled(): Promise<boolean> { | ||
try { | ||
await this.driver.findClickableElement(this.receiveButton, 1000); | ||
} catch (e) { | ||
console.log('Receive button not enabled', e); | ||
return false; | ||
} | ||
console.log('Receive button is enabled'); | ||
return true; | ||
} | ||
|
||
/** | ||
* Checks if the swap button is enabled on bitcoin account homepage. | ||
*/ | ||
async check_isSwapButtonEnabled(): Promise<boolean> { | ||
try { | ||
await this.driver.findClickableElement(this.swapButton, 1000); | ||
} catch (e) { | ||
console.log('Swap button not enabled', e); | ||
return false; | ||
} | ||
console.log('Swap button is enabled'); | ||
return true; | ||
} | ||
} | ||
|
||
export default BitcoinHomepage; |
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
Oops, something went wrong.