Skip to content

Commit 0900eb9

Browse files
committed
e2e: added wallet connect tests
1 parent 4b226fd commit 0900eb9

File tree

5 files changed

+366
-0
lines changed

5 files changed

+366
-0
lines changed

test/appium/support/testrail_report.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ def get_regression_cases(self):
115115
test_categories['android_versions'] = 63809
116116
test_categories['profile'] = 63854
117117
test_categories['real_tx'] = 63867
118+
test_categories['wallet_connect'] = 64122
118119

119120
case_ids = list()
120121
for arg in argv:
Lines changed: 246 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,246 @@
1+
import re
2+
3+
import pytest
4+
from selenium.common import TimeoutException
5+
6+
import marks
7+
from base_test_case import MultipleSharedDeviceTestCase, create_shared_drivers
8+
from users import transaction_senders
9+
from views.sign_in_view import SignInView
10+
from views.web_views.external_browser_view import BridgeStatusNetworkView, UniswapView
11+
12+
13+
@marks.nightly
14+
@pytest.mark.xdist_group(name="two_1")
15+
class TestWalletConnectBaseChecks(MultipleSharedDeviceTestCase):
16+
17+
def prepare_devices(self):
18+
self.drivers, self.loop = create_shared_drivers(1)
19+
self.sign_in_view = SignInView(self.drivers[0])
20+
self.sign_in_view.create_user()
21+
self.home_view = self.sign_in_view.get_home_view()
22+
self.username = self.home_view.get_username()
23+
self.wallet_view = self.sign_in_view.wallet_tab.click()
24+
self.status_dapp_url = 'https://bridge.status.network'
25+
self.status_dapp_name = 'Status Network Bridge'
26+
self.browser_view = BridgeStatusNetworkView(self.drivers[0])
27+
self.account_1_name = 'Account 1'
28+
29+
@marks.testrail_id(742897)
30+
def test_wallet_connect_disconnect(self):
31+
self.wallet_view.just_fyi(
32+
"Open %s in an external browser and try connecting to Status" % self.status_dapp_url)
33+
self.browser_view.connect_status_wallet()
34+
for text in self.status_dapp_name, self.status_dapp_url:
35+
if not self.wallet_view.element_by_text(text).is_element_displayed():
36+
self.errors.append(self.wallet_view,
37+
"Text '%s' is not displayed when connecting to Status wallet" % text)
38+
expected_data = {'Account': 'Account 1', 'Networks': 'Mainnet, Status'}
39+
for key, value in expected_data.items():
40+
try:
41+
data = self.wallet_view.get_data_item_element_text(data_item_name=key)
42+
if data != value:
43+
self.errors.append(
44+
self.wallet_view,
45+
"%s value '%s' doesn't match expected '%s' when connecting to Status" % (key, data, value))
46+
except TimeoutException:
47+
self.errors.append(self.wallet_view, "%s data is not shown when connecting to Status" % key)
48+
self.wallet_view.wallet_connect_button.click()
49+
self.wallet_view.just_fyi("Check that %s is added to connected dApps")
50+
self.wallet_view.get_account_element().click()
51+
self.wallet_view.connected_dapps_button.click()
52+
dapp_element = self.wallet_view.get_connected_dapp_element_by_name(dapp_name=self.status_dapp_name)
53+
if dapp_element.is_element_displayed():
54+
if dapp_element.url_text.text != self.status_dapp_url:
55+
self.errors.append(self.wallet_view,
56+
"DApp url %s is not shown for the connected dApp" % self.status_dapp_url)
57+
else:
58+
self.errors.append(self.wallet_view, "%s is not shown in connected dApps" % self.status_dapp_name)
59+
60+
self.wallet_view.just_fyi("Check that dApp is connected in the browser")
61+
status_app_package = self.drivers[0].current_package
62+
self.browser_view.open_browser()
63+
if self.browser_view.connect_wallet_button.is_element_displayed():
64+
self.errors.append(self.wallet_view, "DApp is not connected in the browser")
65+
66+
self.wallet_view.just_fyi("Check that dApp can be disconnected")
67+
self.drivers[0].activate_app(status_app_package)
68+
if dapp_element.is_element_displayed():
69+
dapp_element.disconnect()
70+
if not self.wallet_view.element_by_translation_id('no-dapps').is_element_displayed():
71+
self.errors.append(self.wallet_view, "DApp was not disconnected")
72+
self.errors.verify_no_errors()
73+
74+
@marks.testrail_id(742898)
75+
def test_wallet_connect_decline_and_select_account(self):
76+
self.wallet_view.navigate_to_wallet_view()
77+
self.wallet_view.just_fyi("Add new wallet account")
78+
new_account_name = "New Account"
79+
self.wallet_view.add_regular_account(account_name=new_account_name)
80+
81+
self.wallet_view.just_fyi("Decline connection to Status dApp")
82+
self.browser_view.open_browser()
83+
if self.browser_view.connect_wallet_button.is_element_displayed():
84+
refresh = False
85+
else:
86+
refresh = True
87+
self.browser_view.connect_status_wallet(refresh=refresh)
88+
self.wallet_view.wallet_decline_button.click()
89+
self.browser_view.open_browser()
90+
self.browser_view.element_by_text('Connection declined').wait_for_element()
91+
self.browser_view.element_by_text('Try again').click()
92+
93+
self.wallet_view.just_fyi("Connect Status dApp with selecting newly created account")
94+
self.wallet_view.select_account_to_connect_dapp(account_name=new_account_name)
95+
self.wallet_view.wallet_connect_button.click()
96+
self.wallet_view.navigate_to_wallet_view()
97+
self.wallet_view.get_account_element(account_name=new_account_name).click()
98+
self.wallet_view.connected_dapps_button.click()
99+
dapp_element = self.wallet_view.get_connected_dapp_element_by_name(dapp_name=self.status_dapp_name)
100+
if dapp_element.is_element_displayed():
101+
if dapp_element.url_text.text != self.status_dapp_url:
102+
self.errors.append(self.wallet_view,
103+
"DApp url %s is not shown for the connected dApp" % self.status_dapp_url)
104+
else:
105+
self.errors.append(self.wallet_view, "%s is not shown in connected dApps" % self.status_dapp_name)
106+
self.errors.verify_no_errors()
107+
108+
109+
@marks.nightly
110+
@pytest.mark.xdist_group(name="two_1")
111+
class TestWalletConnectDifferentNetworks(MultipleSharedDeviceTestCase):
112+
113+
def prepare_devices(self):
114+
self.drivers, self.loop = create_shared_drivers(1)
115+
self.sign_in_view = SignInView(self.drivers[0])
116+
self.sign_in_view.create_user()
117+
self.home_view = self.sign_in_view.get_home_view()
118+
self.username = self.home_view.get_username()
119+
self.wallet_view = self.sign_in_view.wallet_tab.click()
120+
self.status_dapp_url = 'https://bridge.status.network'
121+
self.status_dapp_name = 'Status Network Bridge'
122+
self.browser_view = BridgeStatusNetworkView(self.drivers[0])
123+
self.account_1_name = 'Account 1'
124+
self.profile_view = self.home_view.get_profile_view()
125+
self.status_app_package = self.drivers[0].current_package
126+
127+
@marks.testrail_id(742899)
128+
def test_wallet_connect_testnet_dapp(self):
129+
self.home_view.navigate_back_to_home_view()
130+
if self.home_view.testnet_mode_enabled:
131+
self.home_view.just_fyi("Switch to mainnet")
132+
self.home_view.profile_button.click()
133+
self.profile_view.switch_network()
134+
self.home_view.navigate_back_to_home_view()
135+
self.home_view.just_fyi("Try connecting testnet dApp when being on mainnet")
136+
self.browser_view.connect_status_wallet()
137+
self.browser_view.open_browser()
138+
self.browser_view.element_by_text('Connection declined').wait_for_element()
139+
self.browser_view.connect_wallet_button.click()
140+
141+
self.drivers[0].activate_app(self.status_app_package)
142+
self.home_view.just_fyi("Switch to testnet")
143+
self.home_view.profile_button.click()
144+
self.profile_view.switch_network()
145+
self.home_view.navigate_back_to_home_view()
146+
147+
self.wallet_view.just_fyi("Connect to dApp on testnet")
148+
self.browser_view.connect_status_wallet(refresh=False)
149+
self.wallet_view.wallet_connect_button.click()
150+
151+
self.wallet_view.just_fyi("Switch to mainnet and check that testnet dApp is not shown")
152+
self.wallet_view.profile_button.click()
153+
self.profile_view.switch_network()
154+
self.wallet_view.navigate_to_wallet_view()
155+
self.wallet_view.get_account_element(account_name=self.account_1_name).click()
156+
self.wallet_view.connected_dapps_button.click()
157+
if not self.wallet_view.element_by_translation_id('no-dapps').is_element_displayed():
158+
pytest.fail("%s dApp is shown on mainnet" % self.status_dapp_name)
159+
160+
@marks.testrail_id(742900)
161+
def test_wallet_connect_mainnet_dapp(self):
162+
self.home_view.navigate_back_to_home_view()
163+
if self.home_view.testnet_mode_enabled:
164+
self.home_view.just_fyi("Switch to mainnet")
165+
self.home_view.profile_button.click()
166+
self.profile_view.switch_network()
167+
self.home_view.navigate_back_to_home_view()
168+
self.wallet_view.just_fyi("Connect dApp on mainnet")
169+
UniswapView(self.drivers[0]).connect_status_wallet()
170+
self.wallet_view.wallet_connect_button.click()
171+
self.wallet_view.get_account_element(account_name=self.account_1_name).click()
172+
self.wallet_view.connected_dapps_button.click_until_presence_of_element(self.wallet_view.add_dapp_button)
173+
dapp_name = 'Uniswap'
174+
dapp_url = 'https://app.uniswap.org'
175+
dapp_element = self.wallet_view.get_connected_dapp_element_by_name(dapp_name=dapp_name)
176+
if dapp_element.is_element_displayed():
177+
if dapp_element.url_text.text != dapp_url:
178+
self.errors.append(self.wallet_view,
179+
"DApp url %s is not shown for the connected dApp on mainnet" % dapp_url)
180+
else:
181+
self.errors.append(self.wallet_view, "%s is not shown in connected dApps on mainnet" % dapp_name)
182+
183+
self.wallet_view.just_fyi("Switch to testnet and check that mainnet dApp is not shown")
184+
self.wallet_view.navigate_back_to_home_view()
185+
profile_view = self.wallet_view.profile_button.click()
186+
profile_view.switch_network()
187+
self.wallet_view.navigate_to_wallet_view()
188+
self.wallet_view.get_account_element(account_name=self.account_1_name).click()
189+
self.wallet_view.connected_dapps_button.click()
190+
if dapp_element.is_element_displayed():
191+
self.errors.append(self.wallet_view, "%s dApp is shown on testnet" % dapp_name)
192+
self.errors.verify_no_errors()
193+
194+
195+
@marks.nightly
196+
@pytest.mark.xdist_group(name="two_1")
197+
class TestWalletConnectSignTransactions(MultipleSharedDeviceTestCase):
198+
199+
def prepare_devices(self):
200+
self.drivers, self.loop = create_shared_drivers(1)
201+
self.sign_in_view = SignInView(self.drivers[0])
202+
self.user = transaction_senders['ETH_2']
203+
self.user['wallet_address'] = '0x' + self.user['address']
204+
self.sign_in_view.recover_access(passphrase=self.user['passphrase'])
205+
self.wallet_view = self.sign_in_view.wallet_tab.click()
206+
self.status_dapp_url = 'https://bridge.status.network/'
207+
self.browser_view = BridgeStatusNetworkView(self.drivers[0])
208+
209+
@marks.testrail_id(742901)
210+
def test_wallet_connect_sign_transaction(self):
211+
self.wallet_view.just_fyi("Connect %s dApp" % self.status_dapp_url)
212+
self.browser_view.connect_status_wallet()
213+
self.wallet_view.wallet_connect_button.click()
214+
self.wallet_view.just_fyi("Make bridge transaction from the connected dApp")
215+
self.browser_view.open_browser()
216+
self.browser_view.amount_input.send_keys('0.000001')
217+
self.browser_view.bridge_button.scroll_and_click()
218+
data_to_check = {
219+
'Network': 'Sepolia',
220+
'Max fees': r"<?[$|€]\d+.\d+",
221+
'Est. time': r'>\d+ sec'
222+
}
223+
for key, expected_value in data_to_check.items():
224+
try:
225+
text = self.wallet_view.get_data_item_element_text(data_item_name=key)
226+
if key == 'Max fees':
227+
if not re.findall(expected_value, text):
228+
self.errors.append(self.wallet_view,
229+
"Max fee is not a number - %s on the Review Transaction page" % text)
230+
elif key == 'Est. time':
231+
if not re.findall(expected_value, text) or int(re.findall(r'\d+', text)[0]) > 60:
232+
self.errors.append(
233+
self.wallet_view, "Unexpected Est. time value - %s on the Review Transaction page" % text)
234+
else:
235+
if text != expected_value:
236+
self.errors.append(
237+
self.wallet_view,
238+
"%s text %s doesn't match expected %s on the Review Transaction page" % (
239+
key, text, expected_value))
240+
except TimeoutException:
241+
self.errors.append(self.wallet_view, "%s is not shown on the Review Transaction page" % key)
242+
self.wallet_view.slide_and_confirm_with_password()
243+
self.browser_view.open_browser()
244+
if not self.browser_view.element_by_text('Transaction confirmed!').is_element_displayed(60):
245+
self.errors.append(self.wallet_view, "Transaction was not confirmed")
246+
self.errors.verify_no_errors()

test/appium/views/base_view.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ def __init__(self, driver):
116116
self.login_button = LogInButton(self.driver)
117117
self.continue_button = Button(self.driver, accessibility_id='continue-button')
118118
self.view_id_tracker = Text(self.driver, xpath="//*[@content-desc='view-id-tracker']/android.widget.TextView")
119+
self.testnet_mode_enabled_element = BaseElement(self.driver, accessibility_id='Testnet mode enabled')
119120

120121
# Tabs
121122
self.communities_tab = CommunitiesTab(self.driver)
@@ -245,6 +246,10 @@ def navigate_to_communities_view(self):
245246
self.navigate_back_to_home_view()
246247
self.communities_tab.click()
247248

249+
def navigate_to_wallet_view(self):
250+
self.navigate_back_to_home_view()
251+
self.wallet_tab.click()
252+
248253
def navigate_back_to_chat_view(self):
249254
self.click_system_back_button_until_presence_of_element(self.get_chat_view().chat_message_input)
250255

@@ -429,3 +434,7 @@ def pull_to_refresh(self):
429434
"direction": "down",
430435
"percent": 0.75
431436
})
437+
438+
@property
439+
def testnet_mode_enabled(self) -> bool:
440+
return self.testnet_mode_enabled_element.is_element_displayed()

test/appium/views/wallet_view.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from tests import common_password
99
from views.base_element import Button, EditBox, Text, BaseElement
1010
from views.base_view import BaseView
11+
from views.chat_view import ChatView
1112
from views.home_view import HomeView
1213
from views.sign_in_view import SignInView
1314

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

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

237+
# dApp adding
238+
self.add_dapp_button = Button(self.driver, accessibility_id='connected-dapps-add')
239+
self.wallet_connect_button = Button(self.driver, accessibility_id='wc-connect')
240+
self.wallet_decline_button = Button(self.driver, accessibility_id='wc-deny-connection')
241+
self.select_account_to_connect_dapp_button = Button(self.driver, accessibility_id='icon-right')
242+
self.close_connected_dapps_button = Button(self.driver, accessibility_id='connected-dapps-close')
243+
234244
def set_network_in_wallet(self, network_name: str):
235245
class NetworksCheckboxElement(Button):
236246
def __init__(self, driver, index=0):
@@ -529,3 +539,21 @@ def get_balance(self, asset='Ether', fiat=False):
529539
def get_receive_swap_amount(self, decimals=18):
530540
self.just_fyi("Getting swap Receive amount for on review page")
531541
return self.round_amount_float(self.swap_receive_amount_summary_text.text.split()[0], decimals)
542+
543+
def get_connected_dapp_element_by_name(self, dapp_name: str):
544+
class ConnectedDAppElement(BaseElement):
545+
def __init__(self, driver, dapp_name):
546+
self.locator = "//*[contains(@content-desc,'dapp-')][*[@text='%s']]" % dapp_name
547+
super().__init__(driver, xpath=self.locator)
548+
self.url_text = Text(self.driver, xpath=self.locator + "//*[starts-with(@text,'http')]")
549+
self.disconnect_button = Button(self.driver, xpath=self.locator + "//*[@content-desc='icon']")
550+
551+
def disconnect(self):
552+
self.disconnect_button.click()
553+
ChatView(self.driver).confirm_block_contact_button.click()
554+
555+
return ConnectedDAppElement(self.driver, dapp_name)
556+
557+
def select_account_to_connect_dapp(self, account_name: str):
558+
self.select_account_to_connect_dapp_button.click()
559+
Button(self.driver, xpath="//*[@content-desc='container']/*[@text='%s']" % account_name).click()

0 commit comments

Comments
 (0)