From 746d580e3406cceb0707ddb30652203789801607 Mon Sep 17 00:00:00 2001 From: yevh-berdnyk Date: Wed, 1 Aug 2018 02:16:33 +0200 Subject: [PATCH] Wallet modal tests Signed-off-by: yevh-berdnyk --- src/status_im/chat/screen.cljs | 3 +- src/status_im/ui/screens/browser/views.cljs | 3 +- src/status_im/ui/screens/wallet/views.cljs | 3 +- .../account_management/test_wallet_modal.py | 101 ++++++++++++++++++ .../dapps_and_browsing/test_browsing.py | 6 +- .../transactions/test_daaps_transactions.py | 2 +- test/appium/tests/marks.py | 1 + test/appium/views/base_view.py | 20 ++++ test/appium/views/wallet_view.py | 2 +- test/appium/views/web_views/base_web_view.py | 24 ++--- 10 files changed, 144 insertions(+), 21 deletions(-) create mode 100644 test/appium/tests/atomic/account_management/test_wallet_modal.py diff --git a/src/status_im/chat/screen.cljs b/src/status_im/chat/screen.cljs index 8cdd403cca..7a1790a83d 100644 --- a/src/status_im/chat/screen.cljs +++ b/src/status_im/chat/screen.cljs @@ -53,7 +53,8 @@ (toolbar/nav-back-count {:home? true}) [toolbar-content/toolbar-content-view] [toolbar/actions [{:icon :icons/wallet - :icon-opts {:color :black} + :icon-opts {:color :black + :accessibility-label :wallet-modal-button} :handler #(re-frame/dispatch [:navigate-to-modal :wallet-modal])} {:icon :icons/options :icon-opts {:color :black diff --git a/src/status_im/ui/screens/browser/views.cljs b/src/status_im/ui/screens/browser/views.cljs index a947459c27..61197c9913 100644 --- a/src/status_im/ui/screens/browser/views.cljs +++ b/src/status_im/ui/screens/browser/views.cljs @@ -96,7 +96,8 @@ (re-frame/dispatch [:remove-browser browser-id]))))] [toolbar-content url browser error? url-editing?] [toolbar.view/actions [{:icon :icons/wallet - :icon-opts {:color :black} + :icon-opts {:color :black + :accessibility-label :wallet-modal-button} :handler #(re-frame/dispatch [:navigate-to-modal :wallet-modal])}]]] [react/view components.styles/flex [components.webview-bridge/webview-bridge diff --git a/src/status_im/ui/screens/wallet/views.cljs b/src/status_im/ui/screens/wallet/views.cljs index 08e77490a9..7c9cea3cbb 100644 --- a/src/status_im/ui/screens/wallet/views.cljs +++ b/src/status_im/ui/screens/wallet/views.cljs @@ -38,7 +38,8 @@ [toolbar/content-wrapper] [toolbar/actions [{:icon (if modal-history? :icons/wallet :icons/transaction-history) - :icon-opts {:color :white} + :icon-opts {:color :white + :accessibility-label (if modal-history? :wallet-modal-button :transaction-history-button)} :handler #(re-frame/dispatch [:set-in [:wallet :modal-history?] (not modal-history?)])}]]]]) (defn- total-section [value currency] diff --git a/test/appium/tests/atomic/account_management/test_wallet_modal.py b/test/appium/tests/atomic/account_management/test_wallet_modal.py new file mode 100644 index 0000000000..2a441956dd --- /dev/null +++ b/test/appium/tests/atomic/account_management/test_wallet_modal.py @@ -0,0 +1,101 @@ +import pytest + +from tests import marks, transaction_users +from tests.base_test_case import SingleDeviceTestCase +from views.sign_in_view import SignInView + + +@marks.wallet_modal +class TestWalletModal(SingleDeviceTestCase): + + @marks.testrail_id(3794) + def test_wallet_modal_public_chat(self): + user = transaction_users['A_USER'] + sign_in = SignInView(self.driver) + sign_in.recover_access(user['passphrase'], user['password']) + wallet = sign_in.wallet_button.click() + wallet.set_up_wallet() + usd_value = wallet.get_usd_total_value() + eth_value = wallet.get_eth_value() + stt_value = wallet.get_stt_value() + home = wallet.home_button.click() + chat = home.join_public_chat(home.get_public_chat_name()) + wallet_modal = chat.wallet_modal_button.click() + if wallet_modal.address_text.text != '0x' + user['address']: + self.errors.append('Wallet address is not shown in wallet modal') + if wallet_modal.get_usd_total_value() != usd_value: + self.errors.append('Total value in USD is not correct in wallet modal') + if wallet_modal.get_eth_value() != eth_value: + self.errors.append('ETH value is not correct in wallet modal') + if wallet_modal.get_stt_value() != stt_value: + self.errors.append('STT value is not correct in wallet modal') + if not wallet_modal.transaction_history_button.is_element_displayed(): + self.errors.append('Transaction history button is not visible in wallet modal') + self.verify_no_errors() + + @marks.testrail_id(3795) + def test_wallet_modal_dapp(self): + user = transaction_users['B_USER'] + sign_in = SignInView(self.driver) + sign_in.recover_access(user['passphrase'], user['password']) + wallet = sign_in.wallet_button.click() + wallet.set_up_wallet() + usd_value = wallet.get_usd_total_value() + eth_value = wallet.get_eth_value() + stt_value = wallet.get_stt_value() + home = wallet.home_button.click() + start_new_chat = home.plus_button.click() + start_new_chat.open_d_app_button.click() + start_new_chat.element_by_text('Airswap').click() + start_new_chat.open_button.click() + wallet_modal = start_new_chat.wallet_modal_button.click() + if wallet_modal.address_text.text != '0x' + user['address']: + self.errors.append('Wallet address is not shown in wallet modal') + if wallet_modal.get_usd_total_value() != usd_value: + self.errors.append('Total value in USD is not correct in wallet modal') + if wallet_modal.get_eth_value() != eth_value: + self.errors.append('ETH value is not correct in wallet modal') + if wallet_modal.get_stt_value() != stt_value: + self.errors.append('STT value is not correct in wallet modal') + if not wallet_modal.transaction_history_button.is_element_displayed(): + self.errors.append('Transaction history button is not visible in wallet modal') + self.verify_no_errors() + + @marks.testrail_id(3797) + def test_wallet_modal_transaction_history(self): + user = transaction_users['B_USER'] + sign_in = SignInView(self.driver) + home = sign_in.recover_access(user['passphrase'], user['password']) + start_new_chat = home.plus_button.click() + start_new_chat.open_d_app_button.click() + start_new_chat.element_by_text('Airswap').click() + start_new_chat.open_button.click() + wallet_modal = start_new_chat.wallet_modal_button.click() + transaction_history = wallet_modal.transaction_history_button.click() + if transaction_history.transactions_table.get_transactions_number() < 1: + pytest.fail('Transactions history is not shown') + + @marks.testrail_id(3800) + def test_close_and_open_wallet_modal(self): + user = transaction_users['B_USER'] + sign_in = SignInView(self.driver) + home = sign_in.recover_access(user['passphrase'], user['password']) + start_new_chat = home.plus_button.click() + start_new_chat.open_d_app_button.click() + start_new_chat.element_by_text('Airswap').click() + start_new_chat.open_button.click() + web_view = start_new_chat.get_base_web_view() + wallet_modal = start_new_chat.wallet_modal_button.click() + if not wallet_modal.usd_total_value.is_element_displayed(): + pytest.fail("Wallet modal doesn't contain balance") + transaction_history = wallet_modal.transaction_history_button.click() + if transaction_history.transactions_table.get_transactions_number() < 1: + pytest.fail('Transactions history is not shown') + transaction_history.cross_icon.click() + if not web_view.browser_previous_page_button.is_element_displayed(): + pytest.fail('Modal wallet was not closed') + web_view.cross_icon.click() + chat = home.join_public_chat(home.get_public_chat_name()) + chat.wallet_modal_button.click() + if not wallet_modal.usd_total_value.is_element_displayed(): + pytest.fail("Wallet modal was not opened") diff --git a/test/appium/tests/atomic/dapps_and_browsing/test_browsing.py b/test/appium/tests/atomic/dapps_and_browsing/test_browsing.py index 29f7795d5f..07a317f9f4 100644 --- a/test/appium/tests/atomic/dapps_and_browsing/test_browsing.py +++ b/test/appium/tests/atomic/dapps_and_browsing/test_browsing.py @@ -31,7 +31,7 @@ class TestBrowsing(SingleDeviceTestCase): start_new_chat.confirm() browsing_view = home_view.get_base_web_view() browsing_view.find_text_part('Unable to load page') - browsing_view.browser_cross_icon.click() + browsing_view.cross_icon.click() if home_view.element_by_text('Browser').is_element_displayed(): pytest.fail('Browser entity is shown for an invalid link') @@ -58,7 +58,7 @@ class TestBrowsing(SingleDeviceTestCase): browsing_view = home_view.get_base_web_view() browsing_view.url_edit_box_lock_icon.click() browsing_view.find_full_text(connection_is_secure_text) - browsing_view.browser_cross_icon.click() + browsing_view.cross_icon.click() start_new_chat_view = home_view.plus_button.click() start_new_chat_view.open_d_app_button.click() start_new_chat_view.element_by_text('Airswap').click() @@ -75,7 +75,7 @@ class TestBrowsing(SingleDeviceTestCase): start_new_chat.enter_url_editbox.set_value('google.com') start_new_chat.confirm() browsing_view = home_view.get_base_web_view() - browsing_view.browser_cross_icon.click() + browsing_view.cross_icon.click() home_view.get_chat_with_user('Browser').swipe_and_delete() home_view.relogin() if home_view.get_chat_with_user('Browser').is_element_present(20): diff --git a/test/appium/tests/atomic/transactions/test_daaps_transactions.py b/test/appium/tests/atomic/transactions/test_daaps_transactions.py index e93df7a392..3de83c2c94 100644 --- a/test/appium/tests/atomic/transactions/test_daaps_transactions.py +++ b/test/appium/tests/atomic/transactions/test_daaps_transactions.py @@ -101,7 +101,7 @@ class TestTransactionDApp(SingleDeviceTestCase): status_test_dapp.request_eth_button.click() status_test_dapp.element_by_text('Faucet request recieved').wait_for_visibility_of_element() status_test_dapp.ok_button.click() - status_test_dapp.browser_cross_icon.click() + status_test_dapp.cross_icon.click() wallet_view = sign_in_view.wallet_button.click() wallet_view.set_up_wallet() wallet_view.wait_balance_changed_on_wallet_screen() diff --git a/test/appium/tests/marks.py b/test/appium/tests/marks.py index 9239f5790a..d802d2e03f 100644 --- a/test/appium/tests/marks.py +++ b/test/appium/tests/marks.py @@ -14,6 +14,7 @@ dapps = pytest.mark.dapps message_reliability = pytest.mark.message_reliability transaction = pytest.mark.transaction wallet = pytest.mark.wallet +wallet_modal = pytest.mark.wallet_modal sign_in = pytest.mark.sign_in skip = pytest.mark.skip logcat = pytest.mark.logcat diff --git a/test/appium/views/base_view.py b/test/appium/views/base_view.py index 5893e70ef6..64820864ef 100644 --- a/test/appium/views/base_view.py +++ b/test/appium/views/base_view.py @@ -222,6 +222,23 @@ class ProgressBar(BaseElement): self.locator = self.Locator.xpath_selector(parent_locator + '//android.widget.ProgressBar') +class WalletModalButton(BaseButton): + def __init__(self, driver): + super(WalletModalButton, self).__init__(driver) + self.locator = self.Locator.accessibility_id('wallet-modal-button') + + def navigate(self): + from views.wallet_view import WalletView + return WalletView(self.driver) + + +class CrossIcon(BaseButton): + + def __init__(self, driver): + super(CrossIcon, self).__init__(driver) + self.locator = self.Locator.xpath_selector('(//android.view.ViewGroup[@content-desc="icon"])[1]') + + class BaseView(object): def __init__(self, driver): self.driver = driver @@ -246,12 +263,15 @@ class BaseView(object): self.discard_button = DiscardButton(self.driver) self.confirm_button = ConfirmButton(self.driver) self.connection_status = ConnectionStatusText(self.driver) + self.cross_icon = CrossIcon(self.driver) self.apps_button = AppsButton(self.driver) self.status_app_icon = StatusAppIcon(self.driver) self.test_fairy_warning = TestFairyWarning(self.driver) + self.wallet_modal_button = WalletModalButton(self.driver) + self.element_types = { 'base': BaseElement, 'button': BaseButton, diff --git a/test/appium/views/wallet_view.py b/test/appium/views/wallet_view.py index cd44320a01..bef6b02cb0 100644 --- a/test/appium/views/wallet_view.py +++ b/test/appium/views/wallet_view.py @@ -72,7 +72,7 @@ class STTAssetText(BaseText): class UsdTotalValueText(BaseText): def __init__(self, driver): super(UsdTotalValueText, self).__init__(driver) - self.locator = self.Locator.xpath_selector("//*[@text='USD']/../android.widget.TextView[1]") + self.locator = self.Locator.accessibility_id('total-amount-value-text') class SendTransactionRequestButton(BaseButton): diff --git a/test/appium/views/web_views/base_web_view.py b/test/appium/views/web_views/base_web_view.py index 28037562d7..0b9ab5e97f 100644 --- a/test/appium/views/web_views/base_web_view.py +++ b/test/appium/views/web_views/base_web_view.py @@ -1,6 +1,9 @@ -from views.base_view import * +import time import pytest +from views.base_element import BaseElement, BaseEditBox, BaseButton +from views.base_view import BaseView + class ProgressBarIcon(BaseElement): @@ -9,6 +12,13 @@ class ProgressBarIcon(BaseElement): self.locator = self.Locator.xpath_selector("//android.widget.ProgressBar") +class WebLinkEditBox(BaseEditBox): + + def __init__(self, driver): + super(WebLinkEditBox, self).__init__(driver) + self.locator = self.Locator.xpath_selector("//android.widget.EditText") + + class BackToHomeButton(BaseButton): def __init__(self, driver): super(BackToHomeButton, self).__init__(driver) @@ -46,17 +56,6 @@ class AlwaysButton(BaseButton): self.locator = self.Locator.text_part_selector('ALWAYS') -class BrowserCrossIcon(BaseButton): - - def __init__(self, driver): - super(BrowserCrossIcon, self).__init__(driver) - self.locator = self.Locator.xpath_selector('(//android.view.ViewGroup[@content-desc="icon"])[1]') - - def navigate(self): - from views.home_view import HomeView - return HomeView(self.driver) - - class URLEditBoxLockIcon(BaseEditBox): def __init__(self, driver): @@ -80,7 +79,6 @@ class BaseWebView(BaseView): self.web_view_browser = WebViewBrowserButton(self.driver) self.always_button = AlwaysButton(self.driver) - self.browser_cross_icon = BrowserCrossIcon(self.driver) self.browser_refresh_page_button = BrowserRefreshPageButton(self.driver) def wait_for_d_aap_to_load(self, wait_time=35):