e2e: fixes for wallet, community urls and more

This commit is contained in:
Yevheniia Berdnyk 2024-07-30 19:44:16 +03:00
parent e0fe0d2dbd
commit 28da6f8bfc
No known key found for this signature in database
6 changed files with 38 additions and 21 deletions

View File

@ -1,11 +1,13 @@
import logging
import time
from datetime import datetime
from decimal import Decimal
from json import JSONDecodeError
from os import environ
from typing import List
import pytest
import pytz
import requests
from selenium.common import TimeoutException
@ -38,7 +40,7 @@ class NetworkApi:
return self.send_etherscan_request(params)
def get_transactions(self, address: str) -> List[dict]:
params = {'module': 'account', 'action': 'txlist', 'address': address, 'sort': 'desc'}
params = {'module': 'account', 'action': 'txlist', 'address': address, 'page': 1, 'offset': 10, 'sort': 'desc'}
return self.send_etherscan_request(params)
def is_transaction_successful(self, transaction_hash: str) -> int:
@ -106,22 +108,28 @@ class NetworkApi:
self.log("Failed iterate transactions(Etherscan unexpected error): " + str(e))
continue
def wait_for_confirmation_of_transaction(self, address, amount, confirmations=6, token=False):
def wait_for_confirmation_of_transaction(self, address, tx_time, confirmations=7, token=False):
expected_tx_timestamp = datetime.strptime(tx_time, "%Y-%m-%dT%H:%M:%S%z").replace(tzinfo=pytz.UTC)
start_time = time.time()
if token:
token_info = "token transaction"
else:
token_info = "ETH transaction"
self.log('Waiting %s %s for %s to have %s confirmations' % (amount, token_info, address, confirmations))
self.log('Waiting for %s of %s to have %s confirmations' % (token_info, address, confirmations))
while round(time.time() - start_time, ndigits=2) < 600: # should be < idleTimeout capability
transaction = self.find_transaction_by_unique_amount(address, amount, token)
if token:
transaction = self.get_token_transactions(address)[0]
else:
transaction = self.get_transactions(address)[0]
tx_timestamp = datetime.fromtimestamp(int(transaction['timeStamp'])).replace(tzinfo=pytz.UTC)
if tx_timestamp > expected_tx_timestamp:
if int(transaction['confirmations']) >= confirmations:
return
time.sleep(20)
self.log(
'Expected amount of confirmations is %s, in fact %s' % (confirmations, transaction['confirmations']))
if int(transaction['confirmations']) >= confirmations:
return
time.sleep(20)
pytest.fail('Transaction with amount %s was not confirmed, address is %s, still has %s confirmations' % (
amount, address, int(transaction['confirmations'])))
pytest.fail('The last transaction was not confirmed, address is %s, still has %s confirmations' % (
address, int(transaction['confirmations'])))
def verify_balance_is_updated(self, initial_balance, recipient_address, wait_time=360):
counter = 0

View File

@ -48,11 +48,11 @@ class TestDeepLinksOneDevice(MultipleSharedDeviceTestCase):
self.profile_view.close_button.click()
community_urls = {
"https://status.app/c/ixyACjgKDVNOVCBjb21tdW5pdHkSHHJlcXVpcmUgMTAgU05UIEdvZXJsaSB0byB1c2UYASIHI2VhYjcwMAM=#zQ3shUeGnhM33QW4g9JfYfeLFAH9ZwbDboNYn5exCR7S3ii1y":
"https://status.app/c/ixyACjgKDVNOVCBjb21tdW5pdHkSHHJlcXVpcmUgMTAgU05UIEdvZXJsaSB0byB1c2UYASIHI2VhYjcwMAM=#zQ3shhxbnaCooVQqaEkZRuRbez2SRws52Sas9HxkZNGimLRpi":
"SNT community",
"https://status.app/c/G0UAAMTyNsn2QZDEG0EXftOl8pOEfwEBOOSA_YTfIk85xmADDgINGmxpUHAXzK36bN0fK42Xf4YD2yjPk1z2pbFwFw==#zQ3sheoNX5kiuM393TJ6xDnL57aQoiwFWEuJnazJ6W2eNuh9u":
"https://status.app/c/G0UAAMTyNsn2QZDEG0EXftOl8pOEfwEBOOSA_YTfIk85xmADDgINGmxpUHAXzK36bN0fK42Xf4YD2yjPk1z2pbFwFw==#zQ3shQGRffgENQzqDLAVCUbF8S2iPZHFfCGCPbApUfAoCNBMu":
"open community",
"https://status.app/c/G00AAGS9TbI9mSR-ZNmFrhRjNuEeXAAbcAIUaLLJyjMOG3ACJQ12oIHD78QhzO9s_T5bUeU7rnATWJg3mGgTUemrAg==#zQ3shp9f5M3uyMpwTi3rFpFrP6WCWmNsW9pgK9cjXVTaf2vgj":
"https://status.app/c/G00AAGS9TbI9mSR-ZNmFrhRjNuEeXAAbcAIUaLLJyjMOG3ACJQ12oIHD78QhzO9s_T5bUeU7rnATWJg3mGgTUemrAg==#zQ3shf1JfZjB7yJ1EorFnnmeTs2PN5chpD98Li5kLN7wd2SpL":
"closed community"
}
for url, text in community_urls.items():
@ -98,11 +98,11 @@ class TestDeepLinksOneDevice(MultipleSharedDeviceTestCase):
self.browser_view.click_system_back_button()
community_links = {
"status.app://c/ixyACjgKDVNOVCBjb21tdW5pdHkSHHJlcXVpcmUgMTAgU05UIEdvZXJsaSB0byB1c2UYASIHI2VhYjcwMAM=#zQ3shUeGnhM33QW4g9JfYfeLFAH9ZwbDboNYn5exCR7S3ii1y":
"status.app://c/ixyACjgKDVNOVCBjb21tdW5pdHkSHHJlcXVpcmUgMTAgU05UIEdvZXJsaSB0byB1c2UYASIHI2VhYjcwMAM=#zQ3shhxbnaCooVQqaEkZRuRbez2SRws52Sas9HxkZNGimLRpi":
"SNT community",
"status.app://c/G0UAAMTyNsn2QZDEG0EXftOl8pOEfwEBOOSA_YTfIk85xmADDgINGmxpUHAXzK36bN0fK42Xf4YD2yjPk1z2pbFwFw==#zQ3sheoNX5kiuM393TJ6xDnL57aQoiwFWEuJnazJ6W2eNuh9u":
"status.app://c/G0UAAMTyNsn2QZDEG0EXftOl8pOEfwEBOOSA_YTfIk85xmADDgINGmxpUHAXzK36bN0fK42Xf4YD2yjPk1z2pbFwFw==#zQ3shQGRffgENQzqDLAVCUbF8S2iPZHFfCGCPbApUfAoCNBMu":
"open community",
"status.app://c/G00AAGS9TbI9mSR-ZNmFrhRjNuEeXAAbcAIUaLLJyjMOG3ACJQ12oIHD78QhzO9s_T5bUeU7rnATWJg3mGgTUemrAg==#zQ3shp9f5M3uyMpwTi3rFpFrP6WCWmNsW9pgK9cjXVTaf2vgj":
"status.app://c/G00AAGS9TbI9mSR-ZNmFrhRjNuEeXAAbcAIUaLLJyjMOG3ACJQ12oIHD78QhzO9s_T5bUeU7rnATWJg3mGgTUemrAg==#zQ3shf1JfZjB7yJ1EorFnnmeTs2PN5chpD98Li5kLN7wd2SpL":
"closed community"
}
for link, text in community_links.items():

View File

@ -135,11 +135,14 @@ class TestWalletMultipleDevice(MultipleSharedDeviceTestCase):
self.wallet_1.just_fyi("Sending funds from wallet")
amount_to_send = 0.0001
device_time_before_sending = self.wallet_1.driver.device_time
self.wallet_1.send_asset(address='arb1:' + self.receiver['wallet_address'],
asset_name='Ether',
amount=amount_to_send)
self.network_api.wait_for_confirmation_of_transaction(address=self.sender['wallet_address'],
tx_time=device_time_before_sending)
device_time = self.wallet_1.driver.device_time
device_time_after_sending = self.wallet_1.driver.device_time
self._check_balances_after_tx(amount_to_send, sender_balance, receiver_balance, eth_amount_sender,
eth_amount_receiver)
@ -164,10 +167,13 @@ class TestWalletMultipleDevice(MultipleSharedDeviceTestCase):
self.wallet_1.just_fyi("Sending asset from drawer")
amount_to_send = 0.0001
device_time_before_sending = self.wallet_1.driver.device_time
self.wallet_1.send_asset_from_drawer(address='arb1:' + self.receiver['wallet_address'],
asset_name='Ether',
amount=amount_to_send)
device_time = self.wallet_1.driver.device_time
self.network_api.wait_for_confirmation_of_transaction(address=self.sender['wallet_address'],
tx_time=device_time_before_sending)
device_time_after_sending = self.wallet_1.driver.device_time
self._check_balances_after_tx(amount_to_send, sender_balance, receiver_balance, eth_amount_sender,
eth_amount_receiver)

View File

@ -290,8 +290,11 @@ class ProfileView(BaseView):
self.advertise_device_button = Button(self.driver, accessibility_id="advertise-device")
self.sync_all_button = Button(self.driver, translation_id="sync-all-devices")
self.syncing_button = Button(self.driver, accessibility_id="icon, Syncing, label-component, icon")
self.sync_plus_button = Button(self.driver,
xpath="//*[@text='Syncing']/following-sibling::android.view.ViewGroup[1]")
self.paired_devices_button = Button(self.driver,
accessibility_id="icon, Paired devices, 0 devices, label-component, icon")
self.sync_plus_button = Button(
self.driver,
xpath="//*[@text='Paired devices']/following-sibling::android.view.ViewGroup[@content-desc='icon']")
# Keycard
self.keycard_button = Button(self.driver, accessibility_id="keycard-button")
@ -539,6 +542,7 @@ class ProfileView(BaseView):
def get_sync_code(self):
self.syncing_button.scroll_and_click()
self.paired_devices_button.click()
self.sync_plus_button.click()
for checkbox in Button(
self.driver,

View File

@ -261,7 +261,7 @@ class SignInView(BaseView):
# self.identifiers_button.wait_and_click(30)
if enable_notifications:
self.enable_notifications_button.click_until_presence_of_element(self.start_button)
if self.allow_button.is_element_displayed():
if self.allow_button.is_element_displayed(10):
self.allow_button.click()
else:
self.maybe_later_button.click_until_presence_of_element(self.start_button)

View File

@ -160,7 +160,6 @@ class WalletView(BaseView):
self.add_account_button.click()
self.add_account_to_watch.click()
self.address_to_watch_input.send_keys(address)
self.account_has_activity_label.wait_for_visibility_of_element()
self.add_account_continue_button.click()
SignInView(self.driver).profile_title_input.send_keys(account_name)
self.add_watched_address_button.click()