From b8e41cb4642a4c0349bc8ef1e0d0a96922fca89b Mon Sep 17 00:00:00 2001 From: Anton Danchenko Date: Wed, 23 May 2018 16:02:45 +0300 Subject: [PATCH] added public chat management test, disabled group chat tests, added more errors to the rerun tests list Signed-off-by: yevh-berdnyk --- test/appium/support/test_rerun.py | 6 ++- test/appium/tests/api_requests.py | 2 +- test/appium/tests/conftest.py | 8 +-- test/appium/tests/marks.py | 1 + test/appium/tests/test_chat_management.py | 63 ++++++++++++++++++++++- test/appium/tests/test_messaging.py | 27 +++++----- test/appium/tests/test_sanity.py | 2 + test/appium/tests/test_transaction.py | 2 + test/appium/views/chat_view.py | 32 ++++++++++++ test/appium/views/home_view.py | 1 + 10 files changed, 125 insertions(+), 19 deletions(-) diff --git a/test/appium/support/test_rerun.py b/test/appium/support/test_rerun.py index 47163a983a..37aa71be0c 100644 --- a/test/appium/support/test_rerun.py +++ b/test/appium/support/test_rerun.py @@ -2,7 +2,11 @@ RERUN_ERRORS = [ 'Original error: Error: ESOCKETTIMEDOUT', "The server didn't respond in time.", 'An unknown server-side error occurred while processing the command.', - 'Could not proxy command to remote server. Original error: Error: socket hang up' + 'Could not proxy command to remote server. Original error: Error: socket hang up', + 'The server returned an invalid or incomplete response.', + '502 Bad Gateway', + 'Unexpected server error', + '504 Gateway Time-out' ] diff --git a/test/appium/tests/api_requests.py b/test/appium/tests/api_requests.py index 00580b90ae..c9be96438b 100644 --- a/test/appium/tests/api_requests.py +++ b/test/appium/tests/api_requests.py @@ -32,7 +32,7 @@ def find_transaction_on_ropsten(address: str, transaction_hash: str): pytest.fail('Transaction is not found in Ropsten network') -def verify_balance_is_updated(initial_balance, recipient_address, wait_time=240): +def verify_balance_is_updated(initial_balance, recipient_address, wait_time=360): counter = 0 while True: if counter >= wait_time: diff --git a/test/appium/tests/conftest.py b/test/appium/tests/conftest.py index 26e4502ee9..39b43cfe4d 100644 --- a/test/appium/tests/conftest.py +++ b/test/appium/tests/conftest.py @@ -42,10 +42,10 @@ def pytest_addoption(parser): action='store', default=None, help='Pull Request number') - parser.addoption('--nightly', + parser.addoption('--testrail_report', action='store', default=False, - help='boolean; For running extended test suite against nightly build') + help='boolean; For creating testrail report per run') parser.addoption('--rerun_count', action='store', default=0, @@ -74,7 +74,7 @@ def pytest_configure(config): test_suite_data.apk_name = ([i for i in [i for i in config.getoption('apk').split('/') if '.apk' in i]])[0] if is_master(config): - if config.getoption('nightly'): + if config.getoption('testrail_report'): testrail_report.add_run(test_suite_data.apk_name) if config.getoption('env') == 'sauce': if not is_uploaded(): @@ -99,7 +99,7 @@ def pytest_unconfigure(config): repo = Github(github_token).get_user('status-im').get_repo('status-react') pull = repo.get_pull(int(config.getoption('pr_number'))) pull.create_issue_comment(github_report.build_html_report()) - if config.getoption('nightly'): + if config.getoption('testrail_report'): testrail_report.add_results() diff --git a/test/appium/tests/marks.py b/test/appium/tests/marks.py index 41b31a4ea6..7e0d83570d 100644 --- a/test/appium/tests/marks.py +++ b/test/appium/tests/marks.py @@ -8,3 +8,4 @@ chat = pytest.mark.chat chat_management = pytest.mark.chat_management transaction = pytest.mark.transaction wallet = pytest.mark.wallet +skip = pytest.mark.skip diff --git a/test/appium/tests/test_chat_management.py b/test/appium/tests/test_chat_management.py index 16c2312f70..38fae1cc04 100644 --- a/test/appium/tests/test_chat_management.py +++ b/test/appium/tests/test_chat_management.py @@ -1,10 +1,12 @@ import time import pytest +import random +import string +import emoji from tests import transaction_users, marks, group_chat_users, get_current_time from tests.base_test_case import MultipleDeviceTestCase, SingleDeviceTestCase from views.sign_in_view import SignInView - @marks.all @marks.chat_management class TestChatManagementMultiple(MultipleDeviceTestCase): @@ -71,7 +73,65 @@ class TestChatManagementMultiple(MultipleDeviceTestCase): device_1_chat_view = device_1_home_view.start_1_1_chat(self.senders['h_user']['username']) if not device_1_chat_view.no_messages_in_chat.is_element_present(): pytest.fail('Message history is shown in a chat which was previously deleted') + self.verify_no_errors() + @marks.testrail_case_id(3419) + def test_public_chat_management(self): + self.create_drivers(2) + device_1, device_2 = SignInView(self.drivers[0]), SignInView(self.drivers[1]) + users = [] + chat_name = ''.join(random.choice(string.ascii_lowercase) for _ in range(19)) + for sign_in in device_1, device_2: + users.append(sign_in.create_user()) + home = sign_in.get_home_view() + home.join_public_chat(chat_name) + chat_1, chat_2 = device_1.get_chat_view(), device_2.get_chat_view() + message_1, message_2, message_3, message_4, message_5 = 'm1', 'm2', 'm3', 'm4', 'm5' + chat_1.chat_message_input.send_keys(message_1) + chat_1.send_message_button.click() + chat_2.element_by_text(message_1).is_element_present() + + chat_2.chat_message_input.send_keys(message_2) + chat_2.send_message_button.click() + chat_1.element_by_text(message_2).is_element_present() + chat_1.chat_options.click() + chat_1.clear_history_button.click() + chat_1.clear_button.click() + chat_2.chat_message_input.send_keys(message_3) + chat_2.send_message_button.click() + chat_1.element_by_text(message_3).is_element_present() + for message in message_1, message_2: + if chat_1.element_starts_with_text(message).is_element_present(): + self.errors.append("Message '%s' is shown, but public chat history has been cleared" % message) + chat_2.chat_options.click() + chat_2.delete_chat_button.click() + chat_2.delete_button.click() + chat_1.chat_message_input.send_keys(message_4) + chat_1.send_message_button.click() + public_chat_name = '#' + chat_name + chat_2.element_by_text(public_chat_name).click() + for message in message_1, message_2, message_3, message_4: + if not chat_2.element_starts_with_text(message).is_element_present(): + self.errors.append("Message '%s' is not shown in public chat which has been deleted" % message) + chat_1.chat_options.click() + chat_1.leave_chat_button.click() + chat_1.leave_button.click() + chat_2.chat_message_input.send_keys(message_5) + chat_2.send_message_button.click() + if chat_1.element_starts_with_text(message_5).is_element_present(20): + self.errors.append("Message '%s' is shown, but the user left public chat" % message_5) + + chat_2.get_back_to_home_view() + home_2, home_1 = chat_2.get_home_view(), chat_1.get_home_view() + home_2.swipe_and_delete_chat('#' + chat_name) + + for home in home_2, home_1: + home.relogin() + if home_1.element_by_text(public_chat_name).is_element_present(20): + self.errors.append("Public chat '%s' is shown, but the user left public chat" % public_chat_name) + if home_2.element_by_text(public_chat_name).is_element_present(20): + self.errors.append("Public chat '%s' is shown, but the chat has been deleted via 'swipe to delete'" + % public_chat_name) self.verify_no_errors() @@ -96,6 +156,7 @@ class TestChatManagement(SingleDeviceTestCase): pytest.fail('The chat is present after re-login') @marks.testrail_case_id(3418) + @marks.skip def test_swipe_and_delete_group_chat(self): recipient = group_chat_users['A_USER'] sign_in_view = SignInView(self.driver) diff --git a/test/appium/tests/test_messaging.py b/test/appium/tests/test_messaging.py index 75913af770..ac85b7c4a0 100644 --- a/test/appium/tests/test_messaging.py +++ b/test/appium/tests/test_messaging.py @@ -79,6 +79,7 @@ class TestMessages(MultipleDeviceTestCase): @marks.pr @marks.testrail_case_id(3391) + @marks.skip def test_group_chat_messages_and_delete_chat(self): self.create_drivers(3) @@ -212,19 +213,20 @@ class TestMessages(MultipleDeviceTestCase): if not chat_1.contact_profile_picture.is_element_image_equals_template(file_name): self.errors.append("Updated profile picture is not shown in one-to-one chat") - home_1.get_back_to_home_view() - chat_name = 'a_chat_%s' % get_current_time() - home_1.create_group_chat([username_2], chat_name) - group_chat_1 = home_1.get_chat_view() + # home_1.get_back_to_home_view() + # chat_name = 'a_chat_%s' % get_current_time() + # home_1.create_group_chat([username_2], chat_name) + # group_chat_1 = home_1.get_chat_view() + # + # home_2.get_back_to_home_view() + # group_chat_2 = home_2.get_chat_with_user(chat_name).click() + # message_text = 'test message' + # group_chat_2.chat_message_input.send_keys(message_text) + # group_chat_2.send_message_button.click() + # + # group_chat_1.wait_for_messages(username_2, message_text, self.errors) + # group_chat_1.verify_username_is_shown_per_message(username_2, message_text, self.errors) - home_2.get_back_to_home_view() - group_chat_2 = home_2.get_chat_with_user(chat_name).click() - message_text = 'test message' - group_chat_2.chat_message_input.send_keys(message_text) - group_chat_2.send_message_button.click() - - group_chat_1.wait_for_messages(username_2, message_text, self.errors) - group_chat_1.verify_username_is_shown_per_message(username_2, message_text, self.errors) self.verify_no_errors() @marks.testrail_case_id(3429) @@ -300,6 +302,7 @@ class TestOfflineMessages(MultipleDeviceTestCase): self.verify_no_errors() @marks.testrail_case_id(3430) + @marks.skip def test_offline_messaging_group_chat(self): self.create_drivers(2) device_1, device_2 = self.drivers[0], self.drivers[1] diff --git a/test/appium/tests/test_sanity.py b/test/appium/tests/test_sanity.py index 8618fbcf59..cc98de15ad 100644 --- a/test/appium/tests/test_sanity.py +++ b/test/appium/tests/test_sanity.py @@ -1,4 +1,5 @@ import pytest +from tests import marks from tests import transaction_users, transaction_users_wallet from tests.base_test_case import SingleDeviceTestCase from tests import basic_user @@ -38,6 +39,7 @@ class TestSanity(SingleDeviceTestCase): pytest.fail('Password in logcat!!!', pytrace=False) @pytest.mark.group_chat + @marks.skip def test_group_chat_members(self): sign_in_view = SignInView(self.driver) sign_in_view.create_user() diff --git a/test/appium/tests/test_transaction.py b/test/appium/tests/test_transaction.py index 48c74c7590..5750269aff 100644 --- a/test/appium/tests/test_transaction.py +++ b/test/appium/tests/test_transaction.py @@ -66,6 +66,7 @@ class TestTransaction(SingleDeviceTestCase): send_transaction_view.find_full_text('Wrong password', 20) @marks.pr + @marks.skip @marks.testrail_case_id(3403) def test_transaction_send_command_group_chat(self): recipient = transaction_users['A_USER'] @@ -218,6 +219,7 @@ class TestTransactions(MultipleDeviceTestCase): @marks.pr @marks.testrail_case_id(3408) + @marks.skip def test_send_eth_to_request_in_group_chat(self): recipient = transaction_users['E_USER'] sender = self.senders['f_user'] = transaction_users['F_USER'] diff --git a/test/appium/views/chat_view.py b/test/appium/views/chat_view.py index 6f0631222d..905b0656e2 100644 --- a/test/appium/views/chat_view.py +++ b/test/appium/views/chat_view.py @@ -76,6 +76,34 @@ class DeleteChatButton(BaseButton): self.locator = self.Locator.xpath_selector('//*[@text="Delete chat"]') +class ClearHistoryButton(BaseButton): + + def __init__(self, driver): + super(ClearHistoryButton, self).__init__(driver) + self.locator = self.Locator.xpath_selector('//*[@text="Clear history"]') + + +class LeaveChatButton(BaseButton): + + def __init__(self, driver): + super(LeaveChatButton, self).__init__(driver) + self.locator = self.Locator.xpath_selector('//*[@text="Leave public chat"]') + + +class ClearButton(BaseButton): + + def __init__(self, driver): + super(ClearButton, self).__init__(driver) + self.locator = self.Locator.xpath_selector('//*[@text="CLEAR"]') + + +class LeaveButton(BaseButton): + + def __init__(self, driver): + super(LeaveButton, self).__init__(driver) + self.locator = self.Locator.xpath_selector('//*[@text="LEAVE"]') + + class ChatSettings(BaseButton): def __init__(self, driver): super(ChatSettings, self).__init__(driver) @@ -171,6 +199,10 @@ class ChatView(BaseView): self.chat_options = ChatMenuButton(self.driver) self.members_button = MembersButton(self.driver) self.delete_chat_button = DeleteChatButton(self.driver) + self.clear_history_button = ClearHistoryButton(self.driver) + self.clear_button = ClearButton(self.driver) + self.leave_chat_button = LeaveChatButton(self.driver) + self.leave_button = LeaveButton(self.driver) self.chat_settings = ChatSettings(self.driver) self.view_profile_button = ViewProfileButton(self.driver) diff --git a/test/appium/views/home_view.py b/test/appium/views/home_view.py index 6a436f3f9b..ed9f6d2aa4 100644 --- a/test/appium/views/home_view.py +++ b/test/appium/views/home_view.py @@ -112,6 +112,7 @@ class HomeView(BaseView): start_new_chat = self.plus_button.click() start_new_chat.join_public_chat_button.click() start_new_chat.chat_name_editbox.send_keys(chat_name) + time.sleep(2) start_new_chat.confirm() def get_public_key(self):