e2e: update for wallet users and community links test

This commit is contained in:
Yevheniia Berdnyk 2024-06-19 19:44:01 +03:00
parent fb84f105db
commit 9d825ee04e
No known key found for this signature in database
GPG Key ID: 0642C73C66214825
3 changed files with 29 additions and 27 deletions

View File

@ -14,7 +14,7 @@ import tests
class NetworkApi:
def __init__(self):
self.network_url = 'http://api-sepolia.etherscan.io/api'
self.network_url = 'http://api-sepolia.arbiscan.io/api'
self.api_key = environ.get('ETHERSCAN_API_KEY')
def log(self, text: str):
@ -50,7 +50,7 @@ class NetworkApi:
balance = self.send_etherscan_request(params)
if balance:
self.log('Balance is %s Gwei' % balance)
return int(balance)
return int(balance) / 1000000000000000000
else:
self.log('Cannot extract balance!')
@ -138,11 +138,12 @@ class NetworkApi:
def wait_for_balance_to_be(self, address: str, expected_balance: int, less: bool = True):
for _ in range(5):
balance = self.get_balance(address) / 1000000000000000000
if (less and balance < expected_balance) or (not less and balance > expected_balance):
balance = self.get_balance(address)
if balance == expected_balance:
return
time.sleep(10)
raise TimeoutException('Balance is not updated on Etherscan')
raise TimeoutException(
'balance is not updated on Etherscan, it is %s but expected to be %s' % (balance, expected_balance))
# Do not use until web3 update
# def faucet(self, address):

View File

@ -47,15 +47,15 @@ class TestDeepLinksOneDevice(MultipleSharedDeviceTestCase):
self.errors.append("Profile was not opened by the profile url %s" % url)
self.profile_view.close_button.click()
closed_community_urls = {
"https://status.app/c/G0IAAGRy3S0pLm1NeQ91pwKgFaFGoIlkxXmDxITXXi3KdZ7vpb9-ERczhqwoFwMK6sCPnKwA#zQ3shtJ8A3rxUZWcfWDL3vKYQBt3jMPTuf44dJUGfjZjsek66":
"e2e community token-gated",
community_urls = {
"https://status.app/c/G0IAAGS9TbI9SrSPbDPplfBUeBBOIWhFRhGIKVlxntAg5CSvsJw4jurb636UKo7Lm2gTUS_M#zQ3shm7cS2MX6K1iinjNhiw88g1WH6fbE8rvnMHBq4RhznkWc":
"token-gated community e2e",
"https://status.app/c/GzwAAGS9TbI9CiYaoZj0TRNelWAPwk8gSHIEmqgqb0ADPw5rnFvk6bp_n3BlZxVMshmxFyI=#zQ3shkrmSmwb66sw2EuUvC5iqiNqEeevTfjtks3p8ZaaCYoNj":
"Open community for e2e",
"https://status.app/c/GzAAAORtwyW4xNWM4td0F7hOnYZ1apSqCCRUUR0qxD19n3Ec97fX_aIVIGFWbdUM#zQ3shk6dgK8dYWWSC4m8Jj5c91zyfhfj1fFkgypS8D9gsXkrK":
"Closed community"
}
for url, text in closed_community_urls.items():
for url, text in community_urls.items():
self.channel.just_fyi("Opening community '%s' by the url %s" % (text, url))
self.channel.chat_message_input.clear()
self.channel.send_message(url)
@ -95,8 +95,8 @@ class TestDeepLinksOneDevice(MultipleSharedDeviceTestCase):
self.browser_view.click_system_back_button()
community_links = {
"status.app://c/G0IAAGRy3S0pLm1NeQ91pwKgFaFGoIlkxXmDxITXXi3KdZ7vpb9-ERczhqwoFwMK6sCPnKwA#zQ3shtJ8A3rxUZWcfWDL3vKYQBt3jMPTuf44dJUGfjZjsek66":
"e2e community token-gated",
"status.app://c/G0IAAGS9TbI9SrSPbDPplfBUeBBOIWhFRhGIKVlxntAg5CSvsJw4jurb636UKo7Lm2gTUS_M#zQ3shm7cS2MX6K1iinjNhiw88g1WH6fbE8rvnMHBq4RhznkWc":
"token-gated community e2e",
"status.app://c/GzwAAGS9TbI9CiYaoZj0TRNelWAPwk8gSHIEmqgqb0ADPw5rnFvk6bp_n3BlZxVMshmxFyI=#zQ3shkrmSmwb66sw2EuUvC5iqiNqEeevTfjtks3p8ZaaCYoNj":
"Open community for e2e",
"status.app://c/GzAAAORtwyW4xNWM4td0F7hOnYZ1apSqCCRUUR0qxD19n3Ec97fX_aIVIGFWbdUM#zQ3shk6dgK8dYWWSC4m8Jj5c91zyfhfj1fFkgypS8D9gsXkrK":

View File

@ -8,7 +8,7 @@ from selenium.common import TimeoutException, NoSuchElementException
from base_test_case import MultipleSharedDeviceTestCase, create_shared_drivers
from support.api.network_api import NetworkApi
from tests import marks, run_in_parallel
from users import recovery_users
from users import transaction_senders
from views.sign_in_view import SignInView
@ -21,9 +21,9 @@ class TestWalletMultipleDevice(MultipleSharedDeviceTestCase):
self.network_api = NetworkApi()
self.drivers, self.loop = create_shared_drivers(2)
self.sign_in_1, self.sign_in_2 = SignInView(self.drivers[0]), SignInView(self.drivers[1])
passphrases, addresses = list(recovery_users), list(recovery_users.values())
self.sender = {'passphrase': passphrases[0], 'address': addresses[0]}
self.receiver = {'passphrase': passphrases[1], 'address': addresses[1]}
self.sender, self.receiver = transaction_senders['ETH_1'], transaction_senders['ETH_2']
self.sender['wallet_address'] = '0x' + self.sender['address']
self.receiver['wallet_address'] = '0x' + self.receiver['address']
self.sender_username, self.receiver_username = 'sender', 'receiver'
self.loop.run_until_complete(
run_in_parallel(((self.sign_in_1.recover_access, {'passphrase': self.sender['passphrase'],
@ -34,8 +34,8 @@ class TestWalletMultipleDevice(MultipleSharedDeviceTestCase):
self.wallet_1, self.wallet_2 = self.sign_in_1.get_wallet_view(), self.sign_in_2.get_wallet_view()
def _get_balances_before_tx(self):
sender_balance = self.network_api.get_balance(self.sender['address'])
receiver_balance = self.network_api.get_balance(self.receiver['address'])
sender_balance = self.network_api.get_balance(self.sender['wallet_address'])
receiver_balance = self.network_api.get_balance(self.receiver['wallet_address'])
self.wallet_1.just_fyi("Getting ETH amount in the wallet of the sender before transaction")
self.wallet_1.wallet_tab.click()
self.wallet_1.get_account_element().click()
@ -49,15 +49,15 @@ class TestWalletMultipleDevice(MultipleSharedDeviceTestCase):
def _check_balances_after_tx(self, amount_to_send, sender_balance, receiver_balance, eth_amount_sender,
eth_amount_receiver):
try:
self.network_api.wait_for_balance_to_be(address=self.sender['address'],
self.network_api.wait_for_balance_to_be(address=self.sender['wallet_address'],
expected_balance=sender_balance - amount_to_send)
except TimeoutException:
self.errors.append("Sender balance was not updated")
except TimeoutException as e:
self.errors.append("Sender " + e.msg)
try:
self.network_api.wait_for_balance_to_be(address=self.receiver['address'],
self.network_api.wait_for_balance_to_be(address=self.receiver['wallet_address'],
expected_balance=receiver_balance + amount_to_send)
except TimeoutException:
self.errors.append("Receiver balance was not updated")
except TimeoutException as e:
self.errors.append("Receiver " + e.msg)
def wait_for_wallet_balance_to_update(wallet_view, user_name, initial_eth_amount):
wallet_view.just_fyi("Getting ETH amount in the wallet of the %s after transaction" % user_name)
@ -102,8 +102,9 @@ class TestWalletMultipleDevice(MultipleSharedDeviceTestCase):
expected_time = "Today %s" % current_time.strftime('%-I:%M %p')
possible_times = [expected_time,
"Today %s" % (current_time + datetime.timedelta(minutes=1)).strftime('%-I:%M %p')]
sender_address_short = self.sender['address'].replace(self.sender['address'][5:-3], '...').lower()
receiver_address_short = self.receiver['address'].replace(self.receiver['address'][5:-3], '...').lower()
sender_address_short = self.sender['wallet_address'].replace(self.sender['wallet_address'][5:-3], '...').lower()
receiver_address_short = self.receiver['wallet_address'].replace(self.receiver['wallet_address'][5:-3],
'...').lower()
activity_element = wallet_view.get_activity_element()
try:
if not all((activity_element.header == 'Send' if sender else 'Receive',
@ -128,7 +129,7 @@ class TestWalletMultipleDevice(MultipleSharedDeviceTestCase):
self.wallet_1.just_fyi("Sending funds from wallet")
amount_to_send = 0.0001
self.wallet_1.send_asset(address=self.receiver['address'], asset_name='Ether', amount=amount_to_send)
self.wallet_1.send_asset(address=self.receiver['wallet_address'], asset_name='Ether', amount=amount_to_send)
device_time = self.wallet_1.driver.device_time
@ -154,7 +155,7 @@ class TestWalletMultipleDevice(MultipleSharedDeviceTestCase):
self.wallet_1.just_fyi("Sending asset from drawer")
amount_to_send = 0.0001
self.wallet_1.send_asset_from_drawer(address=self.receiver['address'], asset_name='Ether',
self.wallet_1.send_asset_from_drawer(address=self.receiver['wallet_address'], asset_name='Ether',
amount=amount_to_send)
device_time = self.wallet_1.driver.device_time