From 97b19c54401b9fffc003f0b79feff83e21f55851 Mon Sep 17 00:00:00 2001 From: Yevheniia Berdnyk Date: Wed, 17 Jul 2024 19:39:41 +0300 Subject: [PATCH] e2e: fixes for wallet and deep/universal links tests --- .../chats/test_public_chat_browsing.py | 1 + .../critical/test_deep_and_universal_links.py | 45 +++++++++++-------- test/appium/tests/critical/test_wallet.py | 18 +++++--- test/appium/views/wallet_view.py | 13 ++++++ 4 files changed, 53 insertions(+), 24 deletions(-) diff --git a/test/appium/tests/critical/chats/test_public_chat_browsing.py b/test/appium/tests/critical/chats/test_public_chat_browsing.py index 93b691a2b5..b852d56393 100644 --- a/test/appium/tests/critical/chats/test_public_chat_browsing.py +++ b/test/appium/tests/critical/chats/test_public_chat_browsing.py @@ -219,6 +219,7 @@ class TestCommunityOneDeviceMerged(MultipleSharedDeviceTestCase): self.sign_in.show_profiles_button.wait_and_click() self.sign_in.element_by_text(self.username).click() self.sign_in.sign_in() + self.home.navigate_back_to_home_view() self.home.communities_tab.click() if self.home.element_by_text(waku_user.communities['admin_open']).is_element_displayed(30): self.errors.append("Community of previous user is shown!") diff --git a/test/appium/tests/critical/test_deep_and_universal_links.py b/test/appium/tests/critical/test_deep_and_universal_links.py index 1525e5405d..1f51fd1889 100644 --- a/test/appium/tests/critical/test_deep_and_universal_links.py +++ b/test/appium/tests/critical/test_deep_and_universal_links.py @@ -48,11 +48,11 @@ class TestDeepLinksOneDevice(MultipleSharedDeviceTestCase): self.profile_view.close_button.click() community_urls = { - "https://status.app/c/G0IAAGS9TbI9SrSPbDPplfBUeBBOIWhFRhGIKVlxntAg5CSvsJw4jurb636UKo7Lm2gTUS_M#zQ3shm7cS2MX6K1iinjNhiw88g1WH6fbE8rvnMHBq4RhznkWc": - "token-gated community e2e", - "https://status.app/c/G0UAAMTyNsn2QZDEG0EXftOl8pOEfwEBOOSA_YTfIk85xmADDgINGmxpUHAXzK36bN0fK42Xf4YD2yjPk1z2pbFwFw==#zQ3shZU9PNP6QHwEmqoh5mQqjCMDsfZYnpY4BEC8hom7KoNEz": + "https://status.app/c/ixyACjgKDVNOVCBjb21tdW5pdHkSHHJlcXVpcmUgMTAgU05UIEdvZXJsaSB0byB1c2UYASIHI2VhYjcwMAM=#zQ3shUeGnhM33QW4g9JfYfeLFAH9ZwbDboNYn5exCR7S3ii1y": + "SNT community", + "https://status.app/c/G0UAAMTyNsn2QZDEG0EXftOl8pOEfwEBOOSA_YTfIk85xmADDgINGmxpUHAXzK36bN0fK42Xf4YD2yjPk1z2pbFwFw==#zQ3sheoNX5kiuM393TJ6xDnL57aQoiwFWEuJnazJ6W2eNuh9u": "open community", - "https://status.app/c/G00AAGS9TbI9mSR-ZNmFrhRjNuEeXAAbcAIUaLLJyjMOG3ACJQ12oIHD78QhzO9s_T5bUeU7rnATWJg3mGgTUemrAg==#zQ3shTK1zXmLq2yZWMij65j1LNtmvuG6x71Nmg2fwtKs32wHj": + "https://status.app/c/G00AAGS9TbI9mSR-ZNmFrhRjNuEeXAAbcAIUaLLJyjMOG3ACJQ12oIHD78QhzO9s_T5bUeU7rnATWJg3mGgTUemrAg==#zQ3shp9f5M3uyMpwTi3rFpFrP6WCWmNsW9pgK9cjXVTaf2vgj": "closed community" } for url, text in community_urls.items(): @@ -60,11 +60,14 @@ class TestDeepLinksOneDevice(MultipleSharedDeviceTestCase): self.channel.chat_message_input.clear() self.channel.send_message(url) self.channel.chat_element_by_text(url).click_on_link_inside_message_body() - if not (self.community_view.join_button.is_element_displayed(10) - or self.community_view.join_community_button.is_element_displayed(5)) \ - or self.community_view.community_title.text != text: - self.errors.append("Community '%s' was not requested to join by the url %s" % (text, url)) - if text != "Closed community": # the last one + if text == 'SNT community': + if self.community_view.community_title.text != text: + self.errors.append("Community '%s' was not requested to join by the url %s" % (text, url)) + else: + if not self.community_view.join_button.is_element_displayed( + 10) or self.community_view.community_title.text != text: + self.errors.append("Community '%s' was not requested to join by the url %s" % (text, url)) + if text != "closed community": # the last one self.home.navigate_back_to_home_view() self.home.get_to_community_channel_from_home(self.community_name) @@ -95,22 +98,26 @@ class TestDeepLinksOneDevice(MultipleSharedDeviceTestCase): self.browser_view.click_system_back_button() community_links = { - "status.app://c/G0IAAGS9TbI9SrSPbDPplfBUeBBOIWhFRhGIKVlxntAg5CSvsJw4jurb636UKo7Lm2gTUS_M#zQ3shm7cS2MX6K1iinjNhiw88g1WH6fbE8rvnMHBq4RhznkWc": - "token-gated community e2e", - "status.app://c/G0UAAMTyNsn2QZDEG0EXftOl8pOEfwEBOOSA_YTfIk85xmADDgINGmxpUHAXzK36bN0fK42Xf4YD2yjPk1z2pbFwFw==#zQ3shZU9PNP6QHwEmqoh5mQqjCMDsfZYnpY4BEC8hom7KoNEz": + "status.app://c/ixyACjgKDVNOVCBjb21tdW5pdHkSHHJlcXVpcmUgMTAgU05UIEdvZXJsaSB0byB1c2UYASIHI2VhYjcwMAM=#zQ3shUeGnhM33QW4g9JfYfeLFAH9ZwbDboNYn5exCR7S3ii1y": + "SNT community", + "status.app://c/G0UAAMTyNsn2QZDEG0EXftOl8pOEfwEBOOSA_YTfIk85xmADDgINGmxpUHAXzK36bN0fK42Xf4YD2yjPk1z2pbFwFw==#zQ3sheoNX5kiuM393TJ6xDnL57aQoiwFWEuJnazJ6W2eNuh9u": "open community", - "status.app://c/G00AAGS9TbI9mSR-ZNmFrhRjNuEeXAAbcAIUaLLJyjMOG3ACJQ12oIHD78QhzO9s_T5bUeU7rnATWJg3mGgTUemrAg==#zQ3shTK1zXmLq2yZWMij65j1LNtmvuG6x71Nmg2fwtKs32wHj": + "status.app://c/G00AAGS9TbI9mSR-ZNmFrhRjNuEeXAAbcAIUaLLJyjMOG3ACJQ12oIHD78QhzO9s_T5bUeU7rnATWJg3mGgTUemrAg==#zQ3shp9f5M3uyMpwTi3rFpFrP6WCWmNsW9pgK9cjXVTaf2vgj": "closed community" } for link, text in community_links.items(): self.channel.just_fyi("Opening community '%s' by the link %s" % (text, link)) self.browser_view.open_url(link) - if not (self.community_view.join_button.is_element_displayed(10) - or self.community_view.join_community_button.is_element_displayed(5)) \ - or self.community_view.community_title.text != text: - self.errors.append("Community '%s' was not requested to join by the deep link %s" % (text, link)) - self.home.navigate_back_to_home_view() - self.home.browser_tab.click() + if text == 'SNT community': + if self.community_view.community_title.text != text: + self.errors.append("Community '%s' was not requested to join by the deep link %s" % (text, link)) + else: + if not self.community_view.join_button.is_element_displayed( + 10) or self.community_view.community_title.text != text: + self.errors.append("Community '%s' was not requested to join by the deep link %s" % (text, link)) + if text != "closed community": # the last one + self.home.navigate_back_to_home_view() + self.home.browser_tab.click() self.errors.verify_no_errors() diff --git a/test/appium/tests/critical/test_wallet.py b/test/appium/tests/critical/test_wallet.py index 6718838308..195583f15f 100644 --- a/test/appium/tests/critical/test_wallet.py +++ b/test/appium/tests/critical/test_wallet.py @@ -33,16 +33,16 @@ class TestWalletMultipleDevice(MultipleSharedDeviceTestCase): 'username': self.receiver_username})))) self.home_1, self.home_2 = self.sign_in_1.get_home_view(), self.sign_in_2.get_home_view() self.wallet_1, self.wallet_2 = self.sign_in_1.get_wallet_view(), self.sign_in_2.get_wallet_view() + self.wallet_1.wallet_tab.click() + self.wallet_2.wallet_tab.click() def _get_balances_before_tx(self): 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() eth_amount_sender = self.wallet_1.get_asset(asset_name='Ether').get_amount() self.wallet_2.just_fyi("Getting ETH amount in the wallet of the receiver before transaction") - self.wallet_2.wallet_tab.click() self.wallet_2.get_account_element().click() eth_amount_receiver = self.wallet_2.get_asset(asset_name='Ether').get_amount() return sender_balance, receiver_balance, eth_amount_sender, eth_amount_receiver @@ -68,7 +68,6 @@ class TestWalletMultipleDevice(MultipleSharedDeviceTestCase): exp_amount = round(initial_eth_amount + amount_to_send, 4) # for _ in range(12): # ToDo: 120 sec wait time, enable when autoupdate feature is ready - wallet_view.wallet_tab.wait_and_click() new_eth_amount = round(wallet_view.get_asset(asset_name='Ether').get_amount(), 4) if user_name == 'sender' and new_eth_amount <= exp_amount: return @@ -87,6 +86,10 @@ class TestWalletMultipleDevice(MultipleSharedDeviceTestCase): self.loop.run_until_complete( run_in_parallel(((self.home_1.reopen_app,), (self.home_2.reopen_app,)))) + self.wallet_1.wallet_tab.wait_and_click() + self.wallet_2.wallet_tab.wait_and_click() + self.wallet_1.select_network(network_name='Arbitrum') + self.wallet_2.select_network(network_name='Arbitrum') self.loop.run_until_complete( run_in_parallel(((wait_for_wallet_balance_to_update, {'wallet_view': self.wallet_1, 'user_name': self.sender_username, @@ -123,6 +126,8 @@ class TestWalletMultipleDevice(MultipleSharedDeviceTestCase): @marks.testrail_id(727229) def test_wallet_send_eth(self): + self.wallet_1.select_network(network_name='Arbitrum') + self.wallet_2.select_network(network_name='Arbitrum') sender_balance, receiver_balance, eth_amount_sender, eth_amount_receiver = self._get_balances_before_tx() self.wallet_2.close_account_button.click() @@ -130,7 +135,9 @@ 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['wallet_address'], asset_name='Ether', amount=amount_to_send) + self.wallet_1.send_asset(address='arb1:' + self.receiver['wallet_address'], + asset_name='Ether', + amount=amount_to_send) device_time = self.wallet_1.driver.device_time @@ -156,7 +163,8 @@ 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['wallet_address'], asset_name='Ether', + 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 diff --git a/test/appium/views/wallet_view.py b/test/appium/views/wallet_view.py index 8bbb425d26..0865b3c7dd 100644 --- a/test/appium/views/wallet_view.py +++ b/test/appium/views/wallet_view.py @@ -92,9 +92,16 @@ class WalletView(BaseView): # Sending transaction self.address_text_input = EditBox(self.driver, accessibility_id='address-text-input') self.amount_input = EditBox(self.driver, xpath="//android.widget.EditText") + self.from_network_text = Text( + self.driver, xpath="(//*[@content-desc='loading']/following-sibling::android.widget.TextView)[1]") self.confirm_button = Button(self.driver, accessibility_id='button-one') self.done_button = Button(self.driver, accessibility_id='done') + def select_network(self, network_name: str): + self.network_drop_down.click() + Button(self.driver, accessibility_id="%s, label-component" % network_name.capitalize()).click() + self.network_drop_down.click() + def get_account_element(self, account_name: str = 'Account 1'): return Button(self.driver, xpath="//android.view.ViewGroup[contains(@content-desc,'%s')]" % account_name) @@ -120,12 +127,17 @@ class WalletView(BaseView): for i in '{:f}'.format(amount).rstrip('0'): Button(self.driver, accessibility_id='keyboard-key-%s' % i).click() + def disable_mainnet_in_from_network(self): + if self.from_network_text.text == 'Mainnet': + self.from_network_text.click() + def send_asset(self, address: str, asset_name: str, amount: float): self.send_button.click() self.address_text_input.send_keys(address) self.continue_button.click() self.select_asset(asset_name).click() self.set_amount(amount) + self.disable_mainnet_in_from_network() self.confirm_transaction() def send_asset_from_drawer(self, address: str, asset_name: str, amount: float): @@ -135,6 +147,7 @@ class WalletView(BaseView): self.address_text_input.send_keys(address) self.continue_button.click() self.set_amount(amount) + self.disable_mainnet_in_from_network() self.confirm_transaction() def add_regular_account(self, account_name: str):