e2e: updated communities join flow (#17132)

This commit is contained in:
Yevheniia Berdnyk 2023-08-30 11:49:31 +03:00 committed by GitHub
parent ca7a519f89
commit 551ac22085
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 48 additions and 29 deletions

View File

@ -413,7 +413,7 @@ class SauceSharedMultipleDeviceTestCase(AbstractTestCase):
session_id = driver.session_id session_id = driver.session_id
try: try:
sauce.jobs.update_job(username=sauce_username, job_id=session_id, name=cls.__name__) sauce.jobs.update_job(username=sauce_username, job_id=session_id, name=cls.__name__)
except (RemoteDisconnected, SauceException): except (RemoteDisconnected, SauceException, requests.exceptions.ConnectionError):
pass pass
try: try:
driver.quit() driver.quit()

View File

@ -552,6 +552,7 @@ class TestCommunityMultipleDeviceMerged(MultipleSharedDeviceTestCase):
self.text_message = 'hello' self.text_message = 'hello'
# self.home_2.just_fyi("Send message to contact (need for blocking contact) test") # self.home_2.just_fyi("Send message to contact (need for blocking contact) test")
self.home_1.get_chat(self.username_2).wait_for_visibility_of_element()
self.chat_1 = self.home_1.get_chat(self.username_2).click() self.chat_1 = self.home_1.get_chat(self.username_2).click()
self.chat_1.send_message('hey') self.chat_1.send_message('hey')
self.chat_2 = self.home_2.get_chat(self.username_1).click() self.chat_2 = self.home_2.get_chat(self.username_1).click()
@ -912,7 +913,7 @@ class TestCommunityMultipleDeviceMerged(MultipleSharedDeviceTestCase):
self.errors.append("Messages from blocked user is not cleared in public chat ") self.errors.append("Messages from blocked user is not cleared in public chat ")
self.chat_1.navigate_back_to_home_view() self.chat_1.navigate_back_to_home_view()
self.home_1.chats_tab.click() self.home_1.chats_tab.click()
if not self.home_1.element_by_translation_id( "no-messages").is_element_displayed(): if not self.home_1.element_by_translation_id("no-messages").is_element_displayed():
self.errors.append("1-1 chat from blocked user is not removed and messages home is not empty!") self.errors.append("1-1 chat from blocked user is not removed and messages home is not empty!")
self.chat_1.toggle_airplane_mode() self.chat_1.toggle_airplane_mode()
@ -1024,6 +1025,30 @@ class TestCommunityMultipleDeviceMerged(MultipleSharedDeviceTestCase):
@marks.xfail( @marks.xfail(
reason="Issue with username in PN, issue #6 in https://github.com/status-im/status-mobile/issues/15500") reason="Issue with username in PN, issue #6 in https://github.com/status-im/status-mobile/issues/15500")
def test_community_mentions_push_notification(self): def test_community_mentions_push_notification(self):
self.home_1.navigate_back_to_home_view()
self.home_1.chats_tab.click()
self.home_1.contacts_tab.click()
if not self.home_1.contact_details_row(username=self.username_2).is_element_displayed():
# if test_community_contact_block_unblock_offline failed we need to add users to contacts again
self.home_1.navigate_back_to_home_view()
self.chat_1.profile_button.click()
self.profile_1.contacts_button.wait_and_click()
if self.profile_1.blocked_users_button.is_element_displayed():
self.profile_1.element_by_text(self.username_2).click()
self.chat_1.unblock_contact_button.click()
self.chat_1.profile_add_to_contacts_button.click()
self.chat_1.close_button.click()
else:
self.profile_1.add_new_contact_button.click()
self.chat_1.public_key_edit_box.click()
self.chat_1.public_key_edit_box.send_keys(self.public_key_2)
self.chat_1.view_profile_new_contact_button.click_until_presence_of_element(
self.chat_1.profile_add_to_contacts_button)
self.chat_1.profile_add_to_contacts_button.click()
self.chat_1.navigate_back_to_home_view()
self.home_2.navigate_back_to_home_view()
self.home_2.handle_contact_request(self.username_1)
self.home_1.navigate_back_to_home_view() self.home_1.navigate_back_to_home_view()
if not self.channel_2.chat_message_input.is_element_displayed(): if not self.channel_2.chat_message_input.is_element_displayed():
self.channel_2.navigate_back_to_home_view() self.channel_2.navigate_back_to_home_view()
@ -1136,28 +1161,9 @@ class TestCommunityMultipleDeviceMerged(MultipleSharedDeviceTestCase):
for home in self.homes: for home in self.homes:
home.navigate_back_to_home_view() home.navigate_back_to_home_view()
home.chats_tab.click() home.chats_tab.click()
home.recent_tab.click()
if self.home_1.get_chat(self.username_2).is_element_displayed(): self.home_1.get_chat(self.username_2).click()
self.home_1.get_chat(self.username_2).click()
else:
# if test_community_contact_block_unblock_offline failed we need to add users to contacts again
self.home_1.contacts_tab.click()
if self.home_1.contact_details_row(username=self.username_2).is_element_displayed():
self.home_1.contact_details_row(username=self.username_2).click()
self.chat_1.profile_send_message_button.click()
else:
self.home_1.navigate_back_to_home_view()
self.chat_1.profile_button.click()
self.profile_1.contacts_button.wait_and_click()
self.profile_1.blocked_users_button.wait_and_click()
self.profile_1.element_by_text(self.username_2).click()
self.chat_1.unblock_contact_button.click()
self.chat_1.close_button.click()
self.chat_1.navigate_back_to_home_view()
self.home_1.chats_tab.click()
self.home_1.get_chat(self.username_2).click()
self.chat_1.send_message("just a message")
self.home_2.get_chat(self.username_1).click() self.home_2.get_chat(self.username_1).click()
for message, symbol in markdown.items(): for message, symbol in markdown.items():

View File

@ -240,6 +240,7 @@ class BaseView(object):
self.driver = driver self.driver = driver
self.send_message_button = SendMessageButton(self.driver) self.send_message_button = SendMessageButton(self.driver)
self.send_contact_request_button = Button(self.driver, translation_id="send-request") self.send_contact_request_button = Button(self.driver, translation_id="send-request")
self.password_input = EditBox(self.driver, accessibility_id="password-input")
# Old UI Tabs # Old UI Tabs
self.home_button = HomeButton(self.driver) self.home_button = HomeButton(self.driver)

View File

@ -5,9 +5,9 @@ from time import sleep
import dateutil.parser import dateutil.parser
from appium.webdriver.common.touch_action import TouchAction from appium.webdriver.common.touch_action import TouchAction
from selenium.common.exceptions import NoSuchElementException, TimeoutException from selenium.common.exceptions import NoSuchElementException, TimeoutException, StaleElementReferenceException
from tests import emojis from tests import emojis, common_password
from views.base_element import Button, EditBox, Text, BaseElement, SilentButton from views.base_element import Button, EditBox, Text, BaseElement, SilentButton
from views.base_view import BaseView from views.base_view import BaseView
from views.home_view import HomeView from views.home_view import HomeView
@ -410,12 +410,15 @@ class CommunityView(HomeView):
# Communities initial page # Communities initial page
self.community_description_text = Text(self.driver, accessibility_id="community-description-text") self.community_description_text = Text(self.driver, accessibility_id="community-description-text")
def join_community(self): def join_community(self, password=common_password):
self.driver.info("Joining community") self.driver.info("Joining community")
self.join_button.click() self.join_button.click()
self.checkbox_button.scroll_to_element() self.checkbox_button.scroll_to_element()
self.checkbox_button.enable() self.checkbox_button.enable()
self.join_community_button.scroll_and_click() self.join_community_button.scroll_and_click()
self.password_input.set_value(password)
Button(self.driver,
xpath="//*[@content-desc='password-input']/../following-sibling::*//*[@text='Join Community']").click()
def get_channel(self, channel_name: str): def get_channel(self, channel_name: str):
self.driver.info("Getting %s channel element in community" % channel_name) self.driver.info("Getting %s channel element in community" % channel_name)
@ -986,7 +989,16 @@ class ChatView(BaseView):
def send_message(self, message: str = 'test message', wait_chat_input_sec=5): def send_message(self, message: str = 'test message', wait_chat_input_sec=5):
self.driver.info("Sending message '%s'" % BaseElement(self.driver).exclude_emoji(message)) self.driver.info("Sending message '%s'" % BaseElement(self.driver).exclude_emoji(message))
self.chat_message_input.wait_for_element(wait_chat_input_sec) self.chat_message_input.wait_for_element(wait_chat_input_sec)
self.chat_message_input.send_keys(message) for _ in range(3):
try:
self.chat_message_input.send_keys(message)
break
except StaleElementReferenceException:
time.sleep(1)
except Exception as e:
raise e
else:
raise StaleElementReferenceException(msg="Can't send keys to chat message input, loading")
self.send_message_button.click() self.send_message_button.click()
def send_contact_request(self, message: str = 'Contact request message', wait_chat_input_sec=5): def send_contact_request(self, message: str = 'Contact request message', wait_chat_input_sec=5):
@ -1020,7 +1032,8 @@ class ChatView(BaseView):
def copy_message_text(self, message_text): def copy_message_text(self, message_text):
self.driver.info("Copying '%s' message via long press" % message_text) self.driver.info("Copying '%s' message via long press" % message_text)
self.element_by_text_part(message_text).long_press_element() self.chat_element_by_text(message_text).wait_for_visibility_of_element()
self.chat_element_by_text(message_text).long_press_element()
self.element_by_translation_id("copy-text").click() self.element_by_translation_id("copy-text").click()
def quote_message(self, message: str): def quote_message(self, message: str):

View File

@ -142,7 +142,6 @@ class SignInView(BaseView):
self.sign_in_intro_button = Button(self.driver, accessibility_id="already-use-status-button") self.sign_in_intro_button = Button(self.driver, accessibility_id="already-use-status-button")
self.i_m_new_in_status_button = Button(self.driver, accessibility_id="new-to-status-button") self.i_m_new_in_status_button = Button(self.driver, accessibility_id="new-to-status-button")
self.password_input = EditBox(self.driver, accessibility_id="password-input")
self.migration_password_input = EditBox(self.driver, accessibility_id="enter-password-input") self.migration_password_input = EditBox(self.driver, accessibility_id="enter-password-input")
self.login_button = LogInButton(self.driver) self.login_button = LogInButton(self.driver)
self.access_key_button = AccessKeyButton(self.driver) self.access_key_button = AccessKeyButton(self.driver)