-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
test: migrates the WalletConnect performance test #29785
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
6eb79a1
test: migrates the WalletConnect performance test
christopherferreira9 cdc8842
test: removes redundant context switch on Android
christopherferreira9 fb6b7d9
test: fixes context switching on Android
christopherferreira9 a514014
test: increases timeout for test
christopherferreira9 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,248 @@ | ||
| import { | ||
| asPlaywrightElement, | ||
| encapsulated, | ||
| encapsulatedAction, | ||
| EncapsulatedElementType, | ||
| PlatformDetector, | ||
| PlaywrightAssertions, | ||
| PlaywrightGestures, | ||
| PlaywrightMatchers, | ||
| sleep, | ||
| UnifiedGestures, | ||
| } from '../../framework'; | ||
|
|
||
| class UniswapDapp { | ||
| private getByXPath(xpath: string): EncapsulatedElementType { | ||
| return encapsulated({ | ||
| appium: () => PlaywrightMatchers.getLazyElementByXPath(xpath), | ||
| }); | ||
| } | ||
|
|
||
| get connectButton(): EncapsulatedElementType { | ||
| return encapsulated({ | ||
| appium: { | ||
| android: () => | ||
| PlaywrightMatchers.getLazyElementByXPath( | ||
| '//*[@data-testid="navbar-connect-wallet"]', | ||
| ), | ||
| ios: () => | ||
| PlaywrightMatchers.getElementById('Connect', { exact: true }), | ||
| }, | ||
| }); | ||
| } | ||
|
|
||
| get walletConnect(): EncapsulatedElementType { | ||
| return encapsulated({ | ||
| appium: { | ||
| android: () => | ||
| PlaywrightMatchers.getElementByXPath( | ||
| '//*[contains(normalize-space(.), "WalletConnect")]', | ||
| ), | ||
| ios: () => | ||
| PlaywrightMatchers.getElementByXPath( | ||
| '//XCUIElementTypeStaticText[@name="WalletConnect"]', | ||
| ), | ||
| }, | ||
| }); | ||
| } | ||
|
|
||
| get metaMaskWalletOption(): EncapsulatedElementType { | ||
| return encapsulated({ | ||
| appium: { | ||
| android: () => | ||
| PlaywrightMatchers.getLazyElementByXPath( | ||
| '//android.widget.Button[@text="MetaMask MetaMask"]', | ||
| ), | ||
| ios: () => | ||
| PlaywrightMatchers.getElementById('MetaMask MetaMask', { | ||
| exact: true, | ||
| }), | ||
| }, | ||
| }); | ||
| } | ||
|
|
||
| get metaMaskDeeplinkButton(): EncapsulatedElementType { | ||
| return encapsulated({ | ||
| appium: { | ||
| android: () => | ||
| PlaywrightMatchers.getLazyElementByXPath( | ||
| '//android.widget.TextView[@text="MetaMask"]', | ||
| ), | ||
| ios: () => | ||
| PlaywrightMatchers.getLazyElementByXPath( | ||
| '//XCUIElementTypeOther[@name="textfield"]', | ||
| ), | ||
| }, | ||
| }); | ||
| } | ||
|
|
||
| get uniswapDialog(): EncapsulatedElementType { | ||
| return this.getByXPath('//android.app.AlertDialog'); | ||
| } | ||
|
|
||
| get uniswapIcon(): EncapsulatedElementType { | ||
| return encapsulated({ | ||
| appium: () => PlaywrightMatchers.getElementById('account-icon'), | ||
| }); | ||
| } | ||
|
|
||
| get solanaPopup(): EncapsulatedElementType { | ||
| return encapsulated({ | ||
| appium: () => | ||
| PlaywrightMatchers.getElementByText('Use Solana on Uniswap'), | ||
| }); | ||
| } | ||
|
|
||
| get SolanaPopup(): EncapsulatedElementType { | ||
| return this.solanaPopup; | ||
| } | ||
|
|
||
| async waitForConnectButtonVisible(timeoutMs = 20000): Promise<void> { | ||
| await this.waitForElementVisible( | ||
| this.connectButton, | ||
| timeoutMs, | ||
| 'UniswapDapp: connect button not visible', | ||
| ); | ||
| } | ||
|
|
||
| async waitForWalletConnectVisible(timeoutMs = 15000): Promise<void> { | ||
| await this.waitForElementVisible( | ||
| this.walletConnect, | ||
| timeoutMs, | ||
| 'UniswapDapp: WalletConnect option not visible', | ||
| ); | ||
| } | ||
|
|
||
| async tapConnect(): Promise<void> { | ||
| await PlaywrightGestures.waitAndTap( | ||
| await asPlaywrightElement(this.connectButton), | ||
| { | ||
| delay: 3000, // 3 seconds - DOM might not be ready yet | ||
| }, | ||
| ); | ||
| } | ||
|
|
||
| async tapOnWalletConnect(): Promise<void> { | ||
| await PlaywrightGestures.waitAndTap( | ||
| await asPlaywrightElement(this.walletConnect), | ||
| { | ||
| delay: 3000, // 3 seconds - DOM might not be ready yet | ||
| }, | ||
| ); | ||
| } | ||
|
|
||
| async connectWithMetaMask(): Promise<void> { | ||
| await this.waitForConnectButtonVisible(); | ||
| await this.tapConnect(); | ||
| await this.waitForWalletConnectVisible(); | ||
| await this.tapOnWalletConnect(); | ||
| } | ||
|
|
||
| async connectIOS(timeoutMs = 20000): Promise<void> { | ||
| await this.waitForConnectButtonVisible(timeoutMs); | ||
| await this.tapConnect(); | ||
| } | ||
|
|
||
| async selectWalletConnectOption(): Promise<void> { | ||
| await this.tapOnWalletConnect(); | ||
| } | ||
|
|
||
| async tapOnMetaMaskWalletOption(): Promise<void> { | ||
| await UnifiedGestures.waitAndTap(this.metaMaskWalletOption, { | ||
| description: 'tap MetaMask wallet option', | ||
| }); | ||
| } | ||
|
|
||
| async tapOnMetaMaskDeeplinkButton(): Promise<void> { | ||
| await encapsulatedAction({ | ||
| appium: async () => { | ||
| await sleep(2000); | ||
| await PlaywrightGestures.waitAndTap( | ||
| await asPlaywrightElement(this.metaMaskDeeplinkButton), | ||
| ); | ||
| }, | ||
| }); | ||
| } | ||
|
|
||
| async tapOnMetaMaskWalletOptionAndOpenDeeplink(): Promise<void> { | ||
| await this.tapOnMetaMaskWalletOption(); | ||
| if (PlatformDetector.isAndroid()) { | ||
| await this.tapOnMetaMaskDeeplinkButton(); | ||
| } | ||
| } | ||
|
|
||
| async isUniswapDisplayed(timeoutMs = 30000): Promise<void> { | ||
| await encapsulatedAction({ | ||
| appium: async () => { | ||
| if (PlatformDetector.isAndroid()) { | ||
| const dialogVisible = await this.isElementVisible( | ||
| this.uniswapDialog, | ||
| timeoutMs, | ||
| ); | ||
|
|
||
| if (dialogVisible) { | ||
| return; | ||
| } | ||
|
|
||
| const iconVisible = await this.isElementVisible( | ||
| this.uniswapIcon, | ||
| timeoutMs, | ||
| ); | ||
|
|
||
| if (!iconVisible) { | ||
| throw new Error( | ||
| 'Neither Uniswap dialog nor account icon is visible in Android context', | ||
| ); | ||
| } | ||
|
|
||
| return; | ||
| } | ||
|
|
||
| await this.waitForElementVisible( | ||
| this.solanaPopup, | ||
| timeoutMs, | ||
| 'UniswapDapp: Solana popup not visible', | ||
| ); | ||
| }, | ||
| }); | ||
| } | ||
|
|
||
| private async waitForElementVisible( | ||
| targetElement: EncapsulatedElementType, | ||
| timeoutMs: number, | ||
| timeoutMsg: string, | ||
| ): Promise<void> { | ||
| await encapsulatedAction({ | ||
| appium: async () => { | ||
| await PlaywrightAssertions.expectConditionWithRetry( | ||
| async () => { | ||
| const resolvedElement = await asPlaywrightElement(targetElement); | ||
| await resolvedElement.waitForDisplayed({ | ||
| timeout: timeoutMs, | ||
| timeoutMsg, | ||
| }); | ||
| }, | ||
| { | ||
| maxRetries: 5, | ||
| description: timeoutMsg, | ||
| }, | ||
| ); | ||
| }, | ||
| }); | ||
| } | ||
|
|
||
| private async isElementVisible( | ||
| targetElement: EncapsulatedElementType, | ||
| timeoutMs: number, | ||
| ): Promise<boolean> { | ||
| try { | ||
| const resolvedElement = await asPlaywrightElement(targetElement); | ||
| await resolvedElement.waitForDisplayed({ timeout: timeoutMs }); | ||
| return true; | ||
| } catch { | ||
| return false; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| export default new UniswapDapp(); | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused
SolanaPopupgetter is dead codeLow Severity
The PascalCase
SolanaPopupgetter is an alias forsolanaPopupthat is never referenced anywhere in the codebase. It was carried over from the old wdioUniswapDapp.js(which usedthis.SolanaPopup), but the new code exclusively uses the camelCasesolanaPopup(inisUniswapDisplayed). This is dead code that adds confusion, especially since PascalCase getters are unconventional in TypeScript.Reviewed by Cursor Bugbot for commit a514014. Configure here.