diff --git a/test/appium/tests/critical/test_public_chat_browsing.py b/test/appium/tests/critical/test_public_chat_browsing.py index 2a94e2f086..ccc007d583 100644 --- a/test/appium/tests/critical/test_public_chat_browsing.py +++ b/test/appium/tests/critical/test_public_chat_browsing.py @@ -10,6 +10,7 @@ from tests import marks, test_dapp_name, test_dapp_url, run_in_parallel, common_ from tests.base_test_case import create_shared_drivers, MultipleSharedDeviceTestCase from views.chat_view import CommunityView from views.sign_in_view import SignInView +from views.dbs.waku_backup import user as waku_user @pytest.mark.xdist_group(name="three_1") @@ -305,8 +306,9 @@ class TestCommunityOneDeviceMerged(MultipleSharedDeviceTestCase): def prepare_devices(self): self.drivers, self.loop = create_shared_drivers(1) self.sign_in = SignInView(self.drivers[0]) + self.username = 'first user' - self.home = self.sign_in.create_user() + self.home = self.sign_in.create_user(username=self.username) self.home.communities_tab.click_until_presence_of_element(self.home.plus_button) self.community_name = self.home.get_random_chat_name() self.channel_name = 'general' @@ -335,9 +337,8 @@ class TestCommunityOneDeviceMerged(MultipleSharedDeviceTestCase): message_input = self.channel.chat_message_input if not message_input.is_element_displayed(): - self.home.communities_tab.double_click() - self.home.get_chat(self.community_name, community=True).click() - self.community.get_chat(self.channel_name).click() + self.home.click_system_back_button_until_element_is_shown() + self.home.get_to_community_channel_from_home(self.community_name) for message in message_texts: message_input.send_keys(message) @@ -351,6 +352,56 @@ class TestCommunityOneDeviceMerged(MultipleSharedDeviceTestCase): self.errors.verify_no_errors() + @marks.testrail_id(703133) + def test_restore_multiaccount_with_waku_backup_remove_switch(self): + self.home.click_system_back_button_until_element_is_shown() + profile = self.home.profile_button.click() + profile.logout() + self.sign_in.recover_access(passphrase=waku_user.seed, second_user=True) + + self.home.just_fyi("Restore user with predefined communities, check communities") + self.home.communities_tab.click() + for key in ['admin_open', 'member_open', 'admin_closed', 'member_closed']: + if not self.home.element_by_text(waku_user.communities[key]).is_element_displayed(30): + self.errors.append("%s was not restored from waku-backup!!" % key) + self.home.opened_communities_tab.click() + if not self.home.element_by_text(waku_user.communities['member_pending']).is_element_displayed(30): + self.errors.append("Pending community %s was not restored from waku-backup!" % waku_user.communities['member_pending']) + + self.home.just_fyi("Check contacts/blocked users") + self.home.chats_tab.click() + self.home.contacts_tab.click() + for contact in waku_user.contacts: + if not self.home.element_by_text(contact).is_element_displayed(30): + self.errors.append("Contact %s was not restored from backup!" % contact) + + self.home.just_fyi("Check that can login with different user") + self.home.reopen_app(sign_in=False) + self.sign_in.show_profiles_button.click() + self.sign_in.element_by_text(self.username).click() + self.sign_in.sign_in() + self.home.communities_tab.click() + if self.home.element_by_text(waku_user.communities['admin_open']).is_element_displayed(30): + self.errors.append("Community of previous user is shown!") + + self.home.just_fyi("Check that can remove user from logged out state") + self.home.reopen_app(sign_in=False) + self.sign_in.show_profiles_button.click() + user_card = self.sign_in.get_user(username=self.username) + user_card.open_user_options() + self.sign_in.remove_profile_button.click() + if not self.sign_in.element_by_translation_id("remove-profile-confirm-message").is_element_displayed(30): + self.errors.append("Warning is not shown on removing profile!") + self.sign_in.element_by_translation_id("remove").click() + + self.home.just_fyi("Check that removed user is not shown in the list anymore") + self.home.reopen_app(sign_in=False) + self.sign_in.show_profiles_button.click() + if self.sign_in.element_by_text(self.username).is_element_displayed(): + self.errors.append("Removed user is re-appeared after relogin!") + + self.errors.verify_no_errors() + @pytest.mark.xdist_group(name="new_one_2") @marks.new_ui_critical diff --git a/test/appium/views/base_view.py b/test/appium/views/base_view.py index de561e6901..149cf115be 100644 --- a/test/appium/views/base_view.py +++ b/test/appium/views/base_view.py @@ -609,11 +609,12 @@ class BaseView(object): self.jump_to_button.click() self.element_by_text(text).click() - def reopen_app(self, password=common_password): + def reopen_app(self, password=common_password, sign_in=True): self.driver.close_app() self.driver.launch_app() - sign_in_view = self.get_sign_in_view() - sign_in_view.sign_in(password) + if sign_in: + sign_in_view = self.get_sign_in_view() + sign_in_view.sign_in(password) def close_share_popup(self): self.driver.info("Closing share popup") diff --git a/test/appium/views/dbs/waku_backup/user.py b/test/appium/views/dbs/waku_backup/user.py new file mode 100644 index 0000000000..b58be65553 --- /dev/null +++ b/test/appium/views/dbs/waku_backup/user.py @@ -0,0 +1,11 @@ +seed = 'staff actress trash route grab crime leaf uniform dizzy reform issue keep' +display_name = 'End to end' +communities = { + 'admin_open': 'Open-comm-adm', + 'member_open': 'e2e_open', + 'admin_closed': 'admin-closed-comm', + 'member_closed': 'test_comm_enc', + 'member_pending': 'RC1 testing community' +} +contacts = ['Chu_QA', 'my-custom-nickname'] +blocked_user = 'Clear Flat Milkweedbug' \ No newline at end of file diff --git a/test/appium/views/home_view.py b/test/appium/views/home_view.py index 396dca9d00..b5599b25bf 100644 --- a/test/appium/views/home_view.py +++ b/test/appium/views/home_view.py @@ -15,6 +15,7 @@ class ChatButton(Button): from views.chat_view import ChatView return ChatView(self.driver) + class ActivityTabButton(Button): def __init__(self, driver, **kwargs): super().__init__(driver, **kwargs) @@ -212,7 +213,8 @@ class HomeView(BaseView): accessibility_id="accept-and-add-activity-center") self.notifications_select_all = Button(self.driver, xpath="(//android.widget.CheckBox[" "@content-desc='checkbox-off'])[1]") - # Tabs and elements on Messages view + + # Tabs and elements on messages home view self.recent_tab = Button(self.driver, accessibility_id="tab-recent") self.groups_tab = Button(self.driver, accessibility_id="tab-groups") self.contacts_tab = Button(self.driver, accessibility_id="tab-contacts") @@ -220,6 +222,10 @@ class HomeView(BaseView): self.pending_contact_request_button = Button(self.driver, accessibility_id="open-activity-center-contact-requests") self.pending_contact_request_text = Text(self.driver, xpath='//*[@content-desc="pending-contact-requests-count"]/android.widget.TextView') + # Tabs and elements on community home view + self.pending_communities_tab = Button(self.driver, accessibility_id="pending-tab") + self.joined_communities_tab = Button(self.driver, accessibility_id="joined-tab") + self.opened_communities_tab = Button(self.driver, accessibility_id="opened-tab") # Options on long tap self.chats_menu_invite_friends_button = Button(self.driver, accessibility_id="chats-menu-invite-friends-button") diff --git a/test/appium/views/sign_in_view.py b/test/appium/views/sign_in_view.py index 3f35d0f62d..d5a49bef01 100644 --- a/test/appium/views/sign_in_view.py +++ b/test/appium/views/sign_in_view.py @@ -119,6 +119,15 @@ class TermsOfUseLink(Button): return BaseWebView(self.driver) +class UserProfileElement(Button): + def __init__(self, driver, username): + self.username = username + super().__init__(driver, xpath="//*[@text='%s']//ancestor::android.view.ViewGroup[@content-desc='profile-card']" % username) + + def open_user_options(self): + Button(self.driver, xpath='%s//*[@content-desc="profile-card-options"]' % self.locator).click() + + class SignInView(BaseView): def __init__(self, driver): @@ -187,7 +196,11 @@ class SignInView(BaseView): self.maybe_later_button = Button(self.driver, accessibility_id="enable-notifications-later-button") self.start_button = Button(self.driver, accessibility_id="welcome-button") self.use_recovery_phrase_button = Button(self.driver, translation_id="use-recovery-phrase") - self.passphrase_edit_box = EditBox(self.driver, accessibility_id="use-recovery-phrase") + self.passphrase_edit_box = EditBox(self.driver, accessibility_id="passphrase-input") + 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.remove_profile_button = Button(self.driver, accessibility_id="remove-profile") def set_password(self, password: str): self.profile_password_edit_box.set_value(password) @@ -233,18 +246,23 @@ class SignInView(BaseView): self.driver.info("## New multiaccount is created successfully!", device=False) return self.get_home_view() - def recover_access(self, passphrase: str, password: str = common_password+'1234', keycard=False, + def recover_access(self, passphrase: str, password: str = common_password, keycard=False, enable_notifications=False, second_user=False, username='Restore user', set_image=False): self.driver.info("## Recover access(password:%s, keycard:%s)" % (password, str(keycard)), device=False) if not second_user: self.i_m_new_in_status_button.click_until_presence_of_element(self.generate_keys_button) + else: + self.show_profiles_button.click() + self.plus_profiles_button.click() + self.create_new_profile_button.click() self.use_recovery_phrase_button.click() self.passphrase_edit_box.set_value(passphrase) self.continue_button.click_until_presence_of_element(self.profile_your_name_edit_box) self.set_profile(username, set_image) self.set_password(password) self.enable_biometric_maybe_later_button.wait_and_click(30) + self.identifiers_button.wait_and_click(30) if enable_notifications: self.enable_notifications_button.click_until_presence_of_element(self.start_button) else: @@ -324,4 +342,9 @@ class SignInView(BaseView): print(str(e)) self.driver.info('## Exporting database is finished!', device=False) + def get_user(self, username): + self.driver.info("Getting username card by '%s'" % username) + expected_element = UserProfileElement(self.driver, username) + return expected_element if expected_element.is_element_displayed(10) else self.driver.fail("User is not found!") +