From e5b6378e1575f12c91de1db829395625613bac4a Mon Sep 17 00:00:00 2001 From: Yevheniia Berdnyk Date: Mon, 31 Jul 2023 18:54:31 +0300 Subject: [PATCH] e2e: updated tests with new communitites creation flow --- .../critical/test_public_chat_browsing.py | 10 ++++----- .../tests/medium/test_activity_center.py | 10 ++++----- .../tests/medium/test_browser_profile.py | 2 +- .../medium/test_pairing_devices_sync_m.py | 4 ++-- test/appium/tests/medium/test_profile_m.py | 4 ++-- test/appium/views/home_view.py | 21 +++++++++++++++++-- 6 files changed, 34 insertions(+), 17 deletions(-) diff --git a/test/appium/tests/critical/test_public_chat_browsing.py b/test/appium/tests/critical/test_public_chat_browsing.py index 689dba905b..a88cda13ef 100644 --- a/test/appium/tests/critical/test_public_chat_browsing.py +++ b/test/appium/tests/critical/test_public_chat_browsing.py @@ -312,9 +312,9 @@ class TestCommunityOneDeviceMerged(MultipleSharedDeviceTestCase): self.home = self.sign_in.create_user(username=self.username) self.home.communities_tab.click_until_presence_of_element(self.home.plus_community_button) - self.community_name = self.home.get_random_chat_name() - self.channel_name = 'general' - self.community = self.home.create_community(name=self.community_name, description='test description') + self.community_name = "closed community" + self.channel_name = "cats" + self.community = self.home.create_community(community_type="closed") self.home.get_chat(self.community_name, community=True).click() self.community_view = self.home.get_community_view() @@ -538,9 +538,9 @@ class TestCommunityMultipleDeviceMerged(MultipleSharedDeviceTestCase): self.home_1.just_fyi("Open community to message") self.home_1.communities_tab.click() - self.community_name = self.home_1.get_random_chat_name() + self.community_name = "open community" self.channel_name = 'general' - self.home_1.create_community(name=self.community_name, description='community to test', require_approval=False) + self.home_1.create_community(community_type="open") self.channel_1 = self.home_1.get_to_community_channel_from_home(self.community_name) self.channel_1.send_message(self.text_message) diff --git a/test/appium/tests/medium/test_activity_center.py b/test/appium/tests/medium/test_activity_center.py index 29855764e4..5ee10a01e9 100644 --- a/test/appium/tests/medium/test_activity_center.py +++ b/test/appium/tests/medium/test_activity_center.py @@ -161,9 +161,9 @@ class TestActivityMultipleDevicePR(MultipleSharedDeviceTestCase): self.home_1.just_fyi("Open community to message") self.home_1.communities_tab.click() - self.community_name = self.home_1.get_random_chat_name() + self.community_name = "open community" self.channel_name = 'general' - self.home_1.create_community(name=self.community_name, description='community to test', require_approval=False) + self.home_1.create_community(community_type="open") self.channel_1 = self.home_1.get_to_community_channel_from_home(self.community_name) self.channel_1.send_message(self.text_message) @@ -317,9 +317,9 @@ class TestActivityMultipleDevicePR(MultipleSharedDeviceTestCase): [home.jump_to_communities_home() for home in (self.home_1, self.home_2)] self.home_1.just_fyi("Open community to message") self.home_1.communities_tab.click() - community_name = 'commun_to_check_notif' - self.channel_name = self.home_1.get_random_chat_name() - self.home_1.create_community(name=community_name, description='community to test', require_approval=True) + community_name = 'closed community' + self.channel_name = "dogs" + self.home_1.create_community(community_type="closed") self.home_1.reopen_app() community_element = self.home_1.get_chat(community_name, community=True) self.community_1.share_community(community_element, self.username_2) diff --git a/test/appium/tests/medium/test_browser_profile.py b/test/appium/tests/medium/test_browser_profile.py index 3049dfbd66..4263e89c6b 100644 --- a/test/appium/tests/medium/test_browser_profile.py +++ b/test/appium/tests/medium/test_browser_profile.py @@ -313,7 +313,7 @@ class TestBrowserProfileOneDevice(MultipleSharedDeviceTestCase): self.home.just_fyi('Create community chats') community_name = 'test community' community_description, community_pic = "test community description", 'sauce_logo.png' - self.home.create_community(community_name, community_description, set_image=True, file_name=community_pic) + self.home.create_community_e2e(community_name, community_description, set_image=True, file_name=community_pic) self.home.home_button.double_click() self.home.just_fyi('Add ENS-user to contacts') 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 9347ce4b0f..605d4f18ca 100644 --- a/test/appium/tests/medium/test_pairing_devices_sync_m.py +++ b/test/appium/tests/medium/test_pairing_devices_sync_m.py @@ -38,7 +38,7 @@ class TestPairingSyncMediumMultipleDevicesMerged(MultipleSharedDeviceTestCase): self.channel_after_sync, self.message_after_sync = 'chann-after-sync', 'sent after sync' 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.comm_before_1 = self.home_1.create_community_e2e(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() @@ -260,7 +260,7 @@ class TestPairingSyncMediumMultipleDevicesMerged(MultipleSharedDeviceTestCase): def test_pairing_sync_community_add_new(self): self.device_3.put_app_to_background_and_back() [home.home_button.double_click() for home in (self.home_1, self.home_2)] - self.home_1.create_community(self.comm_after_sync_name) + self.home_1.create_community_e2e(self.comm_after_sync_name) if not self.home_2.element_by_text(self.comm_after_sync_name).is_element_displayed(30): self.errors.append('Added community was not appeared after initial sync') self.errors.append("Leaving community was not synced!") diff --git a/test/appium/tests/medium/test_profile_m.py b/test/appium/tests/medium/test_profile_m.py index 4e656a1054..923a1084a8 100644 --- a/test/appium/tests/medium/test_profile_m.py +++ b/test/appium/tests/medium/test_profile_m.py @@ -281,8 +281,8 @@ class TestProfileGapsCommunityMediumMultipleDevicesMerged(MultipleSharedDeviceTe 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) + community_1 = self.home_1.create_community_e2e(community_name, community_description, set_image=True, + file_name=community_pic) channel_1 = community_1.add_channel(channel_name) channel_1.send_message(message) self.home_1.home_button.double_click() diff --git a/test/appium/views/home_view.py b/test/appium/views/home_view.py index f2cdaea8e8..a7b67a4f29 100644 --- a/test/appium/views/home_view.py +++ b/test/appium/views/home_view.py @@ -2,6 +2,7 @@ import time from appium.webdriver.common.mobileby import MobileBy from selenium.common.exceptions import TimeoutException, NoSuchElementException +from typing_extensions import Literal from tests import test_dapp_url from views.base_element import Button, Text, BaseElement, SilentButton, CheckBox, EditBox @@ -235,6 +236,10 @@ class HomeView(BaseView): self.my_profile_on_start_new_chat_button = Button(self.driver, xpath="//*[@content-desc='current-account-photo']") self.communities_button = ChatButton(self.driver, accessibility_id="create-community") + self.create_closed_community_button = ChatButton(self.driver, accessibility_id="create-closed-community") + self.create_open_community_button = ChatButton(self.driver, accessibility_id="create-open-community") + self.create_token_gated_community_button = ChatButton(self.driver, + accessibility_id="create-token-gated-community") self.ens_banner_close_button = Button(self.driver, accessibility_id=":ens-banner-close-button") # Notification centre @@ -425,8 +430,8 @@ class HomeView(BaseView): chat.profile_add_to_contacts_button.click() self.click_system_back_button_until_element_is_shown() - def create_community(self, name: str, description="some_description", set_image=False, file_name='sauce_logo.png', - require_approval=True): + def create_community_e2e(self, name: str, description="some_description", set_image=False, file_name='sauce_logo.png', + require_approval=True): self.driver.info("## Creating community '%s', set image is set to '%s'" % (name, str(set_image)), device=False) self.plus_community_button.click() chat_view = self.communities_button.click() @@ -448,6 +453,18 @@ class HomeView(BaseView): self.driver.info("## Community is created successfully!", device=False) return self.get_community_view() + def create_community(self, community_type: Literal["open", "closed", "token-gated"]): + self.driver.info("## Creating %s community" % community_type) + self.plus_community_button.click() + if community_type == "open": + self.create_open_community_button.click() + elif community_type == "closed": + self.create_closed_community_button.click() + elif community_type == "token-gated": + self.create_token_gated_community_button.click() + else: + raise ValueError("Incorrect community type is set") + def import_community(self, key): self.driver.info("## Importing community") import_button = Button(self.driver, translation_id="import")