Skip to content

e2e: added wallet connect tests #22512

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

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
241 changes: 241 additions & 0 deletions test/appium/tests/wallet/test_wallet_connect.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,241 @@
import re

import pytest
from selenium.common import TimeoutException

import marks
from base_test_case import MultipleSharedDeviceTestCase, create_shared_drivers
from users import transaction_senders
from views.sign_in_view import SignInView
from views.web_views.external_browser_view import BridgeStatusNetworkView, UniswapView


@marks.nightly
@pytest.mark.xdist_group(name="four_2") # ToDo: select group
class TestWalletConnectBaseChecks(MultipleSharedDeviceTestCase):

def prepare_devices(self):
self.drivers, self.loop = create_shared_drivers(1)
self.sign_in_view = SignInView(self.drivers[0])
self.sign_in_view.create_user()
self.home_view = self.sign_in_view.get_home_view()
self.username = self.home_view.get_username()
self.wallet_view = self.sign_in_view.wallet_tab.click()
self.status_dapp_url = 'https://bridge.status.network'
self.status_dapp_name = 'Status Network Bridge'
self.browser_view = BridgeStatusNetworkView(self.drivers[0])
self.account_1_name = 'Account 1'

def test_wallet_connect_disconnect(self):
self.wallet_view.just_fyi(
"Open %s in an external browser and try connecting to Status" % self.status_dapp_url)
self.browser_view.connect_status_wallet()
for text in self.status_dapp_name, self.status_dapp_url:
if not self.wallet_view.element_by_text(text).is_element_displayed():
self.errors.append(self.wallet_view,
"Text '%s' is not displayed when connecting to Status wallet" % text)
expected_data = {'Account': 'Account 1', 'Networks': 'Mainnet, Status'}
for key, value in expected_data.items():
try:
data = self.wallet_view.get_data_item_element_text(data_item_name=key)
if data != value:
self.errors.append(
self.wallet_view,
"%s value '%s' doesn't match expected '%s' when connecting to Status" % (key, data, value))
except TimeoutException:
self.errors.append(self.wallet_view, "%s data is not shown when connecting to Status" % key)
self.wallet_view.wallet_connect_button.click()
self.wallet_view.just_fyi("Check that %s is added to connected dApps")
self.wallet_view.get_account_element().click()
self.wallet_view.connected_dapps_button.click()
dapp_element = self.wallet_view.get_connected_dapp_element_by_name(dapp_name=self.status_dapp_name)
if dapp_element.is_element_displayed():
if dapp_element.url_text.text != self.status_dapp_url:
self.errors.append(self.wallet_view,
"DApp url %s is not shown for the connected dApp" % self.status_dapp_url)
else:
self.errors.append(self.wallet_view, "%s is not shown in connected dApps" % self.status_dapp_name)

self.wallet_view.just_fyi("Check that dApp is connected in the browser")
status_app_package = self.drivers[0].current_package
self.browser_view.open_browser()
if self.browser_view.connect_wallet_button.is_element_displayed():
self.errors.append(self.wallet_view, "DApp is not connected in the browser")

self.wallet_view.just_fyi("Check that dApp can be disconnected")
self.drivers[0].activate_app(status_app_package)
if dapp_element.is_element_displayed():
dapp_element.disconnect()
if not self.wallet_view.element_by_translation_id('no-dapps').is_element_displayed():
self.errors.append(self.wallet_view, "DApp was not disconnected")
self.errors.verify_no_errors()

def test_wallet_connect_decline_and_select_account(self):
self.wallet_view.navigate_to_wallet_view()
self.wallet_view.just_fyi("Add new wallet account")
new_account_name = "New Account"
self.wallet_view.add_regular_account(account_name=new_account_name)

self.wallet_view.just_fyi("Decline connection to Status dApp")
self.browser_view.connect_status_wallet()
self.wallet_view.wallet_decline_button.click()
self.browser_view.open_browser()
self.browser_view.element_by_text('Connection declined').wait_for_element()
self.browser_view.element_by_text('Try again').click()

self.wallet_view.just_fyi("Connect Status dApp with selecting newly created account")
self.wallet_view.select_account_to_connect_dapp(account_name=new_account_name)
self.wallet_view.wallet_connect_button.click()
self.wallet_view.navigate_to_wallet_view()
self.wallet_view.get_account_element(account_name=new_account_name).click()
self.wallet_view.connected_dapps_button.click()
dapp_element = self.wallet_view.get_connected_dapp_element_by_name(dapp_name=self.status_dapp_name)
if dapp_element.is_element_displayed():
if dapp_element.url_text.text != self.status_dapp_url:
self.errors.append(self.wallet_view,
"DApp url %s is not shown for the connected dApp" % self.status_dapp_url)
else:
self.errors.append(self.wallet_view, "%s is not shown in connected dApps" % self.status_dapp_name)
self.errors.verify_no_errors()

# def test_wallet_connect_multiprofile(self):


@marks.nightly
@pytest.mark.xdist_group(name="four_2865748") # ToDo: select group
class TestWalletConnectDifferentNetworks(MultipleSharedDeviceTestCase):

def prepare_devices(self):
self.drivers, self.loop = create_shared_drivers(1)
self.sign_in_view = SignInView(self.drivers[0])
self.sign_in_view.create_user()
self.home_view = self.sign_in_view.get_home_view()
self.username = self.home_view.get_username()
self.wallet_view = self.sign_in_view.wallet_tab.click()
self.status_dapp_url = 'https://bridge.status.network'
self.status_dapp_name = 'Status Network Bridge'
self.browser_view = BridgeStatusNetworkView(self.drivers[0])
self.account_1_name = 'Account 1'
self.profile_view = self.home_view.get_profile_view()
self.status_app_package = self.drivers[0].current_package

def test_wallet_connect_testnet_dapp(self):
self.home_view.navigate_back_to_home_view()
if self.home_view.testnet_mode_enabled:
self.home_view.just_fyi("Switch to mainnet")
self.home_view.profile_button.click()
self.profile_view.switch_network()
self.home_view.navigate_back_to_home_view()
self.home_view.just_fyi("Try connecting testnet dApp when being on mainnet")
self.browser_view.connect_status_wallet()
self.browser_view.open_browser()
self.browser_view.element_by_text('Connection declined').wait_for_element()

self.drivers[0].activate_app(self.status_app_package)
self.home_view.just_fyi("Switch to testnet")
self.home_view.profile_button.click()
self.profile_view.switch_network()
self.home_view.navigate_back_to_home_view()

self.wallet_view.just_fyi("Connect to dApp on testnet")
self.browser_view.connect_status_wallet()
self.wallet_view.wallet_connect_button.click()

self.wallet_view.just_fyi("Switch to mainnet and check that testnet dApp is not shown")
self.wallet_view.profile_button.click()
self.profile_view.switch_network()
self.wallet_view.wallet_tab.click()
self.wallet_view.get_account_element(account_name=self.account_1_name).click()
self.wallet_view.connected_dapps_button.click()
if not self.wallet_view.element_by_translation_id('no-dapps').is_element_displayed():
pytest.fail("%s dApp is shown on mainnet" % self.status_dapp_name)

def test_wallet_connect_mainnet_dapp(self):
self.home_view.navigate_back_to_home_view()
if self.home_view.testnet_mode_enabled:
self.home_view.just_fyi("Switch to mainnet")
self.home_view.profile_button.click()
self.profile_view.switch_network()
self.home_view.navigate_back_to_home_view()
self.wallet_view.just_fyi("Connect dApp on mainnet")
UniswapView(self.drivers[0]).connect_status_wallet()
# self.wallet_view.select_account_to_connect_dapp(account_name=self.account_1_name)
self.wallet_view.wallet_connect_button.click()
self.wallet_view.get_account_element(account_name=self.account_1_name).click()
self.wallet_view.connected_dapps_button.click()
dapp_name = 'Uniswap'
dapp_url = 'https://app.uniswap.org'
dapp_element = self.wallet_view.get_connected_dapp_element_by_name(dapp_name=dapp_name)
if dapp_element.is_element_displayed():
if dapp_element.url_text.text != dapp_url:
self.errors.append(self.wallet_view,
"DApp url %s is not shown for the connected dApp on mainnet" % dapp_url)
else:
self.errors.append(self.wallet_view, "%s is not shown in connected dApps on mainnet" % dapp_name)

self.wallet_view.just_fyi("Switch to testnet and check that mainnet dApp is not shown")
self.wallet_view.navigate_back_to_home_view()
profile_view = self.wallet_view.profile_button.click()
profile_view.switch_network()
self.wallet_view.wallet_tab.click()
self.wallet_view.get_account_element(account_name=self.account_1_name).click()
self.wallet_view.connected_dapps_button.click()
if dapp_element.is_element_displayed():
self.errors.append(self.wallet_view, "%s dApp is shown on testnet" % dapp_name)
self.errors.verify_no_errors()


@marks.nightly
class TestWalletConnectSignTransactions(MultipleSharedDeviceTestCase):

def prepare_devices(self):
self.drivers, self.loop = create_shared_drivers(1)
self.sign_in_view = SignInView(self.drivers[0])
self.user = transaction_senders['ETH_2']
self.user['wallet_address'] = '0x' + self.user['address']
self.sign_in_view.recover_access(passphrase=self.user['passphrase'])
self.home_view = self.sign_in_view.get_home_view()
# self.username = self.home_view.get_username()
self.wallet_view = self.sign_in_view.wallet_tab.click()
self.status_dapp_url = 'https://bridge.status.network/'
self.status_dapp_name = 'Status Network Bridge'
self.browser_view = BridgeStatusNetworkView(self.drivers[0])
self.account_1_name = 'Account 1'

def test_wallet_connect_sign_transaction(self):
self.wallet_view.just_fyi("Connect %s dApp" % self.status_dapp_url)
self.browser_view.connect_status_wallet()
self.wallet_view.wallet_connect_button.click()
self.wallet_view.just_fyi("Make bridge transaction from the connected dApp")
self.browser_view.open_browser()
self.browser_view.amount_input.send_keys('0.000001')
self.browser_view.bridge_button.scroll_and_click()
data_to_check = {
'Network': 'Sepolia',
'Max fees': r"<?[$|€]\d+.\d+",
'Est. time': r'~\d+ sec'
}
for key, expected_value in data_to_check.items():
try:
text = self.wallet_view.get_data_item_element_text(data_item_name=key)
if key == 'Max fees':
if not re.findall(expected_value, text):
self.errors.append(self.wallet_view,
"Max fee is not a number - %s on the Review Transaction page" % text)
elif key == 'Est. time':
if not re.findall(expected_value, text) or int(re.findall(r'\d+', text)[0]) > 60:
self.errors.append(
self.wallet_view, "Unexpected Est. time value - %s on the Review Transaction page" % text)
else:
if text != expected_value:
self.errors.append(
self.wallet_view,
"%s text %s doesn't match expected %s on the Review Transaction page" % (
key, text, expected_value))
except TimeoutException:
self.errors.append(self.wallet_view, "%s is not shown on the Review Transaction page" % key)
self.wallet_view.slide_and_confirm_with_password()
self.browser_view.open_browser()
if not self.browser_view.element_by_text('Transaction confirmed!').is_element_displayed(60):
self.errors.append(self.wallet_view, "Transaction was not confirmed")
self.errors.verify_no_errors()
9 changes: 9 additions & 0 deletions test/appium/views/base_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ def __init__(self, driver):
self.login_button = LogInButton(self.driver)
self.continue_button = Button(self.driver, accessibility_id='continue-button')
self.view_id_tracker = Text(self.driver, xpath="//*[@content-desc='view-id-tracker']/android.widget.TextView")
self.testnet_mode_enabled_element = BaseElement(self.driver, accessibility_id='Testnet mode enabled')

# Tabs
self.communities_tab = CommunitiesTab(self.driver)
Expand Down Expand Up @@ -245,6 +246,10 @@ def navigate_to_communities_view(self):
self.navigate_back_to_home_view()
self.communities_tab.click()

def navigate_to_wallet_view(self):
self.navigate_back_to_home_view()
self.wallet_tab.click()

def navigate_back_to_chat_view(self):
self.click_system_back_button_until_presence_of_element(self.get_chat_view().chat_message_input)

Expand Down Expand Up @@ -429,3 +434,7 @@ def pull_to_refresh(self):
"direction": "down",
"percent": 0.75
})

@property
def testnet_mode_enabled(self) -> bool:
return self.testnet_mode_enabled_element.is_element_displayed()
28 changes: 28 additions & 0 deletions test/appium/views/wallet_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from tests import common_password
from views.base_element import Button, EditBox, Text, BaseElement
from views.base_view import BaseView
from views.chat_view import ChatView
from views.home_view import HomeView
from views.sign_in_view import SignInView

Expand Down Expand Up @@ -137,6 +138,8 @@ def __init__(self, driver):
self.total_balance_text = Text(
self.driver, xpath="//*[@content-desc='network-dropdown']/preceding-sibling::android.widget.TextView")
self.network_drop_down = Button(self.driver, accessibility_id='network-dropdown')
self.connected_dapps_button = Button(
self.driver, xpath="//*[@content-desc='network-dropdown']/../following-sibling::*[@content-desc='icon']")
self.collectibles_tab = Button(self.driver, accessibility_id='collectibles-tab')
self.add_account_button = Button(self.driver, accessibility_id='add-account')

Expand Down Expand Up @@ -231,6 +234,13 @@ def __init__(self, driver):
self.driver, xpath="//*[@content-desc='expanded-collectible']//android.widget.ImageView")
self.send_from_collectible_info_button = Button(self.driver, accessibility_id="icon, Send")

# dApp adding
self.add_dapp_button = Button(self.driver, accessibility_id='connected-dapps-add')
self.wallet_connect_button = Button(self.driver, accessibility_id='wc-connect')
self.wallet_decline_button = Button(self.driver, accessibility_id='wc-deny-connection')
self.select_account_to_connect_dapp_button = Button(self.driver, accessibility_id='icon-right')
self.close_connected_dapps_button = Button(self.driver, accessibility_id='connected-dapps-close')

def set_network_in_wallet(self, network_name: str):
class NetworksCheckboxElement(Button):
def __init__(self, driver, index=0):
Expand Down Expand Up @@ -529,3 +539,21 @@ def get_balance(self, asset='Ether', fiat=False):
def get_receive_swap_amount(self, decimals=18):
self.just_fyi("Getting swap Receive amount for on review page")
return self.round_amount_float(self.swap_receive_amount_summary_text.text.split()[0], decimals)

def get_connected_dapp_element_by_name(self, dapp_name: str):
class ConnectedDAppElement(BaseElement):
def __init__(self, driver, dapp_name):
self.locator = "//*[contains(@content-desc,'dapp-')][*[@text='%s']]" % dapp_name
super().__init__(driver, xpath=self.locator)
self.url_text = Text(self.driver, xpath=self.locator + "//*[starts-with(@text,'http')]")
self.disconnect_button = Button(self.driver, xpath=self.locator + "//*[@content-desc='icon']")

def disconnect(self):
self.disconnect_button.click()
ChatView(self.driver).confirm_block_contact_button.click()

return ConnectedDAppElement(self.driver, dapp_name)

def select_account_to_connect_dapp(self, account_name: str):
self.select_account_to_connect_dapp_button.click()
Button(self.driver, xpath="//*[@content-desc='container']/*[@text='%s']" % account_name).click()
Loading