e2e: added tests for fallback flow

This commit is contained in:
Yevheniia Berdnyk 2024-10-03 16:34:43 +03:00
parent 00b0d75fc4
commit 5f1d74a77a
No known key found for this signature in database
6 changed files with 293 additions and 42 deletions

View File

@ -125,6 +125,7 @@ class TestrailReport(BaseTestReport):
test_cases['nightly']['activity_centre_contact_request'] = 50984
test_cases['nightly']['activity_centre_other'] = 51005
test_cases['nightly']['wallet'] = 59443
test_cases['nightly']['fallback'] = 63472
## Upgrade e2e
# test_cases['upgrade']['general'] = 881

View File

@ -0,0 +1,199 @@
import pytest
from selenium.common import TimeoutException
from base_test_case import MultipleSharedDeviceTestCase, create_shared_drivers
from tests import marks, run_in_parallel, transl
from users import transaction_senders
from views.sign_in_view import SignInView
@pytest.mark.xdist_group(name="new_six_2")
@marks.nightly
class TestFallbackMultipleDevice(MultipleSharedDeviceTestCase):
def prepare_devices(self):
self.drivers, self.loop = create_shared_drivers(3)
self.sign_in_1, self.sign_in_2, self.sign_in_3 = SignInView(self.drivers[0]), SignInView(
self.drivers[1]), SignInView(self.drivers[2])
self.home_1, self.home_2, self.home_3 = self.sign_in_1.get_home_view(), self.sign_in_2.get_home_view(), \
self.sign_in_3.get_home_view()
self.sign_in_1.just_fyi("Device 1: create a new user")
self.sign_in_3.just_fyi("Device 3: create a new user")
self.user_name_1, self.user_name_3 = 'first user', 'third user'
self.loop.run_until_complete(
run_in_parallel(((self.sign_in_1.create_user, {'username': self.user_name_1}),
(self.sign_in_3.create_user, {'username': self.user_name_3}))))
self.profile_1 = self.home_1.profile_button.click()
self.profile_2 = self.home_2.get_profile_view()
self.sign_in_3.just_fyi("Device 3: get public key")
self.recovery_phrase, self.public_key_3 = self.loop.run_until_complete(
run_in_parallel(((self.profile_1.backup_recovery_phrase, {}),
(self.home_3.get_public_key, {}))))
self.home_2.driver.get_clipboard_text() # just pinging 2nd device to save the connection
self.profile_1.click_system_back_button()
self.home_1.chats_tab.click()
self.home_1.just_fyi("Device 1: add the 3rd user as a contact")
self.home_1.add_contact(self.public_key_3)
self.home_3.just_fyi("Device 3: accepting contact request from the 1st user")
self.home_3.handle_contact_request(self.user_name_1)
self.profile_1.just_fyi("Device 1: get sync code")
self.home_1.profile_button.click()
self.sync_code = self.profile_1.get_sync_code()
@marks.testrail_id(740220)
def test_fallback_sync_with_error(self):
self.sign_in_2.just_fyi("Device 2: try syncing profile")
self.sign_in_2.sync_profile(sync_code=self.sync_code)
self.sign_in_2.progress_screen_title.wait_for_element()
assert self.sign_in_2.progress_screen_title.text == "Oops, somethings wrong"
self.home_3.chats_tab.is_element_displayed() # just pinging 3rd device to save the connection
@marks.testrail_id(740221)
def test_fallback_with_correct_seed_phrase(self):
self.sign_in_2.just_fyi("Device 2: recover a profile with backed up seed phrase")
self.sign_in_2.try_seed_phrase_button.click()
self.sign_in_2.recover_access(passphrase=self.recovery_phrase, after_sync_code=True)
self.profile_1.click_system_back_button()
self.home_2.just_fyi("Getting device 2 name")
self.home_2.profile_button.click()
self.profile_2.syncing_button.scroll_and_click()
self.profile_2.paired_devices_button.click()
device_2_name = self.profile_2.get_current_device_name()
self.profile_2.click_system_back_button(times=3)
self.home_3.chats_tab.is_element_displayed() # just pinging 3rd device to save the connection
self.profile_1.just_fyi("Check device 2 is shown in not paired devices list in profile 1")
device_1_name = self.profile_1.get_current_device_name()
device_element = self.profile_1.get_paired_device_by_name(device_2_name)
if device_element.is_element_displayed():
if not device_element.get_pair_button.is_element_displayed():
self.errors.append(
"Pair button is absent for the device 2 inside Paired devices list of profile 1 before pairing")
else:
self.errors.append("Device 2 is not shown in Paired devices list for device 1 before pairing")
self.profile_1.click_system_back_button(times=3)
for home in self.home_1, self.home_2:
home.notifications_unread_badge.wait_for_visibility_of_element(30)
home.open_activity_center_button.click_until_presence_of_element(home.close_activity_centre)
self.home_1.just_fyi("Checking pairing request on device 1")
a_c_element = self.home_1.get_activity_center_element_by_text(transl['review-pairing-request'])
if a_c_element.title.text != transl['new-device-detected']:
self.errors.append(
"Notification with title '%s' is not shown in the activity center for the device 1" % transl[
'new-device-detected'])
a_c_element.review_pairing_request_button.click()
device_id_1 = self.home_1.get_new_device_installation_id()
self.home_3.chats_tab.is_element_displayed() # just pinging 3rd device to save the connection
self.home_2.just_fyi("Checking sync profile on device 2")
a_c_element = self.home_2.get_activity_center_element_by_text(transl['more-details'])
if a_c_element.title.text != transl['sync-your-profile']:
self.errors.append(
"Notification with title '%s' is not shown in the activity center for the device 2" % transl[
'sync-your-profile'])
a_c_element.more_details_button.click()
device_id_2 = self.home_2.get_new_device_installation_id()
if device_id_1 != device_id_2:
self.errors.append("Device ids don't match on the activity center notifications")
self.home_1.just_fyi("Confirm pairing request on device 1")
self.home_1.element_by_translation_id('pair-and-sync').click()
self.home_2.element_by_translation_id('close').click()
self.home_1.close_activity_centre.click()
self.home_2.close_activity_centre.click()
self.home_3.chats_tab.is_element_displayed() # just pinging 3rd device to save the connection
self.home_1.just_fyi("Device 1: Check that the device 2 is shown in paired devices list")
self.home_1.profile_button.click()
self.profile_1.syncing_button.scroll_and_click()
self.profile_1.paired_devices_button.click()
device_element = self.profile_1.get_paired_device_by_name(device_2_name)
if device_element.is_element_displayed():
if not device_element.get_unpair_button.is_element_displayed():
self.errors.append(
"Unpair button is absent for the device 2 inside Paired devices list of profile 1 after pairing")
else:
self.errors.append("Device 2 is not shown in Paired devices list for device 1 after pairing")
self.home_2.just_fyi("Device 2: Check that the device 1 is shown paired devices list")
self.home_2.profile_button.click()
self.profile_2.syncing_button.scroll_and_click()
self.profile_2.paired_devices_button.click()
device_element = self.profile_2.get_paired_device_by_name(device_1_name)
if device_element.is_element_displayed():
if not device_element.get_unpair_button.is_element_displayed():
self.errors.append(
"Unpair button is absent for the device 1 inside Paired devices list of profile 2 after pairing")
else:
self.errors.append("Device 1 is not shown in Paired devices list for device 2 after pairing")
self.home_3.just_fyi("Device 3: send a message to user 1")
self.home_3.chats_tab.click()
chat_3 = self.home_3.get_chat(self.user_name_1).click()
message = "Test message"
chat_3.send_message(message)
def _check_message(home_view, index):
home_view.just_fyi("Device %s: check the message from the user 3 is received" % index)
home_view.click_system_back_button(times=3)
home_view.chats_tab.click()
try:
chat_element = home_view.get_chat(self.user_name_3)
chat_element.wait_for_visibility_of_element(60)
chat_view = chat_element.click()
chat_view.chat_element_by_text(message).wait_for_visibility_of_element(60)
except TimeoutException:
self.errors.append("Message is not received by the user %s" % index)
self.loop.run_until_complete(
run_in_parallel(((_check_message, {'home_view': self.home_1, 'index': 1}),
(_check_message, {'home_view': self.home_2, 'index': 2}))))
self.errors.verify_no_errors()
@marks.testrail_id(740222)
def test_fallback_validate_seed_phrase(self):
self.sign_in_2.reopen_app(sign_in=False)
self.sign_in_2.just_fyi("Device 2: try syncing profile")
self.sign_in_2.sync_profile(sync_code=self.sync_code, first_user=False)
self.sign_in_2.progress_screen_title.wait_for_element()
assert self.sign_in_2.progress_screen_title.text == "Oops, somethings wrong"
self.sign_in_2.just_fyi("Device 2: try invalid passphrase")
self.sign_in_2.try_seed_phrase_button.click()
self.sign_in_2.passphrase_edit_box.send_keys(' '.join(['asset'] * 12))
self.sign_in_2.continue_button.click()
if not self.sign_in_2.element_by_translation_id('seed-phrase-invalid').is_element_displayed():
self.errors.append("Error message is not displayed for invalid recovery phrase")
self.sign_in_2.just_fyi("Device 2: try creating an account with another valid passphrase")
self.sign_in_2.passphrase_edit_box.clear()
self.sign_in_2.passphrase_edit_box.send_keys(transaction_senders['A']['passphrase'])
self.sign_in_2.continue_button.click()
if not self.sign_in_2.profile_title_input.is_element_displayed():
self.errors.append("Can't recover an access with a valid passphrase")
self.sign_in_2.click_system_back_button()
self.sign_in_2.just_fyi("Device 2: try recovering an account which is already synced")
self.sign_in_2.passphrase_edit_box.clear()
self.sign_in_2.passphrase_edit_box.send_keys(self.recovery_phrase)
self.sign_in_2.continue_button.click()
try:
self.sign_in_2.native_alert_title.wait_for_element()
shown_text = self.sign_in_2.native_alert_title.text
if shown_text != "Keys for this account already exist":
self.errors.append("Incorrect error message '%s' is shown for already synced account" % shown_text)
self.sign_in_2.cancel_button.click()
except TimeoutException:
self.errors.append("Error is not shown for already synced account")
self.errors.verify_no_errors()

View File

@ -298,14 +298,13 @@ class BaseView(object):
self.deny_button = Button(self.driver, translation_id="deny", uppercase=True)
self.continue_button = Button(self.driver, translation_id="continue", uppercase=True)
self.ok_button = Button(self.driver, xpath="//*[@text='OK' or @text='Ok']")
self.next_button = Button(self.driver, translation_id="next")
self.add_button = Button(self.driver, translation_id="add")
self.save_button = Button(self.driver, translation_id="save")
self.done_button = Button(self.driver, translation_id="done")
self.done_button = Button(self.driver, accessibility_id="Done")
self.delete_button = Button(self.driver, translation_id="delete", uppercase=True)
self.ok_continue_button = Button(self.driver, xpath="//*[@text='OK, CONTINUE' or @text='Okay, continue']")
self.ok_continue_button = Button(self.driver, accessibility_id="Okay, continue")
self.discard_button = Button(self.driver, xpath="//*[@text='DISCARD']")
self.confirm_button = Button(self.driver, translation_id='confirm', uppercase=True)
self.confirm_button = Button(self.driver, accessibility_id='Confirm')
self.cross_icon = Button(self.driver, xpath="(//android.widget.ImageView[@content-desc='icon'])[1]")
self.close_sticker_view_icon = Button(self.driver, xpath="//androidx.appcompat.widget.LinearLayoutCompat")
@ -314,7 +313,7 @@ class BaseView(object):
self.navigate_up_button = Button(self.driver, accessibility_id="Navigate Up")
self.show_roots_button = Button(self.driver, accessibility_id="Show roots")
self.get_started_button = Button(self.driver, translation_id="get-started")
self.ok_got_it_button = Button(self.driver, translation_id="ok-got-it")
self.ok_got_it_button = Button(self.driver, accessibility_id="Okay, got it")
self.cross_icon_inside_welcome_screen_button = Button(self.driver, accessibility_id='hide-home-button')
self.status_in_background_button = Button(self.driver, xpath="//*[contains(@content-desc,'Status')]")
self.cancel_button = Button(self.driver, translation_id="cancel", uppercase=True)
@ -324,6 +323,7 @@ class BaseView(object):
self.sign_in_phrase = SignInPhraseText(self.driver)
self.toast_content_element = BaseElement(self.driver, accessibility_id="toast-content")
self.next_button = Button(self.driver, accessibility_id="next-button")
self.native_alert_title = Text(self.driver, xpath="//*[@resource-id='android:id/alertTitle']")
# share contact screen
self.show_qr_code_button = Button(self.driver, accessibility_id="show-qr-button")
@ -332,7 +332,8 @@ class BaseView(object):
self.sharing_text_native = Text(self.driver, xpath="//*[@resource-id='android:id/content_preview_text']")
# checkboxes and toggles
self.checkbox_button = CheckBox(self.driver, accessibility_id="checkbox-off")
self.checkbox_button = CheckBox(
self.driver, xpath="//*[@content-desc='checkbox-off'][@resource-id='checkbox-component']")
self.slide_button_track = SlideButton(self.driver)
# external browser
@ -770,7 +771,7 @@ class BaseView(object):
self.close_native_device_dialog("MmsService")
def set_device_to_offline(self):
# setting network connection to data only and switching off wifi
# setting network connection to data only and switching off Wi-Fi
self.driver.set_network_connection(2)
self.driver.toggle_wifi()

View File

@ -152,6 +152,14 @@ class ActivityCenterElement(SilentButton):
def pending_status_tag(self):
return Text(self.driver, xpath=self.locator + '//*[@content-desc="status-tag-pending"]')
@property
def review_pairing_request_button(self):
return Button(self.driver, accessibility_id='Review pairing request')
@property
def more_details_button(self):
return Button(self.driver, accessibility_id='More details')
def handle_cr(self, element_accessibility: str):
Button(
self.driver,
@ -611,3 +619,8 @@ class HomeView(BaseView):
xpath="//*[@content-desc='%s'][descendant::*[@content-desc='chat-name-text'][@text='%s']]" % (
self.community_card_item.accessibility_id, community_name)
)
def get_new_device_installation_id(self):
element = Text(self.driver, accessibility_id='new-device-installation-id')
element.wait_for_visibility_of_element()
return element.text

View File

@ -4,7 +4,7 @@ from selenium.common import NoSuchElementException
from tests import common_password
from tests.base_test_case import AbstractTestCase
from views.base_element import Text, Button, EditBox, SilentButton
from views.base_element import Text, Button, EditBox, SilentButton, BaseElement
from views.base_view import BaseView
@ -68,15 +68,6 @@ class AdvancedButton(Button):
return self.navigate()
class BackupRecoveryPhraseButton(Button):
def __init__(self, driver):
super().__init__(driver, accessibility_id="back-up-recovery-phrase-button")
def click(self):
self.scroll_to_element().click()
return self.navigate()
class RecoveryPhraseTable(Text):
def __init__(self, driver):
super().__init__(driver, translation_id="your-recovery-phrase",
@ -93,11 +84,6 @@ class RecoveryPhraseWordNumberText(Text):
return int(self.find_element().text.split('#')[1])
class RecoveryPhraseWordInput(EditBox):
def __init__(self, driver):
super(RecoveryPhraseWordInput, self).__init__(driver, xpath="//android.widget.EditText")
class HelpButton(Button):
def __init__(self, driver):
super().__init__(driver, accessibility_id="help-button")
@ -235,10 +221,13 @@ class ProfileView(BaseView):
self.show_profile_pictures_of = Button(self.driver, accessibility_id="show-profile-pictures")
self.show_profile_pictures_to = Button(self.driver, accessibility_id="show-profile-pictures-to")
## Backup recovery phrase
self.backup_recovery_phrase_button = BackupRecoveryPhraseButton(self.driver)
self.backup_recovery_phrase_button = Button(
self.driver, accessibility_id="icon, Backup recovery phrase, label-component, icon")
self.recovery_phrase_table = RecoveryPhraseTable(self.driver)
self.recovery_phrase_word_number = RecoveryPhraseWordNumberText(self.driver)
self.recovery_phrase_word_input = RecoveryPhraseWordInput(self.driver)
self.recovery_phrase_next_button = Button(self.driver, accessibility_id="Next, icon")
self.recovery_phrase_word_input = EditBox(self.driver, xpath="//android.widget.EditText")
## Dapps permissions
self.dapp_permissions_button = DappPermissionsButton(self.driver)
self.revoke_access_button = Button(self.driver, translation_id="revoke-access")
@ -290,8 +279,8 @@ class ProfileView(BaseView):
self.advertise_device_button = Button(self.driver, accessibility_id="advertise-device")
self.sync_all_button = Button(self.driver, translation_id="sync-all-devices")
self.syncing_button = Button(self.driver, accessibility_id="icon, Syncing, label-component, icon")
self.paired_devices_button = Button(self.driver,
accessibility_id="icon, Paired devices, 0 devices, label-component, icon")
self.paired_devices_button = Button(
self.driver, xpath="//android.view.ViewGroup[contains(@content-desc,'icon, Paired devices,')]")
self.sync_plus_button = Button(
self.driver,
xpath="//*[@text='Paired devices']/following-sibling::android.view.ViewGroup[@content-desc='icon']")
@ -425,20 +414,20 @@ class ProfileView(BaseView):
return dict(zip(map(int, text[::2]), text[1::2]))
def backup_recovery_phrase(self):
self.driver.info("## Back up seed phrase", device=False)
self.just_fyi("Back up recovery phrase")
self.backup_recovery_phrase_button.click()
self.ok_continue_button.click()
recovery_phrase = self.get_recovery_phrase()
self.next_button.click()
self.recovery_phrase_next_button.click()
word_number = self.recovery_phrase_word_number.number
self.recovery_phrase_word_input.send_keys(recovery_phrase[word_number])
self.next_button.click()
self.recovery_phrase_next_button.click()
word_number_1 = self.recovery_phrase_word_number.number
self.recovery_phrase_word_input.send_keys(recovery_phrase[word_number_1])
self.done_button.click()
self.yes_button.click()
self.ok_got_it_button.click()
self.driver.info("## Seed phrase is backed up!", device=False)
return recovery_phrase
return ' '.join(recovery_phrase.values())
def edit_profile_picture(self, image_index: int, update_by="Gallery"):
self.driver.info("## Setting custom profile image", device=False)
@ -555,3 +544,25 @@ class ProfileView(BaseView):
self.login_button.click()
self.wait_for_staleness_of_element(password_input)
return self.password_input.text
def get_current_device_name(self):
element = BaseElement(
self.driver,
xpath="//android.view.ViewGroup/android.view.ViewGroup[@content-desc='status-tag-positive']/..")
return element.attribute_value('content-desc').split(',')[1].strip()
def get_paired_device_by_name(self, device_name: str):
class PairedDeviceElement(BaseElement):
def __init__(self, driver, device_name):
super().__init__(driver, xpath="//*[@content-desc='icon, %s, label-component']" % device_name)
@property
def get_pair_button(self):
return Button(self.driver, xpath=self.locator + "//*[@content-desc='Pair']")
@property
def get_unpair_button(self):
return Button(self.driver, xpath=self.locator + "//*[@content-desc='Unpair']")
return PairedDeviceElement(self.driver, device_name)

View File

@ -154,6 +154,11 @@ class SignInView(BaseView):
self.create_profile_button = Button(self.driver, accessibility_id='new-to-status-button')
self.not_now_button = Button(self.driver, xpath="//*[@text='Not now']")
self.sync_or_recover_profile_button = Button(self.driver, accessibility_id='already-use-status-button')
self.scan_sync_code_button = Button(self.driver, accessibility_id="scan-sync-code-option-card")
self.enter_sync_code_button = Button(self.driver, accessibility_id="Enter sync code")
self.enter_sync_code_input = EditBox(self.driver, accessibility_id="enter-sync-code-input")
self.progress_screen_title = Text(self.driver, accessibility_id="progress-screen-title")
self.try_seed_phrase_button = Button(self.driver, accessibility_id="try-seed-phrase-button")
self.migration_password_input = EditBox(self.driver, accessibility_id="enter-password-input")
self.access_key_button = AccessKeyButton(self.driver)
@ -215,6 +220,7 @@ class SignInView(BaseView):
self.show_profiles_button = Button(self.driver, accessibility_id="show-profiles")
self.plus_profiles_button = Button(self.driver, accessibility_id="show-new-account-options")
self.create_new_profile_button = Button(self.driver, accessibility_id="create-new-profile")
self.sync_or_recover_new_profile_button = Button(self.driver, accessibility_id="multi-profile")
self.remove_profile_button = Button(self.driver, accessibility_id="remove-profile")
def set_password(self, password: str):
@ -282,21 +288,24 @@ class SignInView(BaseView):
return self.get_home_view()
def recover_access(self, passphrase: str, password: str = common_password, keycard=False,
enable_notifications=False, second_user=False, username='Restore user', set_image=False):
enable_notifications=False, second_user=False, username='Restore user', set_image=False,
after_sync_code=False):
self.driver.info("## Recover access(password:%s, keycard:%s)" % (password, str(keycard)), device=False)
if not second_user:
self.terms_and_privacy_checkbox.click()
self.sync_or_recover_profile_button.click_until_presence_of_element(self.generate_keys_button)
self.not_now_button.wait_and_click()
else:
self.show_profiles_button.wait_and_click(20)
self.plus_profiles_button.click()
self.create_new_profile_button.click()
self.use_recovery_phrase_button.click()
if not after_sync_code:
if not second_user:
self.terms_and_privacy_checkbox.click()
self.sync_or_recover_profile_button.click_until_presence_of_element(self.generate_keys_button)
self.not_now_button.wait_and_click()
else:
self.show_profiles_button.wait_and_click(20)
self.plus_profiles_button.click()
self.create_new_profile_button.click()
self.use_recovery_phrase_button.click()
self.passphrase_edit_box.send_keys(passphrase)
self.continue_button.click_until_presence_of_element(self.profile_title_input)
self.set_profile(username, set_image)
if not after_sync_code:
self.set_profile(username, set_image)
self.set_password(password)
if enable_notifications:
self.enable_notifications_button.wait_and_click()
@ -318,6 +327,23 @@ class SignInView(BaseView):
self.driver.info("## Multiaccount is recovered successfully!", device=False)
return self.get_home_view()
def sync_profile(self, sync_code: str, first_user: bool = True):
if first_user:
self.terms_and_privacy_checkbox.click()
self.sync_or_recover_profile_button.click()
self.not_now_button.click()
else:
self.show_profiles_button.click()
self.plus_profiles_button.click()
self.sync_or_recover_new_profile_button.click()
self.scan_sync_code_button.click()
for checkbox in self.checkbox_button.find_elements():
checkbox.click()
self.continue_button.click()
self.enter_sync_code_button.click()
self.enter_sync_code_input.send_keys(sync_code)
self.confirm_button.click()
def sign_in(self, password=common_password):
self.driver.info("## Sign in (password: %s)" % password, device=False)
self.password_input.wait_for_visibility_of_element(10)