From 927d67f3caea884d72baa3281a3f607914d4e6d1 Mon Sep 17 00:00:00 2001 From: Serhy Date: Mon, 5 Jul 2021 22:28:55 +0300 Subject: [PATCH] Update tests to check ToS link and fix for chats in activity centre Signed-off-by: Serhy --- .../ui/screens/onboarding/intro/views.cljs | 6 ++-- .../account_management/test_create_account.py | 4 ++- .../atomic/account_management/test_profile.py | 29 +++++++++++++++--- .../atomic/chats/test_chats_management.py | 3 +- test/appium/views/base_element.py | 8 +++++ test/appium/views/home_view.py | 10 +++++-- test/appium/views/profile_view.py | 10 +++++++ test/appium/views/sign_in_view.py | 30 ++++++++++++++----- test/appium/views/web_views/base_web_view.py | 2 ++ 9 files changed, 85 insertions(+), 17 deletions(-) diff --git a/src/status_im/ui/screens/onboarding/intro/views.cljs b/src/status_im/ui/screens/onboarding/intro/views.cljs index 5c36467e17..896f5e94d2 100644 --- a/src/status_im/ui/screens/onboarding/intro/views.cljs +++ b/src/status_im/ui/screens/onboarding/intro/views.cljs @@ -161,7 +161,8 @@ (i18n/label :t/accept-status-tos-prefix) [{:style (merge {:color colors/blue} typography/font-medium) - :on-press #(re-frame/dispatch [:open-modal :terms-of-service])} + :on-press #(re-frame/dispatch [:open-modal :terms-of-service]) + :accessibility-label :terms-of-service-link} " " (i18n/label :t/terms-of-service)]]]] [react/view {:style {:margin-bottom 24}} @@ -173,5 +174,6 @@ (i18n/label :t/get-started)]] [react/text {:style {:color colors/blue} - :on-press #(re-frame/dispatch [:open-modal :privacy-policy])} + :on-press #(re-frame/dispatch [:open-modal :privacy-policy]) + :accessibility-label :privacy-policy-link} (i18n/label :t/privacy-policy)]]]) diff --git a/test/appium/tests/atomic/account_management/test_create_account.py b/test/appium/tests/atomic/account_management/test_create_account.py index 67e047f3a7..a6b1686793 100644 --- a/test/appium/tests/atomic/account_management/test_create_account.py +++ b/test/appium/tests/atomic/account_management/test_create_account.py @@ -92,8 +92,10 @@ class TestCreateAccount(SingleDeviceTestCase): @marks.high def test_home_view(self): sign_in = SignInView(self.driver) - sign_in.accept_tos_checkbox.click() sign_in.get_started_button.click() + if sign_in.generate_key_button.is_element_displayed(): + self.errors.append("Agree with ToS is not mandatory to proceed onboarding!") + sign_in.accept_tos_checkbox.click() sign_in.generate_key_button.click() from views.sign_in_view import MultiAccountButton account_button = sign_in.get_multiaccount_by_position(position=random.randint(1, 4), element_class=MultiAccountButton) diff --git a/test/appium/tests/atomic/account_management/test_profile.py b/test/appium/tests/atomic/account_management/test_profile.py index a7006d1e55..b8dcf9fdc2 100644 --- a/test/appium/tests/atomic/account_management/test_profile.py +++ b/test/appium/tests/atomic/account_management/test_profile.py @@ -333,19 +333,33 @@ class TestProfileSingleDevice(SingleDeviceTestCase): @marks.testrail_id(5453) @marks.medium - def test_privacy_policy_node_version_need_help_in_profile(self): + @marks.flaky + def test_privacy_policy_terms_of_use_node_version_need_help_in_profile(self): signin = SignInView(self.driver) no_link_found_error_msg = 'Could not find privacy policy link at' no_link_open_error_msg = 'Could not open our privacy policy from' + no_link_tos_error_msg = 'Could not open Terms of Use from' - signin.just_fyi("Checking privacy policy from sign in and from profile") - if not signin.privacy_policy_link.is_element_displayed(): + signin.just_fyi("Checking privacy policy from sign in") + if not signin.privacy_policy_link.is_element_present(): self.driver.fail('%s Sign in view!' % no_link_found_error_msg) web_page = signin.privacy_policy_link.click() web_page.open_in_webview() if not web_page.policy_summary.is_element_displayed(): self.errors.append('%s Sign in view!' % no_link_open_error_msg) web_page.close_privacy_policy_button.click() + + signin.just_fyi("Checking Terms of Use from sign") + if not signin.terms_of_use_link.is_element_displayed(): + self.driver.fail("No Terms of Use link on Sign in view!") + web_page = signin.terms_of_use_link.click() + web_page.open_in_webview() + web_page.wait_for_d_aap_to_load() + web_page.swipe_by_custom_coordinates(0.5,0.8,0.5,0.4) + if not web_page.terms_of_use_summary.is_element_displayed(): + self.errors.append('%s Sign in view!' % no_link_tos_error_msg) + web_page.close_privacy_policy_button.click() + home = signin.create_user() profile = home.profile_button.click() profile.about_button.click() @@ -354,6 +368,13 @@ class TestProfileSingleDevice(SingleDeviceTestCase): self.errors.append('%s Profile about view!' % no_link_open_error_msg) web_page.click_system_back_button() + profile.terms_of_use_button.click() + web_page.wait_for_d_aap_to_load() + web_page.swipe_by_custom_coordinates(0.5,0.8,0.5,0.4) + if not web_page.terms_of_use_summary.is_element_displayed(): + self.errors.append('%s Profile about view!' % no_link_tos_error_msg) + web_page.click_system_back_button() + signin.just_fyi("Checking that version match expected format and can be copied") app_version = profile.app_version_text.text node_version = profile.node_version_text.text @@ -384,7 +405,7 @@ class TestProfileSingleDevice(SingleDeviceTestCase): self.errors.append("Mail client is not opened when submitting bug") profile.click_system_back_button() profile.request_a_feature_button.click() - if not profile.element_by_text("#support").is_element_displayed(): + if not profile.element_by_text("#support").is_element_displayed(): self.errors.append("Support channel is not suggested for requesting a feature") self.errors.verify_no_errors() diff --git a/test/appium/tests/atomic/chats/test_chats_management.py b/test/appium/tests/atomic/chats/test_chats_management.py index 26c8e72735..34ee5f04e4 100644 --- a/test/appium/tests/atomic/chats/test_chats_management.py +++ b/test/appium/tests/atomic/chats/test_chats_management.py @@ -846,7 +846,8 @@ class TestChatManagementMultipleDevice(MultipleDeviceTestCase): self.errors.append("Reply is not present in message received in public chat") device_1.just_fyi('Can reply to link') - link_message, reply = 'Test with link: https://status.im/', 'reply to link' + link_message, reply = 'Test with link: https://status.im/ here should be nothing unusual.' \ + ' Just a regular reply.', 'reply to link' chat_public_1.send_message(link_message) chat_public_2.quote_message(link_message[:10]) chat_public_2.send_message(reply) diff --git a/test/appium/views/base_element.py b/test/appium/views/base_element.py index c7f349610f..ed4d4e7e48 100644 --- a/test/appium/views/base_element.py +++ b/test/appium/views/base_element.py @@ -259,6 +259,14 @@ class BaseElement(object): return timeit(wrapper, number=1) + def click_inside_element_by_coordinate(self, rel_x=0.8, rel_y=0.8, times_to_click=1): + element = self.find_element() + location = element.location + size = element.size + x = int(location['x'] + size['width'] * rel_x) + y = int(location['y'] + size['height'] * rel_y) + [self.driver.tap([(x, y)], 150) for _ in range(times_to_click)] + @staticmethod def get_translation_by_key(key): return transl[key] diff --git a/test/appium/views/home_view.py b/test/appium/views/home_view.py index a9034dc032..a781245f2d 100644 --- a/test/appium/views/home_view.py +++ b/test/appium/views/home_view.py @@ -71,6 +71,11 @@ class ChatElement(SilentButton): return ChatImage(self.driver) +class ChatElementInAC(SilentButton): + def __init__(self, driver, username_part): + self.username = username_part + super().__init__(driver, xpath="//*[@content-desc='chat-name-or-sender-text'][starts-with(@text,'%s')]/.." % username_part) + class HomeView(BaseView): def __init__(self, driver): @@ -135,8 +140,9 @@ class HomeView(BaseView): chat_element = ChatElement(self.driver, username[:25]) if not chat_element.is_element_displayed(): self.notifications_unread_badge.wait_and_click(30) - chat_element.wait_for_element(20) - chat_element.click() + chat_in_ac = ChatElementInAC(self.driver, username[:25]) + chat_in_ac.wait_for_element(20) + chat_in_ac.click() self.home_button.double_click() return chat_element diff --git a/test/appium/views/profile_view.py b/test/appium/views/profile_view.py index 8883fbe733..3155e225e1 100644 --- a/test/appium/views/profile_view.py +++ b/test/appium/views/profile_view.py @@ -151,6 +151,15 @@ class PrivacyPolicyButton(Button): return BaseWebView(self.driver) +class TermsOfUseButton(Button): + def __init__(self, driver): + super().__init__(driver, accessibility_id="terms-of-service") + + def navigate(self): + from views.web_views.base_web_view import BaseWebView + return BaseWebView(self.driver) + + class ProfilePictureElement(Button): def __init__(self, driver): super().__init__(driver, accessibility_id="chat-icon") @@ -275,6 +284,7 @@ class ProfileView(BaseView): #About self.about_button = AboutButton(self.driver) self.privacy_policy_button = PrivacyPolicyButton(self.driver) + self.terms_of_use_button = TermsOfUseButton(self.driver) self.app_version_text = Text(self.driver, xpath="//*[@content-desc='app-version']//android.widget.TextView[2]") self.node_version_text = Text(self.driver, xpath="//*[@content-desc='node-version']//android.widget.TextView[2]") diff --git a/test/appium/views/sign_in_view.py b/test/appium/views/sign_in_view.py index ec91443c76..5f5578f559 100644 --- a/test/appium/views/sign_in_view.py +++ b/test/appium/views/sign_in_view.py @@ -85,15 +85,30 @@ class KeycardKeyStorageButton(Button): class PrivacyPolicyLink(Button): def __init__(self, driver): - super(PrivacyPolicyLink, self).__init__(driver, xpath="//*[contains(@text, 'Privacy policy')]") + super(PrivacyPolicyLink, self).__init__(driver, accessibility_id="privacy-policy-link") def click(self): - element = self.find_element() - location = element.location - size = element.size - x = int(location['x'] + size['width'] * 0.9) - y = int(location['y'] + size['height'] * 0.8) - TouchAction(self.driver).tap(None, x, y).perform() + self.driver.info('Click on link %s' % self.name) + self.click_until_absense_of_element(TermsOfUseLink(self.driver)) + return self.navigate() + + def navigate(self): + from views.web_views.base_web_view import BaseWebView + return BaseWebView(self.driver) + + +class TermsOfUseLink(Button): + def __init__(self, driver): + super(TermsOfUseLink, self).__init__(driver, xpath="//*[contains(@text, 'Terms of Use')]") + + def click(self): + counter = 0 + while PrivacyPolicyLink(self.driver).is_element_present(1) and counter <= 5: + try: + self.click_inside_element_by_coordinate(times_to_click=2) + counter += 1 + except (NoSuchElementException): + return self.navigate() self.driver.info('Click on link %s' % self.name) return self.navigate() @@ -121,6 +136,7 @@ class SignInView(BaseView): self.enable_notifications_button = Button(self.driver, accessibility_id="enable-notifications") self.maybe_later_button = Button(self.driver, accessibility_id="maybe-later") self.privacy_policy_link = PrivacyPolicyLink(self.driver) + self.terms_of_use_link = TermsOfUseLink(self.driver) self.lets_go_button = Button(self.driver, accessibility_id="lets-go-button") self.keycard_storage_button = KeycardKeyStorageButton(self.driver) self.first_username_on_choose_chat_name = Text(self.driver, diff --git a/test/appium/views/web_views/base_web_view.py b/test/appium/views/web_views/base_web_view.py index d3686b0169..cd268bf1e9 100644 --- a/test/appium/views/web_views/base_web_view.py +++ b/test/appium/views/web_views/base_web_view.py @@ -11,6 +11,8 @@ class BaseWebView(BaseView): self.progress_bar_icon = Button(self.driver, xpath="//android.widget.ProgressBar") self.url_edit_box_lock_icon = Button(self.driver, xpath="'(//android.view.ViewGroup[@content-desc='icon'])[2]") self.policy_summary = Button(self.driver, xpath="//*[@content-desc='Status Privacy Policy'] | //*[@text='Status Privacy Policyy']") + self.terms_of_use_summary = Button(self.driver, xpath="//*[@content-desc='Status App Terms of Use']") + self.browser_previous_page_button = Button(self.driver, accessibility_id="previous-page-button") self.browser_next_page_button = Button(self.driver, accessibility_id="next-page-button")