From 62a3ed6138e1f86b55863e16a694a2a629e39f7f Mon Sep 17 00:00:00 2001 From: Yevheniia Berdnyk Date: Fri, 17 Jun 2022 03:57:19 +0300 Subject: [PATCH] Fix for stopping sauce sessions in teardown --- test/appium/tests/base_test_case.py | 16 ++ test/appium/tests/conftest.py | 14 +- .../critical/chats/test_1_1_public_chats.py | 151 +++++++------ .../tests/critical/chats/test_group_chat.py | 45 ++-- .../onboarding/test_onboarding_flows.py | 38 ++-- .../critical/test_pairing_devices_sync.py | 132 ++++++----- .../critical/test_public_chat_browsing.py | 42 ++-- .../test_send_tx_dapp_keycard.py | 62 +++--- .../critical/wallet_and_tx/test_wallet.py | 30 +-- .../tests/medium/test_activity_center.py | 28 +-- .../tests/medium/test_browser_profile.py | 13 +- test/appium/tests/medium/test_chats_m.py | 209 +++++++++--------- .../test_deeplink_chat_share_profile.py | 54 ++--- .../medium/test_pairing_devices_sync_m.py | 106 ++++----- .../tests/medium/test_permissions_scan_qr.py | 21 +- test/appium/tests/medium/test_profile_m.py | 78 +++---- .../tests/medium/test_wallet_keycard_m.py | 51 +++-- 17 files changed, 555 insertions(+), 535 deletions(-) diff --git a/test/appium/tests/base_test_case.py b/test/appium/tests/base_test_case.py index fc5fa22a70..6842f7552c 100644 --- a/test/appium/tests/base_test_case.py +++ b/test/appium/tests/base_test_case.py @@ -330,6 +330,14 @@ class LocalSharedMultipleDeviceTestCase(AbstractTestCase): except WebDriverException: pass + @pytest.fixture(scope='class', autouse=True) + def prepare(self, request): + try: + request.cls.prepare_devices(request) + finally: + for item, value in request.__dict__.items(): + setattr(request.cls, item, value) + @classmethod def teardown_class(cls): for driver in cls.drivers: @@ -367,6 +375,14 @@ class SauceSharedMultipleDeviceTestCase(AbstractTestCase): geth = {geth_names[i]: geth_contents[i] for i in range(len(geth_names))} test_suite_data.current_test.geth_paths = self.github_report.save_geth(geth) + @pytest.fixture(scope='class', autouse=True) + def prepare(self, request): + try: + request.cls.prepare_devices(request) + finally: + for item, value in request.__dict__.items(): + setattr(request.cls, item, value) + @classmethod def teardown_class(cls): requests_session = requests.Session() diff --git a/test/appium/tests/conftest.py b/test/appium/tests/conftest.py index 110e54a40e..4ffc8246d5 100644 --- a/test/appium/tests/conftest.py +++ b/test/appium/tests/conftest.py @@ -217,6 +217,8 @@ def pytest_runtest_makereport(item, call): outcome = yield report = outcome.get_result() + is_sauce_env = item.config.getoption('env') == 'sauce' + def catch_error(): error = report.longreprtext failure_pattern = 'E.*Message:|E.*Error:|E.*Failed:' @@ -226,32 +228,36 @@ def pytest_runtest_makereport(item, call): return error if report.when == 'setup': + is_group = "xdist_group" in item.keywords._markers or "xdist_group" in item.parent.keywords._markers error_intro, error = 'Test setup failed:', '' final_error = '%s %s' % (error_intro, error) if hasattr(report, 'wasxfail'): if '[NOTRUN]' in report.wasxfail: test_suite_data.set_current_test(item.name, testrail_case_id=get_testrail_case_id(item)) test_suite_data.current_test.create_new_testrun() - if "xdist_group" in item.keywords._markers: + if is_group: test_suite_data.current_test.group_name = item.instance.__class__.__name__ error_intro, error = 'Test is not run, e2e blocker ', report.wasxfail final_error = "%s [[%s]]" % (error_intro, error) else: - if "xdist_group" in item.keywords._markers: + if is_group: test_suite_data.current_test.group_name = item.instance.__class__.__name__ error = catch_error() final_error = '%s %s [[%s]]' % (error_intro, error, report.wasxfail) else: - if "xdist_group" in item.keywords._markers and report.failed: + if is_group and report.failed: test_suite_data.current_test.group_name = item.instance.__class__.__name__ error = catch_error() final_error = '%s %s' % (error_intro, error) + if is_sauce_env: + update_sauce_jobs(test_suite_data.current_test.group_name, + test_suite_data.current_test.testruns[-1].jobs, + report.passed) if error: test_suite_data.current_test.testruns[-1].error = final_error github_report.save_test(test_suite_data.current_test) if report.when == 'call': - is_sauce_env = item.config.getoption('env') == 'sauce' current_test = test_suite_data.current_test error = catch_error() if report.failed: diff --git a/test/appium/tests/critical/chats/test_1_1_public_chats.py b/test/appium/tests/critical/chats/test_1_1_public_chats.py index 2f78b8d71c..11b67d041b 100644 --- a/test/appium/tests/critical/chats/test_1_1_public_chats.py +++ b/test/appium/tests/critical/chats/test_1_1_public_chats.py @@ -13,23 +13,23 @@ import pytest @marks.critical class TestCommandsMultipleDevicesMerged(MultipleSharedDeviceTestCase): - @classmethod - def setup_class(cls): - cls.drivers, cls.loop = create_shared_drivers(2) - cls.device_1, cls.device_2 = SignInView(cls.drivers[0]), SignInView(cls.drivers[1]) - cls.sender = transaction_senders['ETH_STT_3'] - cls.home_1 = cls.device_1.recover_access(passphrase=cls.sender['passphrase'], enable_notifications=True) - cls.home_2 = cls.device_2.create_user() - for home in cls.home_1, cls.home_2: + def prepare_devices(self): + self.drivers, self.loop = create_shared_drivers(2) + self.device_1, self.device_2 = SignInView(self.drivers[0]), SignInView(self.drivers[1]) + self.sender = transaction_senders['ETH_STT_3'] + self.home_1 = self.device_1.recover_access(passphrase=self.sender['passphrase'], enable_notifications=True) + self.home_2 = self.device_2.create_user() + for home in self.home_1, self.home_2: profile = home.profile_button.click() profile.profile_notifications_button.scroll_and_click() profile.wallet_push_notifications.click() - cls.recipient_public_key, cls.recipient_username = cls.home_2.get_public_key_and_username(return_username=True) - cls.wallet_1, cls.wallet_2 = cls.home_1.wallet_button.click(), cls.home_2.wallet_button.click() - [wallet.home_button.click() for wallet in (cls.wallet_1, cls.wallet_2)] - cls.chat_1 = cls.home_1.add_contact(cls.recipient_public_key) - cls.chat_1.send_message("hello!") - cls.account_name_1 = cls.wallet_1.status_account_name + self.recipient_public_key, self.recipient_username = self.home_2.get_public_key_and_username( + return_username=True) + self.wallet_1, self.wallet_2 = self.home_1.wallet_button.click(), self.home_2.wallet_button.click() + [wallet.home_button.click() for wallet in (self.wallet_1, self.wallet_2)] + self.chat_1 = self.home_1.add_contact(self.recipient_public_key) + self.chat_1.send_message("hello!") + self.account_name_1 = self.wallet_1.status_account_name @marks.testrail_id(6253) def test_1_1_chat_command_send_tx_eth_outgoing_tx_push(self): @@ -212,20 +212,19 @@ class TestCommandsMultipleDevicesMerged(MultipleSharedDeviceTestCase): @marks.critical class TestOneToOneChatMultipleSharedDevices(MultipleSharedDeviceTestCase): - @classmethod - def setup_class(cls): - cls.drivers, cls.loop = create_shared_drivers(2) - cls.device_1, cls.device_2 = SignInView(cls.drivers[0]), SignInView(cls.drivers[1]) - cls.home_1 = cls.device_1.create_user(enable_notifications=True) - cls.home_2 = cls.device_2.create_user(enable_notifications=True) - cls.profile_1 = cls.home_1.profile_button.click() - cls.default_username_1 = cls.profile_1.default_username_text.text - cls.profile_1.home_button.click() - cls.public_key_2, cls.default_username_2 = cls.home_2.get_public_key_and_username(return_username=True) - cls.chat_1 = cls.home_1.add_contact(cls.public_key_2) - cls.chat_1.send_message('hey') - cls.home_2.home_button.double_click() - cls.chat_2 = cls.home_2.get_chat(cls.default_username_1).click() + def prepare_devices(self): + self.drivers, self.loop = create_shared_drivers(2) + self.device_1, self.device_2 = SignInView(self.drivers[0]), SignInView(self.drivers[1]) + self.home_1 = self.device_1.create_user(enable_notifications=True) + self.home_2 = self.device_2.create_user(enable_notifications=True) + self.profile_1 = self.home_1.profile_button.click() + self.default_username_1 = self.profile_1.default_username_text.text + self.profile_1.home_button.click() + self.public_key_2, self.default_username_2 = self.home_2.get_public_key_and_username(return_username=True) + self.chat_1 = self.home_1.add_contact(self.public_key_2) + self.chat_1.send_message('hey') + self.home_2.home_button.double_click() + self.chat_2 = self.home_2.get_chat(self.default_username_1).click() @marks.testrail_id(6315) def test_1_1_chat_message_reaction(self): @@ -621,33 +620,32 @@ class TestOneToOneChatMultipleSharedDevices(MultipleSharedDeviceTestCase): @marks.critical class TestContactBlockMigrateKeycardMultipleSharedDevices(MultipleSharedDeviceTestCase): - @classmethod - def setup_class(cls): - cls.drivers, cls.loop = create_shared_drivers(2) - cls.device_1, cls.device_2 = SignInView(cls.drivers[0]), SignInView(cls.drivers[1]) - cls.sender = transaction_senders['ETH_2'] - cls.nick = "FFOO_brak!1234" - cls.message = cls.device_1.get_random_message() - cls.pub_chat_name = cls.device_1.get_random_chat_name() - cls.home_1 = cls.device_1.recover_access(cls.sender['passphrase'], keycard=True) - cls.home_2 = cls.device_2.create_user() - cls.profile_2 = cls.home_2.profile_button.click() - cls.profile_2.privacy_and_security_button.click() - cls.profile_2.backup_recovery_phrase_button.click() - recovery_phrase = cls.profile_2.backup_recovery_phrase() - cls.recovery_phrase = ' '.join(recovery_phrase.values()) - cls.public_key_2, cls.default_username_2 = cls.home_2.get_public_key_and_username(return_username=True) - cls.chat_1 = cls.home_1.add_contact(cls.public_key_2, add_in_contacts=False) - cls.chat_1.chat_options.click() - cls.chat_1.view_profile_button.click() - cls.chat_1.set_nickname(cls.nick) - [home.home_button.click() for home in [cls.home_1, cls.home_2]] - cls.home_2.add_contact(cls.sender['public_key']) - cls.home_2.home_button.click() - [home.join_public_chat(cls.pub_chat_name) for home in [cls.home_1, cls.home_2]] - cls.chat_2 = cls.home_2.get_chat_view() - cls.chat_2.send_message(cls.message) - [home.home_button.click() for home in [cls.home_1, cls.home_2]] + def prepare_devices(self): + self.drivers, self.loop = create_shared_drivers(2) + self.device_1, self.device_2 = SignInView(self.drivers[0]), SignInView(self.drivers[1]) + self.sender = transaction_senders['ETH_2'] + self.nick = "FFOO_brak!1234" + self.message = self.device_1.get_random_message() + self.pub_chat_name = self.device_1.get_random_chat_name() + self.home_1 = self.device_1.recover_access(self.sender['passphrase'], keycard=True) + self.home_2 = self.device_2.create_user() + self.profile_2 = self.home_2.profile_button.click() + self.profile_2.privacy_and_security_button.click() + self.profile_2.backup_recovery_phrase_button.click() + recovery_phrase = self.profile_2.backup_recovery_phrase() + self.recovery_phrase = ' '.join(recovery_phrase.values()) + self.public_key_2, self.default_username_2 = self.home_2.get_public_key_and_username(return_username=True) + self.chat_1 = self.home_1.add_contact(self.public_key_2, add_in_contacts=False) + self.chat_1.chat_options.click() + self.chat_1.view_profile_button.click() + self.chat_1.set_nickname(self.nick) + [home.home_button.click() for home in [self.home_1, self.home_2]] + self.home_2.add_contact(self.sender['public_key']) + self.home_2.home_button.click() + [home.join_public_chat(self.pub_chat_name) for home in [self.home_1, self.home_2]] + self.chat_2 = self.home_2.get_chat_view() + self.chat_2.send_message(self.message) + [home.home_button.click() for home in [self.home_1, self.home_2]] @marks.testrail_id(702186) def test_keycard_command_send_tx_eth_1_1_chat(self): @@ -963,26 +961,25 @@ class TestContactBlockMigrateKeycardMultipleSharedDevices(MultipleSharedDeviceTe @marks.critical class TestEnsStickersMultipleDevicesMerged(MultipleSharedDeviceTestCase): - @classmethod - def setup_class(cls): - cls.drivers, cls.loop = create_shared_drivers(2) - cls.device_1, cls.device_2 = SignInView(cls.drivers[0]), SignInView(cls.drivers[1]) - cls.sender, cls.reciever = transaction_senders['ETH_3'], ens_user - cls.home_1 = cls.device_1.recover_access(passphrase=cls.sender['passphrase']) - cls.home_2 = cls.device_2.recover_access(ens_user['passphrase'], enable_notifications=True) - cls.ens = '@%s' % cls.reciever['ens'] - cls.pub_chat_name = cls.home_1.get_random_chat_name() - cls.chat_1 = cls.home_1.join_public_chat(cls.pub_chat_name) - cls.chat_2 = cls.home_2.join_public_chat(cls.pub_chat_name) - [home.home_button.double_click() for home in (cls.home_1, cls.home_2)] - cls.profile_2 = cls.home_2.profile_button.click() - cls.profile_2.connect_existing_ens(cls.reciever['ens']) - cls.home_1.add_contact(cls.reciever['ens']) - cls.home_2.home_button.click() - cls.home_2.add_contact(cls.sender['public_key']) + def prepare_devices(self): + self.drivers, self.loop = create_shared_drivers(2) + self.device_1, self.device_2 = SignInView(self.drivers[0]), SignInView(self.drivers[1]) + self.sender, self.reciever = transaction_senders['ETH_3'], ens_user + self.home_1 = self.device_1.recover_access(passphrase=self.sender['passphrase']) + self.home_2 = self.device_2.recover_access(ens_user['passphrase'], enable_notifications=True) + self.ens = '@%s' % self.reciever['ens'] + self.pub_chat_name = self.home_1.get_random_chat_name() + self.chat_1 = self.home_1.join_public_chat(self.pub_chat_name) + self.chat_2 = self.home_2.join_public_chat(self.pub_chat_name) + [home.home_button.double_click() for home in (self.home_1, self.home_2)] + self.profile_2 = self.home_2.profile_button.click() + self.profile_2.connect_existing_ens(self.reciever['ens']) + self.home_1.add_contact(self.reciever['ens']) + self.home_2.home_button.click() + self.home_2.add_contact(self.sender['public_key']) # To avoid activity centre for restored users - [chat.send_message("hey!") for chat in (cls.chat_1, cls.chat_2)] - [home.home_button.double_click() for home in (cls.home_1, cls.home_2)] + [chat.send_message("hey!") for chat in (self.chat_1, self.chat_2)] + [home.home_button.double_click() for home in (self.home_1, self.home_2)] @marks.testrail_id(702152) def test_ens_purchased_in_profile(self): @@ -1105,14 +1102,16 @@ class TestEnsStickersMultipleDevicesMerged(MultipleSharedDeviceTestCase): 'ENS username is not resolved in chat input after selecting it in mention suggestions list!') self.chat_1.send_message_button.click() - self.home_2.just_fyi('check that PN is received and after tap you are redirected to chat, mention is highligted') + self.home_2.just_fyi( + 'check that PN is received and after tap you are redirected to chat, mention is highligted') pn = self.home_2.get_pn(self.reciever['username']) if pn: pn.click() else: self.errors.append('No PN on mention in public chat! ') self.home_2.click_system_back_button(2) - if self.home_2.element_starts_with_text(self.reciever['ens']).is_element_differs_from_template('ment_new.png', 2): + if self.home_2.element_starts_with_text(self.reciever['ens']).is_element_differs_from_template('ment_new.png', + 2): self.errors.append('Mention is not highlighted!') self.errors.verify_no_errors() diff --git a/test/appium/tests/critical/chats/test_group_chat.py b/test/appium/tests/critical/chats/test_group_chat.py index c7764c1053..11ff94e6e1 100644 --- a/test/appium/tests/critical/chats/test_group_chat.py +++ b/test/appium/tests/critical/chats/test_group_chat.py @@ -9,37 +9,36 @@ from views.chat_view import ChatView @marks.critical class TestGroupChatMultipleDeviceMerged(MultipleSharedDeviceTestCase): - @classmethod - def setup_class(cls): - cls.drivers, cls.loop = create_shared_drivers(3) - cls.message_before_adding = 'message before adding new user' - cls.message_to_admin = 'Hey, admin!' + def prepare_devices(self): + self.drivers, self.loop = create_shared_drivers(3) + self.message_before_adding = 'message before adding new user' + self.message_to_admin = 'Hey, admin!' - cls.homes, cls.public_keys, cls.usernames, cls.chats = {}, {}, {}, {} - for key in cls.drivers: - sign_in = SignInView(cls.drivers[key]) - cls.homes[key] = sign_in.create_user(enable_notifications=True) - SignInView(cls.drivers[2]).put_app_to_background_and_back() - cls.public_keys[key], cls.usernames[key] = sign_in.get_public_key_and_username(True) + self.homes, self.public_keys, self.usernames, self.chats = {}, {}, {}, {} + for key in self.drivers: + sign_in = SignInView(self.drivers[key]) + self.homes[key] = sign_in.create_user(enable_notifications=True) + SignInView(self.drivers[2]).put_app_to_background_and_back() + self.public_keys[key], self.usernames[key] = sign_in.get_public_key_and_username(True) sign_in.home_button.click() - SignInView(cls.drivers[0]).put_app_to_background_and_back() - cls.chat_name = cls.homes[0].get_random_chat_name() + SignInView(self.drivers[0]).put_app_to_background_and_back() + self.chat_name = self.homes[0].get_random_chat_name() - cls.homes[0].just_fyi('Admin adds future members to contacts') + self.homes[0].just_fyi('Admin adds future members to contacts') for i in range(1, 3): - cls.homes[0].add_contact(cls.public_keys[i]) - cls.homes[0].home_button.double_click() + self.homes[0].add_contact(self.public_keys[i]) + self.homes[0].home_button.double_click() - cls.homes[0].just_fyi('Member adds admin to contacts to see PNs and put app in background') - cls.homes[1].add_contact(cls.public_keys[0]) - cls.homes[1].home_button.double_click() + self.homes[0].just_fyi('Member adds admin to contacts to see PNs and put app in background') + self.homes[1].add_contact(self.public_keys[0]) + self.homes[1].home_button.double_click() - cls.homes[0].just_fyi('Admin creates group chat') - cls.chats[0] = cls.homes[0].create_group_chat([cls.usernames[1]], cls.chat_name) + self.homes[0].just_fyi('Admin creates group chat') + self.chats[0] = self.homes[0].create_group_chat([self.usernames[1]], self.chat_name) for i in range(1, 3): - cls.chats[i] = ChatView(cls.drivers[i]) + self.chats[i] = ChatView(self.drivers[i]) - cls.chats[0].send_message(cls.message_before_adding) + self.chats[0].send_message(self.message_before_adding) @marks.testrail_id(3994) def test_group_chat_push_system_messages_when_invited(self): diff --git a/test/appium/tests/critical/onboarding/test_onboarding_flows.py b/test/appium/tests/critical/onboarding/test_onboarding_flows.py index 670f552d91..dbbcd0eb63 100644 --- a/test/appium/tests/critical/onboarding/test_onboarding_flows.py +++ b/test/appium/tests/critical/onboarding/test_onboarding_flows.py @@ -12,17 +12,16 @@ from tests.users import basic_user, transaction_senders @marks.critical class TestOnboardingOneDeviceMerged(MultipleSharedDeviceTestCase): - @classmethod - def setup_class(cls): - cls.drivers, cls.loop = create_shared_drivers(1) - cls.sign_in = SignInView(cls.drivers[0]) - cls.password = basic_user['special_chars_password'] + def prepare_devices(self): + self.drivers, self.loop = create_shared_drivers(1) + self.sign_in = SignInView(self.drivers[0]) + self.password = basic_user['special_chars_password'] - cls.home = cls.sign_in.create_user(password=cls.password) - cls.public_chat_name = cls.home.get_random_chat_name() - cls.chat = cls.home.join_public_chat(cls.public_chat_name) - cls.profile = cls.home.profile_button.click() - cls.username = cls.profile.default_username_text.text + self.home = self.sign_in.create_user(password=self.password) + self.public_chat_name = self.home.get_random_chat_name() + self.chat = self.home.join_public_chat(self.public_chat_name) + self.profile = self.home.profile_button.click() + self.username = self.profile.default_username_text.text @marks.testrail_id(700742) def test_onboarding_home_initial_popup(self): @@ -195,7 +194,8 @@ class TestOnboardingOneDeviceMerged(MultipleSharedDeviceTestCase): self.sign_in.just_fyi('Checking case when %s' % cases[1]) self.sign_in.create_password_input.send_keys('123456') - [field.send_keys('123456') for field in (self.sign_in.create_password_input, self.sign_in.confirm_your_password_input)] + [field.send_keys('123456') for field in + (self.sign_in.create_password_input, self.sign_in.confirm_your_password_input)] self.sign_in.confirm_your_password_input.delete_last_symbols(1) self.sign_in.create_password_input.delete_last_symbols(1) self.sign_in.next_button.click() @@ -226,15 +226,15 @@ class TestOnboardingOneDeviceMerged(MultipleSharedDeviceTestCase): @pytest.mark.xdist_group(name="two_1") @marks.critical class TestRestoreOneDeviceMerged(MultipleSharedDeviceTestCase): - @classmethod - def setup_class(cls): - cls.user = transaction_senders['ETH_ADI_STT_2'] - cls.drivers, cls.loop = create_shared_drivers(1) - cls.sign_in = SignInView(cls.drivers[0]) - cls.passphrase = fill_string_with_char(cls.user['passphrase'].upper(), ' ', 3, True, True) - cls.password = basic_user['special_chars_password'] - cls.home = cls.sign_in.recover_access(passphrase=cls.passphrase, password=cls.password) + def prepare_devices(self): + self.user = transaction_senders['ETH_ADI_STT_2'] + self.drivers, self.loop = create_shared_drivers(1) + self.sign_in = SignInView(self.drivers[0]) + self.passphrase = fill_string_with_char(self.user['passphrase'].upper(), ' ', 3, True, True) + self.password = basic_user['special_chars_password'] + + self.home = self.sign_in.recover_access(passphrase=self.passphrase, password=self.password) @marks.testrail_id(700748) def test_restore_uppercase_whitespaces_seed_phrase_special_char_passw_logcat(self): diff --git a/test/appium/tests/critical/test_pairing_devices_sync.py b/test/appium/tests/critical/test_pairing_devices_sync.py index 29224358ab..270b8989b9 100644 --- a/test/appium/tests/critical/test_pairing_devices_sync.py +++ b/test/appium/tests/critical/test_pairing_devices_sync.py @@ -11,27 +11,26 @@ from views.sign_in_view import SignInView @marks.skip class TestPairingMultipleDevicesMerged(MultipleSharedDeviceTestCase): - @classmethod - def setup_class(cls): + def prepare_devices(self): from views.dbs.main_pairing.data import seed_phrase, password - cls.drivers, cls.loop = create_shared_drivers(2) - cls.device_1, cls.device_2 = SignInView(cls.drivers[0]), SignInView(cls.drivers[1]) - cls.home_1 = cls.device_1.import_db(seed_phrase=seed_phrase, import_db_folder_name='main_pairing', - password=password) - cls.home_2 = cls.device_2.recover_access(seed_phrase) + self.drivers, self.loop = create_shared_drivers(2) + self.device_1, self.device_2 = SignInView(self.drivers[0]), SignInView(self.drivers[1]) + self.home_1 = self.device_1.import_db(seed_phrase=seed_phrase, import_db_folder_name='main_pairing', + password=password) + self.home_2 = self.device_2.recover_access(seed_phrase) - cls.home_1.just_fyi('Pair main and secondary devices') - [cls.profile_1, cls.profile_2] = [home.profile_button.click() for home in (cls.home_1, cls.home_2)] - name_1, name_2 = 'device_1', 'a_%s_2' % cls.device_2.get_unique_amount() - cls.profile_2.discover_and_advertise_device(name_2) - cls.profile_1.sync_settings_button.scroll_and_click() - cls.profile_1.devices_button.scroll_to_element() - cls.profile_1.devices_button.click() - cls.home_1.element_by_text_part(name_2).scroll_and_click() - cls.profile_1.sync_all_button.click() - cls.profile_1.sync_all_button.wait_for_visibility_of_element(20) - [profile.get_back_to_home_view() for profile in [cls.profile_1, cls.profile_2]] - [home.home_button.click() for home in [cls.home_1, cls.home_2]] + self.home_1.just_fyi('Pair main and secondary devices') + [self.profile_1, self.profile_2] = [home.profile_button.click() for home in (self.home_1, self.home_2)] + name_1, name_2 = 'device_1', 'a_%s_2' % self.device_2.get_unique_amount() + self.profile_2.discover_and_advertise_device(name_2) + self.profile_1.sync_settings_button.scroll_and_click() + self.profile_1.devices_button.scroll_to_element() + self.profile_1.devices_button.click() + self.home_1.element_by_text_part(name_2).scroll_and_click() + self.profile_1.sync_all_button.click() + self.profile_1.sync_all_button.wait_for_visibility_of_element(20) + [profile.get_back_to_home_view() for profile in [self.profile_1, self.profile_2]] + [home.home_button.click() for home in [self.home_1, self.home_2]] def test_pairing_initial_sync_chats(self): self.profile_2.just_fyi("Check chats and previews") @@ -92,62 +91,61 @@ class TestPairingMultipleDevicesMerged(MultipleSharedDeviceTestCase): @marks.critical class TestPairingSyncMultipleDevicesMerged(MultipleSharedDeviceTestCase): - @classmethod - def setup_class(cls): - cls.drivers, cls.loop = create_shared_drivers(2) - cls.no_contact_nickname = 'no_contact_nickname' - cls.device_1, cls.device_2 = SignInView(cls.drivers[0]), SignInView(cls.drivers[1]) - cls.home_1 = cls.device_1.create_user() + def prepare_devices(self): + self.drivers, self.loop = create_shared_drivers(2) + self.no_contact_nickname = 'no_contact_nickname' + self.device_1, self.device_2 = SignInView(self.drivers[0]), SignInView(self.drivers[1]) + self.home_1 = self.device_1.create_user() - cls.name_1, cls.name_2 = 'device_%s' % cls.drivers[0].number, 'device_%s' % cls.drivers[1].number - cls.message_before_sync, cls.message_after_sync = 'sent before sync', 'sent after sync' - cls.contact_before_sync = basic_user - cls.public_chat_before_sync, cls.public_chat_after_sync = cls.home_1.get_random_chat_name(), 'after-pairing' + self.name_1, self.name_2 = 'device_%s' % self.drivers[0].number, 'device_%s' % self.drivers[1].number + self.message_before_sync, self.message_after_sync = 'sent before sync', 'sent after sync' + self.contact_before_sync = basic_user + self.public_chat_before_sync, self.public_chat_after_sync = self.home_1.get_random_chat_name(), 'after-pairing' - cls.home_1.just_fyi("(main device): get recovery phrase") - cls.profile_1 = cls.home_1.profile_button.click() - cls.profile_1.privacy_and_security_button.click() - cls.profile_1.backup_recovery_phrase_button.click() - cls.profile_1.ok_continue_button.click() - cls.recovery_phrase = cls.profile_1.get_recovery_phrase() - cls.profile_1.close_button.click() - cls.profile_1.home_button.click() - cls.profile_1.get_recovery_phrase() - cls.device_2.put_app_to_background_and_back() + self.home_1.just_fyi("(main device): get recovery phrase") + self.profile_1 = self.home_1.profile_button.click() + self.profile_1.privacy_and_security_button.click() + self.profile_1.backup_recovery_phrase_button.click() + self.profile_1.ok_continue_button.click() + self.recovery_phrase = self.profile_1.get_recovery_phrase() + self.profile_1.close_button.click() + self.profile_1.home_button.click() + self.profile_1.get_recovery_phrase() + self.device_2.put_app_to_background_and_back() - cls.home_1.just_fyi('Add contact, 1-1 chat (main device): 3-random, contact with ENS, start 1-1') - cls.chat_1 = cls.home_1.add_contact(cls.contact_before_sync['public_key']) - cls.chat_1.send_message(cls.message_before_sync) - cls.chat_1.home_button.click() - cls.home_1.add_contact(ens_user['ens']) - cls.chat_1.home_button.click() + self.home_1.just_fyi('Add contact, 1-1 chat (main device): 3-random, contact with ENS, start 1-1') + self.chat_1 = self.home_1.add_contact(self.contact_before_sync['public_key']) + self.chat_1.send_message(self.message_before_sync) + self.chat_1.home_button.click() + self.home_1.add_contact(ens_user['ens']) + self.chat_1.home_button.click() - cls.home_1.just_fyi('Chats, contacts (main device): join public chat, block user, set nickname') - public_chat_1 = cls.home_1.join_public_chat(cls.public_chat_before_sync) + self.home_1.just_fyi('Chats, contacts (main device): join public chat, block user, set nickname') + public_chat_1 = self.home_1.join_public_chat(self.public_chat_before_sync) public_chat_1.home_button.click() - cls.home_1.add_contact(transaction_senders['A']['public_key'], add_in_contacts=False, - nickname=cls.no_contact_nickname) - cls.chat_1.open_user_profile_from_1_1_chat() - cls.chat_1.block_contact() + self.home_1.add_contact(transaction_senders['A']['public_key'], add_in_contacts=False, + nickname=self.no_contact_nickname) + self.chat_1.open_user_profile_from_1_1_chat() + self.chat_1.block_contact() - cls.device_2.just_fyi("(secondary device): restore same multiaccount on another device") - cls.home_2 = cls.device_2.recover_access(passphrase=' '.join(cls.recovery_phrase.values())) - cls.profile_1, cls.profile_2 = cls.home_1.profile_button.click(), cls.home_2.profile_button.click() + self.device_2.just_fyi("(secondary device): restore same multiaccount on another device") + self.home_2 = self.device_2.recover_access(passphrase=' '.join(self.recovery_phrase.values())) + self.profile_1, self.profile_2 = self.home_1.profile_button.click(), self.home_2.profile_button.click() - cls.device_2.just_fyi('Nicknames (main device): set nickname for contact') - cls.profile_1.profile_button.click() - cls.profile_1.open_contact_from_profile(cls.contact_before_sync['username']) - cls.nickname = 'my_basic_user' - cls.chat_1.set_nickname(cls.nickname) - cls.device_1.get_back_to_home_view() + self.device_2.just_fyi('Nicknames (main device): set nickname for contact') + self.profile_1.profile_button.click() + self.profile_1.open_contact_from_profile(self.contact_before_sync['username']) + self.nickname = 'my_basic_user' + self.chat_1.set_nickname(self.nickname) + self.device_1.get_back_to_home_view() - cls.device_2.just_fyi('Pair main and secondary devices') - cls.profile_2.discover_and_advertise_device(cls.name_2) - cls.profile_1.discover_and_advertise_device(cls.name_1) - cls.profile_1.get_toggle_device_by_name(cls.name_2).wait_and_click() - cls.profile_1.sync_all_button.click() - cls.profile_1.sync_all_button.wait_for_visibility_of_element(20) - [device.profile_button.double_click() for device in (cls.profile_1, cls.profile_2)] + self.device_2.just_fyi('Pair main and secondary devices') + self.profile_2.discover_and_advertise_device(self.name_2) + self.profile_1.discover_and_advertise_device(self.name_1) + self.profile_1.get_toggle_device_by_name(self.name_2).wait_and_click() + self.profile_1.sync_all_button.click() + self.profile_1.sync_all_button.wait_for_visibility_of_element(20) + [device.profile_button.double_click() for device in (self.profile_1, self.profile_2)] @marks.testrail_id(702194) def test_pairing_sync_initial_contacts_blocked_users(self): diff --git a/test/appium/tests/critical/test_public_chat_browsing.py b/test/appium/tests/critical/test_public_chat_browsing.py index 54ca857ac6..4ee148164d 100644 --- a/test/appium/tests/critical/test_public_chat_browsing.py +++ b/test/appium/tests/critical/test_public_chat_browsing.py @@ -15,22 +15,21 @@ from selenium.common.exceptions import NoSuchElementException @marks.critical class TestPublicChatMultipleDeviceMerged(MultipleSharedDeviceTestCase): - @classmethod - def setup_class(cls): - cls.drivers, cls.loop = create_shared_drivers(2) - device_1, device_2 = SignInView(cls.drivers[0]), SignInView(cls.drivers[1]) - cls.home_1, cls.home_2 = device_1.create_user(), device_2.create_user() - profile_1 = cls.home_1.profile_button.click() - cls.username_1 = profile_1.default_username_text.text + def prepare_devices(self): + self.drivers, self.loop = create_shared_drivers(2) + device_1, device_2 = SignInView(self.drivers[0]), SignInView(self.drivers[1]) + self.home_1, self.home_2 = device_1.create_user(), device_2.create_user() + profile_1 = self.home_1.profile_button.click() + self.username_1 = profile_1.default_username_text.text profile_1.home_button.click() - cls.pub_chat_delete_long_press = 'pub-chat' - cls.text_message = 'hello' - cls.home_1.join_public_chat(cls.pub_chat_delete_long_press) - [home.home_button.click() for home in (cls.home_1, cls.home_2)] - cls.public_chat_name = cls.home_1.get_random_chat_name() - cls.chat_1 = cls.home_1.join_public_chat(cls.public_chat_name) - cls.chat_2 = cls.home_2.join_public_chat(cls.public_chat_name) - cls.chat_1.send_message(cls.text_message) + self.pub_chat_delete_long_press = 'pub-chat' + self.text_message = 'hello' + self.home_1.join_public_chat(self.pub_chat_delete_long_press) + [home.home_button.click() for home in (self.home_1, self.home_2)] + self.public_chat_name = self.home_1.get_random_chat_name() + self.chat_1 = self.home_1.join_public_chat(self.public_chat_name) + self.chat_2 = self.home_2.join_public_chat(self.public_chat_name) + self.chat_1.send_message(self.text_message) @marks.testrail_id(5313) def test_public_chat_message_send_check_timestamps_while_on_different_tab(self): @@ -229,14 +228,13 @@ class TestPublicChatMultipleDeviceMerged(MultipleSharedDeviceTestCase): @marks.critical class TestPublicChatBrowserOneDeviceMerged(MultipleSharedDeviceTestCase): - @classmethod - def setup_class(cls): - cls.drivers, cls.loop = create_shared_drivers(1) - cls.sign_in = SignInView(cls.drivers[0]) + def prepare_devices(self): + self.drivers, self.loop = create_shared_drivers(1) + self.sign_in = SignInView(self.drivers[0]) - cls.home = cls.sign_in.create_user() - cls.public_chat_name = cls.home.get_random_chat_name() - cls.chat = cls.home.join_public_chat(cls.public_chat_name) + self.home = self.sign_in.create_user() + self.public_chat_name = self.home.get_random_chat_name() + self.chat = self.home.join_public_chat(self.public_chat_name) @marks.testrail_id(5675) def test_public_chat_fetch_more_history(self): diff --git a/test/appium/tests/critical/wallet_and_tx/test_send_tx_dapp_keycard.py b/test/appium/tests/critical/wallet_and_tx/test_send_tx_dapp_keycard.py index 8f5e6032eb..044d51ecdc 100644 --- a/test/appium/tests/critical/wallet_and_tx/test_send_tx_dapp_keycard.py +++ b/test/appium/tests/critical/wallet_and_tx/test_send_tx_dapp_keycard.py @@ -12,22 +12,23 @@ from views.sign_in_view import SignInView @pytest.mark.xdist_group(name="one_1") @marks.critical class TestSendTxDeviceMerged(MultipleSharedDeviceTestCase): - @classmethod - def setup_class(cls): - cls.user = transaction_senders['ETH_STT_4'] - cls.recipient_address = '0x%s' % transaction_senders['ETH_ADI_STT_3']['address'] - cls.drivers, cls.loop = create_shared_drivers(1) - [cls.amount_adi, cls.amount_eth, cls.amount_stt] = ['0.000%s' % str(random.randint(100, 999)) + '1' for _ in range(3)] - cls.sign_in = SignInView(cls.drivers[0]) - cls.home = cls.sign_in.recover_access(cls.user['passphrase']) - cls.wallet = cls.home.wallet_button.click() - cls.assets = ('ETH', 'ADI', 'STT') - [cls.wallet.wait_balance_is_changed(asset) for asset in cls.assets] - cls.initial_balances = dict() - for asset in cls.assets: - cls.initial_balances[asset] = cls.wallet.get_asset_amount_by_name(asset) - cls.wallet.send_transaction(amount=cls.amount_eth, recipient=cls.recipient_address) - cls.wallet.send_transaction(amount=cls.amount_adi, recipient=cls.recipient_address, asset_name='ADI') + + def prepare_devices(self): + self.user = transaction_senders['ETH_STT_4'] + self.recipient_address = '0x%s' % transaction_senders['ETH_ADI_STT_3']['address'] + self.drivers, self.loop = create_shared_drivers(1) + [self.amount_adi, self.amount_eth, self.amount_stt] = ['0.000%s' % str(random.randint(100, 999)) + '1' for _ in + range(3)] + self.sign_in = SignInView(self.drivers[0]) + self.home = self.sign_in.recover_access(self.user['passphrase']) + self.wallet = self.home.wallet_button.click() + self.assets = ('ETH', 'ADI', 'STT') + [self.wallet.wait_balance_is_changed(asset) for asset in self.assets] + self.initial_balances = dict() + for asset in self.assets: + self.initial_balances[asset] = self.wallet.get_asset_amount_by_name(asset) + self.wallet.send_transaction(amount=self.amount_eth, recipient=self.recipient_address) + self.wallet.send_transaction(amount=self.amount_adi, recipient=self.recipient_address, asset_name='ADI') @marks.testrail_id(700763) def test_send_tx_eth_check_logcat(self): @@ -267,20 +268,20 @@ class TestSendTxDeviceMerged(MultipleSharedDeviceTestCase): @pytest.mark.xdist_group(name="two_1") @marks.critical class TestKeycardTxOneDeviceMerged(MultipleSharedDeviceTestCase): - @classmethod - def setup_class(cls): - cls.user = transaction_senders['ETH_STT_ADI_1'] - cls.address = '0x%s' % transaction_senders['ETH_7']['address'] - cls.drivers, cls.loop = create_shared_drivers(1) - cls.sign_in = SignInView(cls.drivers[0]) - cls.home = cls.sign_in.recover_access(passphrase=cls.user['passphrase'], keycard=True) - cls.wallet = cls.home.wallet_button.click() - cls.assets = ('ETH', 'ADI', 'STT') - [cls.wallet.wait_balance_is_changed(asset) for asset in cls.assets] - cls.initial_balances = dict() - for asset in cls.assets: - cls.initial_balances[asset] = cls.wallet.get_asset_amount_by_name(asset) + def prepare_devices(self): + self.user = transaction_senders['ETH_STT_ADI_1'] + self.address = '0x%s' % transaction_senders['ETH_7']['address'] + self.drivers, self.loop = create_shared_drivers(1) + self.sign_in = SignInView(self.drivers[0]) + + self.home = self.sign_in.recover_access(passphrase=self.user['passphrase'], keycard=True) + self.wallet = self.home.wallet_button.click() + self.assets = ('ETH', 'ADI', 'STT') + [self.wallet.wait_balance_is_changed(asset) for asset in self.assets] + self.initial_balances = dict() + for asset in self.assets: + self.initial_balances[asset] = self.wallet.get_asset_amount_by_name(asset) @marks.testrail_id(700767) def test_keycard_send_tx_eth(self): @@ -417,7 +418,8 @@ class TestKeycardTxOneDeviceMerged(MultipleSharedDeviceTestCase): self.sign_in.accept_tos_checkbox.enable() self.sign_in.get_started_button.click() self.sign_in.generate_key_button.click_until_presence_of_element(self.sign_in.next_button) - self.sign_in.next_button.click_until_absense_of_element(self.sign_in.element_by_translation_id("intro-wizard-title2")) + self.sign_in.next_button.click_until_absense_of_element( + self.sign_in.element_by_translation_id("intro-wizard-title2")) keycard_flow = self.sign_in.keycard_storage_button.click() keycard_flow.confirm_pin_and_proceed() seed_phrase = keycard_flow.backup_seed_phrase() diff --git a/test/appium/tests/critical/wallet_and_tx/test_wallet.py b/test/appium/tests/critical/wallet_and_tx/test_wallet.py index cd760e92c7..ea2ca9aa6f 100644 --- a/test/appium/tests/critical/wallet_and_tx/test_wallet.py +++ b/test/appium/tests/critical/wallet_and_tx/test_wallet.py @@ -13,19 +13,18 @@ from support.utilities import get_merged_txs_list @marks.critical class TestWalletManagementDeviceMerged(MultipleSharedDeviceTestCase): - @classmethod - def setup_class(cls): - cls.user = wallet_users['D'] - cls.account_seed_collectibles = 'acc_collectibles' - cls.drivers, cls.loop = create_shared_drivers(1) - cls.sign_in = SignInView(cls.drivers[0]) - cls.sign_in.switch_to_mobile(before_login=True) - cls.home = cls.sign_in.recover_access(cls.user['passphrase']) - cls.wallet = cls.home.wallet_button.click() - [cls.wallet.wait_balance_is_changed(asset) for asset in ('ETH', 'MDS', 'STT')] - cls.initial_balances = {'ETH': cls.wallet.get_asset_amount_by_name('ETH'), - 'ADI': 0, - 'STT': cls.wallet.get_asset_amount_by_name('STT')} + def prepare_devices(self): + self.user = wallet_users['D'] + self.account_seed_collectibles = 'acc_collectibles' + self.drivers, self.loop = create_shared_drivers(1) + self.sign_in = SignInView(self.drivers[0]) + self.sign_in.switch_to_mobile(before_login=True) + self.home = self.sign_in.recover_access(self.user['passphrase']) + self.wallet = self.home.wallet_button.click() + [self.wallet.wait_balance_is_changed(asset) for asset in ('ETH', 'MDS', 'STT')] + self.initial_balances = {'ETH': self.wallet.get_asset_amount_by_name('ETH'), + 'ADI': 0, + 'STT': self.wallet.get_asset_amount_by_name('STT')} @marks.testrail_id(700756) def test_wallet_tx_history_copy_tx_hash_on_cellular(self): @@ -246,7 +245,8 @@ class TestWalletManagementDeviceMerged(MultipleSharedDeviceTestCase): self.wallet.accounts_status_account.swipe_left_on_element() if not self.wallet.get_account_by_name(account_name_private).is_element_displayed(): - self.errors.append("Unhidden %s is shown on main wallet view after hiding via 'Show icon'" % account_name_private) + self.errors.append( + "Unhidden %s is shown on main wallet view after hiding via 'Show icon'" % account_name_private) for asset in self.initial_balances: self.wallet.wait_balance_is_changed(asset=asset, initial_balance=self.initial_balances[asset]) @@ -313,4 +313,4 @@ class TestWalletManagementDeviceMerged(MultipleSharedDeviceTestCase): self.errors.append( "'Insufficient funds' error is not shown when sending %s STT from wallet with balance %s" % ( round(stt_value + 1), stt_value)) - self.errors.verify_no_errors() \ No newline at end of file + self.errors.verify_no_errors() diff --git a/test/appium/tests/medium/test_activity_center.py b/test/appium/tests/medium/test_activity_center.py index 50340dcb7b..3303ccc0b6 100644 --- a/test/appium/tests/medium/test_activity_center.py +++ b/test/appium/tests/medium/test_activity_center.py @@ -9,19 +9,18 @@ from views.sign_in_view import SignInView @marks.medium class TestActivityCenterMultipleDeviceMedium(MultipleSharedDeviceTestCase): - @classmethod - def setup_class(cls): - cls.drivers, cls.loop = create_shared_drivers(2) - cls.device_1, cls.device_2 = SignInView(cls.drivers[0]), SignInView(cls.drivers[1]) - cls.home_1, cls.home_2 = cls.device_1.create_user(enable_notifications=True), cls.device_2.create_user() - cls.public_key_user_1, cls.username_1 = cls.home_1.get_public_key_and_username(return_username=True) - cls.public_key_user_2, cls.username_2 = cls.home_2.get_public_key_and_username(return_username=True) - [cls.group_chat_name_1, cls.group_chat_name_2, cls.group_chat_name_3, cls.group_chat_name_4, \ - cls.group_chat_name_5] = "GroupChat1", "GroupChat2", "GroupChat3", "GroupChat4", "GroupChat5" + def prepare_devices(self): + self.drivers, self.loop = create_shared_drivers(2) + self.device_1, self.device_2 = SignInView(self.drivers[0]), SignInView(self.drivers[1]) + self.home_1, self.home_2 = self.device_1.create_user(enable_notifications=True), self.device_2.create_user() + self.public_key_user_1, self.username_1 = self.home_1.get_public_key_and_username(return_username=True) + self.public_key_user_2, self.username_2 = self.home_2.get_public_key_and_username(return_username=True) + [self.group_chat_name_1, self.group_chat_name_2, self.group_chat_name_3, self.group_chat_name_4, \ + self.group_chat_name_5] = "GroupChat1", "GroupChat2", "GroupChat3", "GroupChat4", "GroupChat5" - cls.message_from_sender = "Message sender" - cls.home_2.home_button.double_click() - cls.device_2_one_to_one_chat = cls.home_2.add_contact(cls.public_key_user_1) + self.message_from_sender = "Message sender" + self.home_2.home_button.double_click() + self.device_2_one_to_one_chat = self.home_2.add_contact(self.public_key_user_1) @marks.testrail_id(702183) def test_activity_center_reject_chats_no_pn(self): @@ -161,7 +160,7 @@ class TestActivityCenterMultipleDeviceMedium(MultipleSharedDeviceTestCase): self.home_1.just_fyi("Device1 joins Group chat 3") group_chat_1 = self.home_1.get_chat(self.group_chat_name_3).click() - group_chat_1.join_chat_button.click_if_shown() + group_chat_1.join_chat_button.click() group_chat_1.home_button.double_click() self.home_2.just_fyi("Device2 mentions Device1 in Group chat 3") @@ -177,7 +176,8 @@ class TestActivityCenterMultipleDeviceMedium(MultipleSharedDeviceTestCase): self.home_1.notifications_unread_badge.click_until_absense_of_element(self.home_1.plus_button) self.home_1.just_fyi("Check that notification from group is presented in Activity Center") - if not self.home_1.get_chat_from_activity_center_view(self.username_2).chat_message_preview == group_chat_message: + if not self.home_1.get_chat_from_activity_center_view( + self.username_2).chat_message_preview == group_chat_message: self.errors.append("No mention in Activity Center for Group Chat") self.home_1.just_fyi("Open group chat where user mentioned") diff --git a/test/appium/tests/medium/test_browser_profile.py b/test/appium/tests/medium/test_browser_profile.py index c8684b2655..56500bef60 100644 --- a/test/appium/tests/medium/test_browser_profile.py +++ b/test/appium/tests/medium/test_browser_profile.py @@ -10,12 +10,11 @@ from tests.users import basic_user, ens_user, ens_user_ropsten, transaction_send @marks.medium class TestBrowserProfileOneDevice(MultipleSharedDeviceTestCase): - @classmethod - def setup_class(cls): - cls.drivers, cls.loop = create_shared_drivers(1) - cls.sign_in = SignInView(cls.drivers[0]) - cls.home = cls.sign_in.create_user() - cls.wiki_texts = ['Español', '日本語', 'Français', '中文', 'Português'] + def prepare_devices(self): + self.drivers, self.loop = create_shared_drivers(1) + self.sign_in = SignInView(self.drivers[0]) + self.home = self.sign_in.create_user() + self.wiki_texts = ['Español', '日本語', 'Français', '中文', 'Português'] @marks.testrail_id(702149) def test_browser_can_access_images_by_link(self): @@ -461,4 +460,4 @@ class TestBrowserProfileOneDevice(MultipleSharedDeviceTestCase): if not self.sign_in.home_button.is_element_displayed(): self.errors.append("Could not sign in with new password after reset") - self.errors.verify_no_errors() \ No newline at end of file + self.errors.verify_no_errors() diff --git a/test/appium/tests/medium/test_chats_m.py b/test/appium/tests/medium/test_chats_m.py index 0e5370ab5a..81f7e697fb 100644 --- a/test/appium/tests/medium/test_chats_m.py +++ b/test/appium/tests/medium/test_chats_m.py @@ -1,35 +1,36 @@ import random from time import sleep + import emoji import pytest -from tests.base_test_case import MultipleSharedDeviceTestCase, create_shared_drivers from tests import bootnode_address, mailserver_address, mailserver_ams, used_fleet, background_service_message -from tests.users import transaction_senders, ens_user from tests import marks +from tests.base_test_case import MultipleSharedDeviceTestCase, create_shared_drivers +from tests.users import transaction_senders, ens_user from views.sign_in_view import SignInView @pytest.mark.xdist_group(name="two_2") @marks.medium class TestTimelineHistoryNodesBootnodesMultipleDeviceMergedMedium(MultipleSharedDeviceTestCase): - @classmethod - def setup_class(cls): - cls.drivers, cls.loop = create_shared_drivers(2) - device_1, device_2 = SignInView(cls.drivers[0]), SignInView(cls.drivers[1]) - cls.home_1, cls.home_2 = device_1.create_user(), device_2.create_user() - cls.profile_1, cls.profile_2 = cls.home_1.profile_button.click(), cls.home_2.profile_button.click() - cls.public_key_1, cls.username_1 = cls.profile_1.get_public_key_and_username(return_username=True) - cls.public_key_2, cls.username_2 = cls.profile_2.get_public_key_and_username(return_username=True) - cls.text_message = 'hello' - [home.home_button.click() for home in (cls.home_1, cls.home_2)] - cls.public_chat_name = cls.home_1.get_random_chat_name() - cls.chat_1, cls.chat_2 = cls.home_1.join_public_chat(cls.public_chat_name), cls.home_2.join_public_chat( - cls.public_chat_name) - cls.chat_1.send_message(cls.text_message) - [home.home_button.click() for home in (cls.home_1, cls.home_2)] - cls.home_1.add_contact(cls.public_key_2, add_in_contacts=False) - cls.home_2.add_contact(cls.public_key_1, add_in_contacts=False) + + def prepare_devices(self): + self.drivers, self.loop = create_shared_drivers(2) + device_1, device_2 = SignInView(self.drivers[0]), SignInView(self.drivers[1]) + self.home_1, self.home_2 = device_1.create_user(), device_2.create_user() + self.profile_1, self.profile_2 = self.home_1.profile_button.click(), self.home_2.profile_button.click() + self.public_key_1, self.username_1 = self.profile_1.get_public_key_and_username(return_username=True) + self.public_key_2, self.username_2 = self.profile_2.get_public_key_and_username(return_username=True) + self.text_message = 'hello' + [home.home_button.click() for home in (self.home_1, self.home_2)] + self.public_chat_name = self.home_1.get_random_chat_name() + self.chat_1, self.chat_2 = self.home_1.join_public_chat(self.public_chat_name), self.home_2.join_public_chat( + self.public_chat_name) + self.chat_1.send_message(self.text_message) + [home.home_button.click() for home in (self.home_1, self.home_2)] + self.home_1.add_contact(self.public_key_2, add_in_contacts=False) + self.home_2.add_contact(self.public_key_1, add_in_contacts=False) @marks.testrail_id(702284) def test_public_chat_timeline_different_statuses_reaction(self): @@ -252,7 +253,8 @@ class TestTimelineHistoryNodesBootnodesMultipleDeviceMergedMedium(MultipleShared public_chat_2.send_message_button.click() public_chat_2.back_button.click() - self.profile_1.just_fyi('join same public chat and try to reconnect via "Tap to reconnect" and check "Connecting"') + self.profile_1.just_fyi( + 'join same public chat and try to reconnect via "Tap to reconnect" and check "Connecting"') self.profile_1.home_button.double_click() public_chat_1 = self.home_1.join_public_chat(public_chat_name) public_chat_1.reopen_app() @@ -295,39 +297,40 @@ class TestTimelineHistoryNodesBootnodesMultipleDeviceMergedMedium(MultipleShared @marks.medium class TestChatMediumMultipleDevice(MultipleSharedDeviceTestCase): - @classmethod - def setup_class(cls): - cls.drivers, cls.loop = create_shared_drivers(2) - cls.device_1, cls.device_2 = SignInView(cls.drivers[0]), SignInView(cls.drivers[1]) - cls.home_1, cls.home_2 = cls.device_1.create_user(enable_notifications=True), cls.device_2.create_user() - cls.public_key_1, cls.default_username_1 = cls.home_1.get_public_key_and_username(return_username=True) - cls.public_key_2, cls.default_username_2 = cls.home_2.get_public_key_and_username(return_username=True) - [home.home_button.click() for home in (cls.home_1, cls.home_2)] + def prepare_devices(self): + self.drivers, self.loop = create_shared_drivers(2) + self.device_1, self.device_2 = SignInView(self.drivers[0]), SignInView(self.drivers[1]) + self.home_1, self.home_2 = self.device_1.create_user(enable_notifications=True), self.device_2.create_user() + self.public_key_1, self.default_username_1 = self.home_1.get_public_key_and_username(return_username=True) + self.public_key_2, self.default_username_2 = self.home_2.get_public_key_and_username(return_username=True) + [home.home_button.click() for home in (self.home_1, self.home_2)] - cls.home_1.just_fyi("Creating 1-1 chats") - cls.chat_1 = cls.home_1.add_contact(cls.public_key_2) - cls.chat_2 = cls.home_2.add_contact(cls.public_key_1) - cls.home_2.just_fyi('Install free sticker pack and use it in 1-1 chat') - cls.chat_2.install_sticker_pack_by_name() - [home.home_button.click() for home in (cls.home_1, cls.home_2)] + self.home_1.just_fyi("Creating 1-1 chats") + self.chat_1 = self.home_1.add_contact(self.public_key_2) + self.chat_2 = self.home_2.add_contact(self.public_key_1) + self.home_2.just_fyi('Install free sticker pack and use it in 1-1 chat') + self.chat_2.install_sticker_pack_by_name() + [home.home_button.click() for home in (self.home_1, self.home_2)] - cls.home_1.just_fyi("Creating group chats") - cls.initial_group_chat_name = "GroupChat before rename" - cls.new_group_chat_name = "GroupChat after rename" - cls.group_chat_1 = cls.home_1.create_group_chat(user_names_to_add=[cls.default_username_2], group_chat_name=cls.initial_group_chat_name) - cls.group_chat_2 = cls.home_2.get_chat(cls.initial_group_chat_name).click() - cls.group_chat_2.join_chat_button.click_if_shown() - [home.home_button.click() for home in (cls.home_1, cls.home_2)] + self.home_1.just_fyi("Creating group chats") + self.initial_group_chat_name = "GroupChat before rename" + self.new_group_chat_name = "GroupChat after rename" + self.group_chat_1 = self.home_1.create_group_chat(user_names_to_add=[self.default_username_2], + group_chat_name=self.initial_group_chat_name) + self.group_chat_2 = self.home_2.get_chat(self.initial_group_chat_name).click() + self.group_chat_2.join_chat_button.click_if_shown() + [home.home_button.click() for home in (self.home_1, self.home_2)] - cls.home_1.just_fyi("Creating public chats") - cls.public_chat_name = cls.home_1.get_random_chat_name() - cls.public_chat_1, cls.public_chat_2 = cls.home_1.join_public_chat(cls.public_chat_name), cls.home_2.join_public_chat(cls.public_chat_name) - [home.home_button.click() for home in (cls.home_1, cls.home_2)] + self.home_1.just_fyi("Creating public chats") + self.public_chat_name = self.home_1.get_random_chat_name() + self.public_chat_1, self.public_chat_2 = self.home_1.join_public_chat( + self.public_chat_name), self.home_2.join_public_chat(self.public_chat_name) + [home.home_button.click() for home in (self.home_1, self.home_2)] - cls.home_1.get_chat(cls.default_username_2).click() - cls.home_2.get_chat(cls.default_username_1).click() + self.home_1.get_chat(self.default_username_2).click() + self.home_2.get_chat(self.default_username_1).click() - cls.message_1, cls.message_2, cls.message_3, cls.message_4 = "Message1", "Message2", "Message3", "Message4" + self.message_1, self.message_2, self.message_3, self.message_4 = "Message1", "Message2", "Message3", "Message4" @marks.testrail_id(702066) @marks.xfail(reason="may fail on setup with remote disconnected error, needs investigation") @@ -516,7 +519,8 @@ class TestChatMediumMultipleDevice(MultipleSharedDeviceTestCase): self.group_chat_1.rename_chat_via_group_info(self.new_group_chat_name) for chat in (self.group_chat_1, self.group_chat_2): if not chat.element_by_text( - chat.create_system_message(self.default_username_1, self.initial_group_chat_name)).is_element_displayed(): + chat.create_system_message(self.default_username_1, + self.initial_group_chat_name)).is_element_displayed(): self.errors.append('Initial system message about creating chat was changed!') if not chat.element_by_text( chat.changed_group_name_system_message(self.default_username_1, @@ -611,7 +615,8 @@ class TestChatMediumMultipleDevice(MultipleSharedDeviceTestCase): nickname_expected = emoji_unicode + special_char + cyrrilic chat_1 = self.home_1.add_contact(ens, add_in_contacts=False, nickname=nickname_to_set) if chat_1.user_name_text.text != nickname_expected: - self.errors.append('Expected special char nickname %s does not match actual %s' % (nickname_expected, chat_1.user_name_text.text)) + self.errors.append('Expected special char nickname %s does not match actual %s' % ( + nickname_expected, chat_1.user_name_text.text)) self.home_1.just_fyi('Can remove nickname without adding to contact') chat_1.chat_options.click() @@ -648,7 +653,8 @@ class TestChatMediumMultipleDevice(MultipleSharedDeviceTestCase): if not chat_1.chat_element_by_text(message_text).is_element_displayed(): self.errors.append("ENS name is not resolved on sent message") - self.home_1.just_fyi('Set nickname via group info and check that can mention by nickname /username in group chat') + self.home_1.just_fyi( + 'Set nickname via group info and check that can mention by nickname /username in group chat') nickname = 'funny_bunny' device_2_options = chat_1.get_user_options(full_ens) device_2_options.view_profile_button.click() @@ -699,30 +705,30 @@ class TestChatMediumMultipleDevice(MultipleSharedDeviceTestCase): @pytest.mark.xdist_group(name="one_3") @marks.medium class TestGroupChatMultipleDeviceMediumMerged(MultipleSharedDeviceTestCase): - @classmethod - def setup_class(cls): - cls.drivers, cls.loop = create_shared_drivers(3) - cls.sign_ins, cls.homes, cls.public_keys, cls.usernames, cls.chats = {}, {}, {}, {}, {} - for key in cls.drivers: - cls.sign_ins[key] = SignInView(cls.drivers[key]) - cls.homes[key] = cls.sign_ins[key].create_user() - SignInView(cls.drivers[2]).put_app_to_background_and_back() - cls.public_keys[key], cls.usernames[key] = cls.sign_ins[key].get_public_key_and_username(True) - cls.sign_ins[key].home_button.click() - SignInView(cls.drivers[0]).put_app_to_background_and_back() - for member in (cls.public_keys[1], cls.public_keys[2]): - cls.homes[0].add_contact(member) - cls.homes[0].home_button.click() - [SignInView(cls.drivers[i]).put_app_to_background_and_back() for i in range(1, 3)] - cls.chat_name = cls.homes[0].get_random_chat_name() - cls.invite_chat_name = '%s_invite' % cls.homes[0].get_random_chat_name() - cls.chats[0] = cls.homes[0].create_group_chat([], cls.invite_chat_name) - cls.chats[0].home_button.double_click() + def prepare_devices(self): + self.drivers, self.loop = create_shared_drivers(3) + self.sign_ins, self.homes, self.public_keys, self.usernames, self.chats = {}, {}, {}, {}, {} + for key in self.drivers: + self.sign_ins[key] = SignInView(self.drivers[key]) + self.homes[key] = self.sign_ins[key].create_user() + SignInView(self.drivers[2]).put_app_to_background_and_back() + self.public_keys[key], self.usernames[key] = self.sign_ins[key].get_public_key_and_username(True) + self.sign_ins[key].home_button.click() + SignInView(self.drivers[0]).put_app_to_background_and_back() - cls.chats[0] = cls.homes[0].create_group_chat([cls.usernames[1], cls.usernames[2]], cls.chat_name) + for member in (self.public_keys[1], self.public_keys[2]): + self.homes[0].add_contact(member) + self.homes[0].home_button.click() + [SignInView(self.drivers[i]).put_app_to_background_and_back() for i in range(1, 3)] + self.chat_name = self.homes[0].get_random_chat_name() + self.invite_chat_name = '%s_invite' % self.homes[0].get_random_chat_name() + self.chats[0] = self.homes[0].create_group_chat([], self.invite_chat_name) + self.chats[0].home_button.double_click() + + self.chats[0] = self.homes[0].create_group_chat([self.usernames[1], self.usernames[2]], self.chat_name) for i in range(1, 3): - cls.chats[i] = cls.homes[i].get_chat(cls.chat_name).click() + self.chats[i] = self.homes[i].get_chat(self.chat_name).click() @marks.testrail_id(702259) def test_group_chat_remove_member(self): @@ -782,32 +788,32 @@ class TestGroupChatMultipleDeviceMediumMerged(MultipleSharedDeviceTestCase): @marks.medium class TestChatKeycardMentionsMediumMultipleDevice(MultipleSharedDeviceTestCase): - @classmethod - def setup_class(cls): - cls.drivers, cls.loop = create_shared_drivers(2) - cls.device_1, cls.device_2 = SignInView(cls.drivers[0]), SignInView(cls.drivers[1]) - cls.sender = transaction_senders['ETH_STT_1'] + def prepare_devices(self): + self.drivers, self.loop = create_shared_drivers(2) + self.device_1, self.device_2 = SignInView(self.drivers[0]), SignInView(self.drivers[1]) + self.sender = transaction_senders['ETH_STT_1'] - cls.device_1.just_fyi('Grab user data for transactions and public chat, set up wallets') - cls.home_1 = cls.device_1.create_user(keycard=True, enable_notifications=True) - cls.device_2.put_app_to_background_and_back() - cls.recipient_public_key, cls.recipient_username = cls.home_1.get_public_key_and_username(return_username=True) - cls.amount = cls.device_1.get_unique_amount() - cls.asset_name = 'STT' - cls.wallet_1 = cls.home_1.wallet_button.click() - cls.wallet_1.select_asset(cls.asset_name) - cls.wallet_1.home_button.click() + self.device_1.just_fyi('Grab user data for transactions and public chat, set up wallets') + self.home_1 = self.device_1.create_user(keycard=True, enable_notifications=True) + self.device_2.put_app_to_background_and_back() + self.recipient_public_key, self.recipient_username = self.home_1.get_public_key_and_username( + return_username=True) + self.amount = self.device_1.get_unique_amount() + self.asset_name = 'STT' + self.wallet_1 = self.home_1.wallet_button.click() + self.wallet_1.select_asset(self.asset_name) + self.wallet_1.home_button.click() - cls.home_2 = cls.device_2.recover_access(passphrase=cls.sender['passphrase'], - keycard=True, enable_notifications=True) - cls.wallet_2 = cls.home_2.wallet_button.click() - cls.initial_amount_stt = cls.wallet_2.get_asset_amount_by_name('STT') - cls.wallet_2.home_button.click() + self.home_2 = self.device_2.recover_access(passphrase=self.sender['passphrase'], + keycard=True, enable_notifications=True) + self.wallet_2 = self.home_2.wallet_button.click() + self.initial_amount_stt = self.wallet_2.get_asset_amount_by_name('STT') + self.wallet_2.home_button.click() - cls.device_2.just_fyi('Add recipient to contact and send 1 message') - cls.chat_2 = cls.home_2.add_contact(cls.recipient_public_key) - cls.chat_2.send_message("test message") - cls.chat_1 = cls.home_1.get_chat(cls.sender['username']).click() + self.device_2.just_fyi('Add recipient to contact and send 1 message') + self.chat_2 = self.home_2.add_contact(self.recipient_public_key) + self.chat_2.send_message("test message") + self.chat_1 = self.home_1.get_chat(self.sender['username']).click() @marks.testrail_id(702294) def test_chat_1_1_unread_counter_highligted(self): @@ -839,7 +845,8 @@ class TestChatKeycardMentionsMediumMultipleDevice(MultipleSharedDeviceTestCase): self.errors.append("Preview message is not hightligted or text is not shown! ") self.home_1.get_chat(self.sender['username']).click() self.home_1.home_button.double_click() - if not self.home_1.get_chat(self.sender['username']).chat_preview.is_element_differs_from_template('highligted_preview.png', 0): + if not self.home_1.get_chat(self.sender['username']).chat_preview.is_element_differs_from_template( + 'highligted_preview.png', 0): self.errors.append("Preview message is still highlighted after opening ") self.errors.verify_no_errors() @@ -896,7 +903,8 @@ class TestChatKeycardMentionsMediumMultipleDevice(MultipleSharedDeviceTestCase): [home.wallet_button.click() for home in (self.home_1, self.home_2)] self.wallet_2.wait_balance_is_changed('STT', self.initial_amount_stt) self.wallet_1.wait_balance_is_changed('STT', scan_tokens=True) - [wallet.find_transaction_in_history(amount=self.amount, asset='STT') for wallet in (self.wallet_1, self.wallet_2)] + [wallet.find_transaction_in_history(amount=self.amount, asset='STT') for wallet in + (self.wallet_1, self.wallet_2)] self.errors.verify_no_errors() @marks.testrail_id(702296) @@ -966,10 +974,11 @@ class TestChatKeycardMentionsMediumMultipleDevice(MultipleSharedDeviceTestCase): if blocked_chat_user.is_element_displayed(): self.errors.append("Chat with blocked user is reappeared after fetching new messages from offline") - self.device_1.just_fyi("check that PNs are still enabled in profile after closing 'background notification centre' " - "message and relogin") + self.device_1.just_fyi( + "check that PNs are still enabled in profile after closing 'background notification centre' " + "message and relogin") self.device_1.open_notification_bar() if not self.device_1.element_by_text_part(background_service_message).is_element_displayed(): self.errors.append("Background notification service is not started after relogin") - self.errors.verify_no_errors() \ No newline at end of file + self.errors.verify_no_errors() diff --git a/test/appium/tests/medium/test_deeplink_chat_share_profile.py b/test/appium/tests/medium/test_deeplink_chat_share_profile.py index 9d22ffda16..439ee142e6 100644 --- a/test/appium/tests/medium/test_deeplink_chat_share_profile.py +++ b/test/appium/tests/medium/test_deeplink_chat_share_profile.py @@ -1,18 +1,10 @@ -import re -import random -import string import pytest - -from tests import marks, mailserver_ams, mailserver_gc, mailserver_hk, used_fleet, common_password, test_dapp_name,\ - test_dapp_url, pair_code, unique_password -from tests.base_test_case import create_shared_drivers, MultipleSharedDeviceTestCase -from tests.users import user_mainnet, chat_users, dummy_user, recovery_users, transaction_senders, basic_user,\ - wallet_users, ens_user_ropsten, ens_user from selenium.common.exceptions import NoSuchElementException -from tests.base_test_case import SingleDeviceTestCase, MultipleDeviceTestCase -from views.send_transaction_view import SendTransactionView -from views.chat_view import ChatView +from tests import marks, test_dapp_url +from tests.base_test_case import create_shared_drivers, MultipleSharedDeviceTestCase +from tests.users import dummy_user, transaction_senders, basic_user, \ + ens_user_ropsten, ens_user from views.sign_in_view import SignInView @@ -20,25 +12,24 @@ from views.sign_in_view import SignInView @marks.medium class TestDeeplinkChatProfileOneDevice(MultipleSharedDeviceTestCase): - @classmethod - def setup_class(cls): - cls.drivers, cls.loop = create_shared_drivers(1) - cls.sign_in = SignInView(cls.drivers[0]) - cls.home = cls.sign_in.create_user() - cls.public_key, cls.default_username = cls.home.get_public_key_and_username(return_username=True) - cls.home.home_button.click() - cls.public_chat_name = 'pubchat' - cls.nickname = 'dummy_user' - cls.search_list_1 = { + def prepare_devices(self): + self.drivers, self.loop = create_shared_drivers(1) + self.sign_in = SignInView(self.drivers[0]) + self.home = self.sign_in.create_user() + self.public_key, self.default_username = self.home.get_public_key_and_username(return_username=True) + self.home.home_button.click() + self.public_chat_name = 'pubchat' + self.nickname = 'dummy_user' + self.search_list_1 = { basic_user['username']: basic_user['username'], ens_user_ropsten['username']: ens_user_ropsten['ens'], - cls.public_chat_name: cls.public_chat_name, - cls.nickname: cls.nickname, - dummy_user['username']: cls.nickname, + self.public_chat_name: self.public_chat_name, + self.nickname: self.nickname, + dummy_user['username']: self.nickname, ens_user_ropsten['ens']: ens_user_ropsten['ens'] } - cls.public_chat = cls.home.join_public_chat(cls.public_chat_name) - cls.public_chat.get_back_to_home_view() + self.public_chat = self.home.join_public_chat(self.public_chat_name) + self.public_chat.get_back_to_home_view() @marks.testrail_id(702244) def test_deep_link_with_invalid_user_public_key_own_profile_key(self): @@ -117,7 +108,8 @@ class TestDeeplinkChatProfileOneDevice(MultipleSharedDeviceTestCase): self.public_chat.chat_options.click() self.public_chat.share_chat_button.click() self.public_chat.share_via_messenger() - if not self.public_chat.element_by_text_part('https://join.status.im/%s' % self.public_chat_name).is_element_present(): + if not self.public_chat.element_by_text_part( + 'https://join.status.im/%s' % self.public_chat_name).is_element_present(): self.errors.append("Can't share link to public chat") for _ in range(2): self.public_chat.click_system_back_button() @@ -260,7 +252,8 @@ class TestDeeplinkChatProfileOneDevice(MultipleSharedDeviceTestCase): message_input.delete_last_symbols(2) current_text = message_input.text if current_text != message_text[:-2]: - self.errors.append("Message input text '%s' doesn't match expected '%s'" % (current_text, message_text[:-2])) + self.errors.append( + "Message input text '%s' doesn't match expected '%s'" % (current_text, message_text[:-2])) """self.home.just_fyi('Cutting message text from input field') message_input.cut_text() @@ -273,7 +266,8 @@ class TestDeeplinkChatProfileOneDevice(MultipleSharedDeviceTestCase): self.home.just_fyi('Pasting the cut message back to the input field') message_input.paste_text_from_clipboard() if current_text != message_text[:-2]: - self.errors.append("Message input text '%s' doesn't match expected '%s'" % (current_text, message_text[:-2])) + self.errors.append( + "Message input text '%s' doesn't match expected '%s'" % (current_text, message_text[:-2])) chat.send_message_button.click() diff --git a/test/appium/tests/medium/test_pairing_devices_sync_m.py b/test/appium/tests/medium/test_pairing_devices_sync_m.py index c38e206393..f9c9e022b2 100644 --- a/test/appium/tests/medium/test_pairing_devices_sync_m.py +++ b/test/appium/tests/medium/test_pairing_devices_sync_m.py @@ -1,4 +1,5 @@ import pytest + from tests import marks from tests.base_test_case import MultipleSharedDeviceTestCase, create_shared_drivers from views.sign_in_view import SignInView @@ -8,63 +9,64 @@ from views.sign_in_view import SignInView @marks.medium class TestPairingSyncMediumMultipleDevicesMerged(MultipleSharedDeviceTestCase): - @classmethod - def setup_class(cls): - cls.drivers, cls.loop = create_shared_drivers(3) - cls.device_1, cls.device_2, cls.device_3 = SignInView(cls.drivers[0]), SignInView(cls.drivers[1]), SignInView(cls.drivers[2]) - cls.home_1 = cls.device_1.create_user() + def prepare_devices(self): + self.drivers, self.loop = create_shared_drivers(3) + self.device_1, self.device_2, self.device_3 = SignInView(self.drivers[0]), SignInView( + self.drivers[1]), SignInView(self.drivers[2]) + self.home_1 = self.device_1.create_user() - cls.profile_1 = cls.home_1.profile_button.click() - cls.profile_1.privacy_and_security_button.click() - cls.profile_1.backup_recovery_phrase_button.click() - cls.profile_1.ok_continue_button.click() - cls.recovery_phrase = cls.profile_1.get_recovery_phrase() - cls.profile_1.close_button.click() - cls.profile_1.home_button.click() - cls.device_2.put_app_to_background_and_back() - cls.home_3 = cls.device_3.create_user() - cls.public_key_3, cls.username_3 = cls.home_3.get_public_key_and_username(return_username=True) - cls.device_3.home_button.click() - cls.device_1.put_app_to_background_and_back() - cls.comm_before_sync_name, cls.channel, cls.message = 'b-%s' % cls.home_1.get_random_chat_name(), 'some-rand-chann', 'comm_message' - cls.device_1_name, cls.device_2_name, cls.group_chat_name = 'creator', 'paired', 'some group chat' - cls.comm_after_sync_name = 'a-public-%s' % cls.home_1.get_random_chat_name() - cls.channel_after_sync, cls.message_after_sync = 'chann-after-sync', 'sent after sync' + self.profile_1 = self.home_1.profile_button.click() + self.profile_1.privacy_and_security_button.click() + self.profile_1.backup_recovery_phrase_button.click() + self.profile_1.ok_continue_button.click() + self.recovery_phrase = self.profile_1.get_recovery_phrase() + self.profile_1.close_button.click() + self.profile_1.home_button.click() + self.device_2.put_app_to_background_and_back() + self.home_3 = self.device_3.create_user() + self.public_key_3, self.username_3 = self.home_3.get_public_key_and_username(return_username=True) + self.device_3.home_button.click() + self.device_1.put_app_to_background_and_back() + self.comm_before_sync_name, self.channel, self.message = 'b-%s' % self.home_1.get_random_chat_name(), 'some-rand-chann', 'comm_message' + self.device_1_name, self.device_2_name, self.group_chat_name = 'creator', 'paired', 'some group chat' + self.comm_after_sync_name = 'a-public-%s' % self.home_1.get_random_chat_name() + self.channel_after_sync, self.message_after_sync = 'chann-after-sync', 'sent after sync' - cls.device_1.just_fyi('Create community, create group chat, edit user picture') - cls.comm_before_1 = cls.home_1.create_community(cls.comm_before_sync_name) - cls.channel_before_1 = cls.comm_before_1.add_channel(cls.channel) - cls.channel_before_1.send_message(cls.message) - cls.home_1.home_button.double_click() - cls.device_3.put_app_to_background_and_back() - cls.device_2.put_app_to_background_and_back() + self.device_1.just_fyi('Create community, create group chat, edit user picture') + self.comm_before_1 = self.home_1.create_community(self.comm_before_sync_name) + self.channel_before_1 = self.comm_before_1.add_channel(self.channel) + self.channel_before_1.send_message(self.message) + self.home_1.home_button.double_click() + self.device_3.put_app_to_background_and_back() + self.device_2.put_app_to_background_and_back() - cls.device_1.just_fyi('Edit profile picture') - cls.home_1.profile_button.double_click() - cls.profile_1.edit_profile_picture('sauce_logo.png') + self.device_1.just_fyi('Edit profile picture') + self.home_1.profile_button.double_click() + self.profile_1.edit_profile_picture('sauce_logo.png') - cls.device_1.just_fyi('Add contact, start group chat') - cls.home_1.home_button.click() - cls.home_1.add_contact(cls.public_key_3) - cls.home_1.get_back_to_home_view() - cls.chat_1 = cls.home_1.create_group_chat([cls.username_3], cls.group_chat_name) - cls.chat_3 = cls.home_3.get_chat(cls.group_chat_name).click() - cls.chat_3.join_chat_button.click_if_shown() + self.device_1.just_fyi('Add contact, start group chat') + self.home_1.home_button.click() + self.home_1.add_contact(self.public_key_3) + self.device_2.put_app_to_background_and_back() + self.home_1.get_back_to_home_view() + self.chat_1 = self.home_1.create_group_chat([self.username_3], self.group_chat_name) + self.chat_3 = self.home_3.get_chat(self.group_chat_name).click() + self.chat_3.join_chat_button.click_if_shown() - cls.device_2.just_fyi("(secondary device): restore same multiaccount on another device") - cls.home_2 = cls.device_2.recover_access(passphrase=' '.join(cls.recovery_phrase.values())) - cls.profile_1, cls.profile_2 = cls.home_1.profile_button.click(), cls.home_2.profile_button.click() - cls.device_1.put_app_to_background_and_back() + self.device_2.just_fyi("(secondary device): restore same multiaccount on another device") + self.home_2 = self.device_2.recover_access(passphrase=' '.join(self.recovery_phrase.values())) + self.profile_1, self.profile_2 = self.home_1.profile_button.click(), self.home_2.profile_button.click() + self.device_1.put_app_to_background_and_back() - cls.device_2.just_fyi('Pair main and secondary devices') - cls.name_1, cls.name_2 = 'device_%s' % cls.device_1.driver.number, 'device_%s' % cls.device_2.driver.number - cls.profile_2.discover_and_advertise_device(cls.name_2) - cls.profile_1.discover_and_advertise_device(cls.name_1) - cls.profile_1.get_toggle_device_by_name(cls.name_2).wait_and_click() - cls.profile_1.sync_all_button.click() - cls.profile_1.sync_all_button.wait_for_visibility_of_element(20) - [device.profile_button.double_click() for device in (cls.profile_1, cls.profile_2)] - [device.home_button.double_click() for device in (cls.profile_1, cls.profile_2, cls.device_3)] + self.device_2.just_fyi('Pair main and secondary devices') + self.name_1, self.name_2 = 'device_%s' % self.device_1.driver.number, 'device_%s' % self.device_2.driver.number + self.profile_2.discover_and_advertise_device(self.name_2) + self.profile_1.discover_and_advertise_device(self.name_1) + self.profile_1.get_toggle_device_by_name(self.name_2).wait_and_click() + self.profile_1.sync_all_button.click() + self.profile_1.sync_all_button.wait_for_visibility_of_element(20) + [device.profile_button.double_click() for device in (self.profile_1, self.profile_2)] + [device.home_button.double_click() for device in (self.profile_1, self.profile_2, self.device_3)] @marks.testrail_id(702269) @marks.xfail(reason="too long setup, can fail with Remote end closed connection") @@ -151,7 +153,7 @@ class TestPairingSyncMediumMultipleDevicesMerged(MultipleSharedDeviceTestCase): self.chat_1.record_audio_message(message_length_in_seconds=3) self.device_1.send_message_button.click() self.chat_1.chat_message_input.click() - for chat in(self.chat_1, self.chat_2, self.chat_3): + for chat in (self.chat_1, self.chat_2, self.chat_3): if not chat.play_pause_audio_message_button.is_element_displayed(30): self.errors.append('Audio message is not shown in chat after sending!') self.errors.verify_no_errors() diff --git a/test/appium/tests/medium/test_permissions_scan_qr.py b/test/appium/tests/medium/test_permissions_scan_qr.py index 7254e5e56b..9a6786128d 100644 --- a/test/appium/tests/medium/test_permissions_scan_qr.py +++ b/test/appium/tests/medium/test_permissions_scan_qr.py @@ -1,26 +1,25 @@ import pytest from tests import marks -from tests.users import transaction_senders, basic_user, ens_user_ropsten, ens_user -from views.web_views.base_web_view import BaseWebView from tests.base_test_case import create_shared_drivers, MultipleSharedDeviceTestCase -from views.send_transaction_view import SendTransactionView +from tests.users import transaction_senders, basic_user, ens_user_ropsten, ens_user from views.chat_view import ChatView -from views.sign_in_view import SignInView from views.profile_view import ProfileView +from views.send_transaction_view import SendTransactionView +from views.sign_in_view import SignInView +from views.web_views.base_web_view import BaseWebView @pytest.mark.xdist_group(name="one_2") @marks.medium class TestPermissionsScanQrOneDevice(MultipleSharedDeviceTestCase): - @classmethod - def setup_class(cls): - cls.drivers, cls.loop = create_shared_drivers(1) - cls.sign_in = SignInView(cls.drivers[0]) - cls.home = cls.sign_in.recover_access(transaction_senders['C']['passphrase']) - cls.public_key = cls.home.get_public_key_and_username() - cls.home.home_button.click() + def prepare_devices(self): + self.drivers, self.loop = create_shared_drivers(1) + self.sign_in = SignInView(self.drivers[0]) + self.home = self.sign_in.recover_access(transaction_senders['C']['passphrase']) + self.public_key = self.home.get_public_key_and_username() + self.home.home_button.click() @marks.testrail_id(702289) def test_permissions_deny_access_camera_and_gallery(self): diff --git a/test/appium/tests/medium/test_profile_m.py b/test/appium/tests/medium/test_profile_m.py index 96313c5387..14129e1e0a 100644 --- a/test/appium/tests/medium/test_profile_m.py +++ b/test/appium/tests/medium/test_profile_m.py @@ -1,45 +1,43 @@ -from views.chat_view import CommunityView +import time + import pytest + +from tests import common_password from tests import marks from tests.base_test_case import MultipleSharedDeviceTestCase, create_shared_drivers +from views.chat_view import CommunityView from views.sign_in_view import SignInView -import time -from tests import bootnode_address, mailserver_address, mailserver_ams, mailserver_hk, used_fleet, common_password -from tests.users import transaction_senders, basic_user, ens_user -from tests import marks -from tests.base_test_case import MultipleDeviceTestCase -from views.sign_in_view import SignInView + @pytest.mark.xdist_group(name='five_2') @marks.medium class TestProfileGapsCommunityMediumMultipleDevicesMerged(MultipleSharedDeviceTestCase): - @classmethod - def setup_class(cls): - cls.drivers, cls.loop = create_shared_drivers(2) - cls.device_1, cls.device_2 = SignInView(cls.drivers[0]), SignInView(cls.drivers[1]) - cls.home_1, cls.home_2 = cls.device_1.create_user(), cls.device_2.create_user(enable_notifications=True) - cls.public_key_1, cls.default_username_1 = cls.home_1.get_public_key_and_username(return_username=True) - cls.public_key_2, cls.default_username_2 = cls.home_2.get_public_key_and_username(return_username=True) - [home.home_button.click() for home in (cls.home_1, cls.home_2)] + def prepare_devices(self): + self.drivers, self.loop = create_shared_drivers(2) + self.device_1, self.device_2 = SignInView(self.drivers[0]), SignInView(self.drivers[1]) + self.home_1, self.home_2 = self.device_1.create_user(), self.device_2.create_user(enable_notifications=True) + self.public_key_1, self.default_username_1 = self.home_1.get_public_key_and_username(return_username=True) + self.public_key_2, self.default_username_2 = self.home_2.get_public_key_and_username(return_username=True) + [home.home_button.click() for home in (self.home_1, self.home_2)] - cls.home_1.just_fyi("Creating 1-1 chats") - cls.chat_1 = cls.home_1.add_contact(cls.public_key_2) - cls.first_message = 'first message' - cls.chat_2 = cls.home_2.add_contact(cls.public_key_1, add_in_contacts=False) - [home.home_button.click() for home in (cls.home_1, cls.home_2)] + self.home_1.just_fyi("Creating 1-1 chats") + self.chat_1 = self.home_1.add_contact(self.public_key_2) + self.first_message = 'first message' + self.chat_2 = self.home_2.add_contact(self.public_key_1, add_in_contacts=False) + [home.home_button.click() for home in (self.home_1, self.home_2)] - cls.home_1.just_fyi("Creating group chat") - cls.group_chat_name = "gr_chat_%s" % cls.home_1.get_random_chat_name() - cls.group_chat_1 = cls.home_1.create_group_chat(user_names_to_add=[cls.default_username_2], - group_chat_name=cls.group_chat_name) - cls.group_chat_2 = cls.home_2.get_chat(cls.group_chat_name).click() - [home.home_button.click() for home in (cls.home_1, cls.home_2)] + self.home_1.just_fyi("Creating group chat") + self.group_chat_name = "gr_chat_%s" % self.home_1.get_random_chat_name() + self.group_chat_1 = self.home_1.create_group_chat(user_names_to_add=[self.default_username_2], + group_chat_name=self.group_chat_name) + self.group_chat_2 = self.home_2.get_chat(self.group_chat_name).click() + [home.home_button.click() for home in (self.home_1, self.home_2)] - cls.home_1.just_fyi("Creating public chats") - cls.public_chat_name = cls.home_1.get_random_chat_name() - cls.public_chat_1, cls.public_chat_2 = cls.home_1.join_public_chat( - cls.public_chat_name), cls.home_2.join_public_chat(cls.public_chat_name) + self.home_1.just_fyi("Creating public chats") + self.public_chat_name = self.home_1.get_random_chat_name() + self.public_chat_1, self.public_chat_2 = self.home_1.join_public_chat( + self.public_chat_name), self.home_2.join_public_chat(self.public_chat_name) @marks.testrail_id(702281) def test_profile_show_profile_picture_and_online_indicator_settings(self): @@ -87,7 +85,8 @@ class TestProfileGapsCommunityMediumMultipleDevicesMerged(MultipleSharedDeviceTe self.errors.append('Profile picture was not updated on user Profile view') profile_2.close_button.click() self.home_2.home_button.double_click() - if not self.home_2.get_chat(self.default_username_1).chat_image.is_element_image_similar_to_template(logo_chats): + if not self.home_2.get_chat(self.default_username_1).chat_image.is_element_image_similar_to_template( + logo_chats): self.errors.append('User profile picture was not updated on Chats view') profile_1.just_fyi('Check profile image updated in user profile view in Group chat views') @@ -97,8 +96,9 @@ class TestProfileGapsCommunityMediumMultipleDevicesMerged(MultipleSharedDeviceTe group_chat_1 = self.home_1.get_chat(self.group_chat_name).click() group_chat_1.send_message(group_chat_message) self.group_chat_2.chat_element_by_text(group_chat_message).wait_for_element(20) - if not self.group_chat_2.chat_element_by_text(group_chat_message).member_photo.is_element_image_similar_to_template( - logo_default): + if not self.group_chat_2.chat_element_by_text( + group_chat_message).member_photo.is_element_image_similar_to_template( + logo_default): self.errors.append('User profile picture was not updated in message Group chat view') self.home_2.put_app_to_background() @@ -154,7 +154,8 @@ class TestProfileGapsCommunityMediumMultipleDevicesMerged(MultipleSharedDeviceTe profile_2.element_by_translation_id("everyone").click() group_chat_1.send_message(group_chat_message) profile_2.home_button.click(desired_view='home') - if not self.home_2.get_chat(self.default_username_1).chat_image.is_element_image_similar_to_template(logo_chats): + if not self.home_2.get_chat(self.default_username_1).chat_image.is_element_image_similar_to_template( + logo_chats): self.errors.append('User profile picture is not returned to default after user removed from Contacts') self.errors.verify_no_errors() @@ -202,11 +203,11 @@ class TestProfileGapsCommunityMediumMultipleDevicesMerged(MultipleSharedDeviceTe @marks.testrail_id(702283) def test_community_create_approve_membership(self): [home.home_button.double_click() for home in (self.home_1, self.home_2)] - community_name, channel_name = "some name", "first_channel" + community_name, channel_name = "some name", "first_channel" community_description, community_pic = "something in community", 'sauce_logo.png' message, message_member = "message", "from member" community_1 = self.home_1.create_community(community_name, community_description, set_image=True, - file_name=community_pic) + file_name=community_pic) channel_1 = community_1.add_channel(channel_name) channel_1.send_message(message) self.home_1.home_button.double_click() @@ -247,7 +248,8 @@ class TestProfileGapsCommunityMediumMultipleDevicesMerged(MultipleSharedDeviceTe self.home_1.just_fyi("Approve membership") community_1.handle_membership_request(self.default_username_2, approve=True) if not community_1.element_by_text(self.default_username_2).is_element_displayed(): - self.errors.append("New member %s is not shown as added to community on info page!" % self.default_username_2) + self.errors.append( + "New member %s is not shown as added to community on info page!" % self.default_username_2) if not community_2.community_info_picture.is_element_image_similar_to_template(community_pic): self.errors.append("Community image is different!") channel_2 = community_2.get_chat(channel_name).click() @@ -263,5 +265,3 @@ class TestProfileGapsCommunityMediumMultipleDevicesMerged(MultipleSharedDeviceTe self.errors.append("Message from member is not shown for community channel!") self.errors.verify_no_errors() - - diff --git a/test/appium/tests/medium/test_wallet_keycard_m.py b/test/appium/tests/medium/test_wallet_keycard_m.py index 70ae6c5e73..9517e7e0a7 100644 --- a/test/appium/tests/medium/test_wallet_keycard_m.py +++ b/test/appium/tests/medium/test_wallet_keycard_m.py @@ -2,8 +2,9 @@ import random import string import pytest -from tests.base_test_case import MultipleSharedDeviceTestCase, create_shared_drivers + from tests import common_password, marks, test_dapp_name +from tests.base_test_case import MultipleSharedDeviceTestCase, create_shared_drivers from tests.users import transaction_senders, basic_user, ens_user_ropsten from views.sign_in_view import SignInView @@ -12,16 +13,15 @@ from views.sign_in_view import SignInView @marks.medium class TestKeycardMediumMultipleDevicesMerged(MultipleSharedDeviceTestCase): - @classmethod - def setup_class(cls): - cls.user = transaction_senders['ETH_STT_4'] - cls.drivers, cls.loop = create_shared_drivers(1) - cls.sign_in = SignInView(cls.drivers[0]) - cls.home = cls.sign_in.recover_access(passphrase=cls.user['passphrase'], keycard=True) - cls.profile = cls.home.get_profile_view() - cls.wallet = cls.home.wallet_button.click() - cls.wallet.wait_balance_is_changed('STT') - cls.home.home_button.click() + def prepare_devices(self): + self.user = transaction_senders['ETH_STT_4'] + self.drivers, self.loop = create_shared_drivers(1) + self.sign_in = SignInView(self.drivers[0]) + self.home = self.sign_in.recover_access(passphrase=self.user['passphrase'], keycard=True) + self.profile = self.home.get_profile_view() + self.wallet = self.home.wallet_button.click() + self.wallet.wait_balance_is_changed('STT') + self.home.home_button.click() @marks.testrail_id(702317) def test_keycard_testdapp_sign_typed_message(self): @@ -202,21 +202,20 @@ class TestKeycardMediumMultipleDevicesMerged(MultipleSharedDeviceTestCase): @marks.medium class TestWalletTestDappMediumMultipleDevicesMerged(MultipleSharedDeviceTestCase): - @classmethod - def setup_class(cls): - cls.user = transaction_senders['ETH_5'] - cls.drivers, cls.loop = create_shared_drivers(1) - cls.sign_in = SignInView(cls.drivers[0]) - cls.home = cls.sign_in.recover_access(passphrase=cls.user['passphrase']) - cls.profile = cls.home.get_profile_view() - cls.wallet = cls.home.wallet_button.click() - cls.wallet.wait_balance_is_changed() - cls.wallet.just_fyi('create new account in multiaccount') - cls.status_account = cls.home.status_account_name - cls.account_name = 'Subaccount' - cls.wallet.add_account(cls.account_name) - cls.sub_acc_address = cls.wallet.get_wallet_address(cls.account_name) - cls.home.wallet_button.double_click() + def prepare_devices(self): + self.user = transaction_senders['ETH_5'] + self.drivers, self.loop = create_shared_drivers(1) + self.sign_in = SignInView(self.drivers[0]) + self.home = self.sign_in.recover_access(passphrase=self.user['passphrase']) + self.profile = self.home.get_profile_view() + self.wallet = self.home.wallet_button.click() + self.wallet.wait_balance_is_changed() + self.wallet.just_fyi('create new account in multiaccount') + self.status_account = self.home.status_account_name + self.account_name = 'Subaccount' + self.wallet.add_account(self.account_name) + self.sub_acc_address = self.wallet.get_wallet_address(self.account_name) + self.home.wallet_button.double_click() @marks.testrail_id(702324) def test_testdapp_request_public_key(self):