Skip to content

Commit

Permalink
e2e: updated communities join flow
Browse files Browse the repository at this point in the history
  • Loading branch information
yevh-berdnyk authored and churik committed Aug 30, 2023
1 parent ca7a519 commit 8d859cb
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 29 deletions.
2 changes: 1 addition & 1 deletion test/appium/tests/base_test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ def teardown_class(cls):
session_id = driver.session_id
try:
sauce.jobs.update_job(username=sauce_username, job_id=session_id, name=cls.__name__)
except (RemoteDisconnected, SauceException):
except (RemoteDisconnected, SauceException, requests.exceptions.ConnectionError):
pass
try:
driver.quit()
Expand Down
50 changes: 28 additions & 22 deletions test/appium/tests/critical/test_public_chat_browsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,7 @@ def prepare_devices(self):
self.text_message = 'hello'

# 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.send_message('hey')
self.chat_2 = self.home_2.get_chat(self.username_1).click()
Expand Down Expand Up @@ -912,7 +913,7 @@ def test_community_contact_block_unblock_offline(self):
self.errors.append("Messages from blocked user is not cleared in public chat ")
self.chat_1.navigate_back_to_home_view()
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.chat_1.toggle_airplane_mode()

Expand Down Expand Up @@ -1024,6 +1025,30 @@ def test_community_mark_all_messages_as_read(self):
@marks.xfail(
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):
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()
if not self.channel_2.chat_message_input.is_element_displayed():
self.channel_2.navigate_back_to_home_view()
Expand Down Expand Up @@ -1136,28 +1161,9 @@ def test_community_markdown_support(self):
for home in self.homes:
home.navigate_back_to_home_view()
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()
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_1.get_chat(self.username_2).click()
self.home_2.get_chat(self.username_1).click()

for message, symbol in markdown.items():
Expand Down
1 change: 1 addition & 0 deletions test/appium/views/base_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ def __init__(self, driver):
self.driver = driver
self.send_message_button = SendMessageButton(self.driver)
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
self.home_button = HomeButton(self.driver)
Expand Down
23 changes: 18 additions & 5 deletions test/appium/views/chat_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

import dateutil.parser
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_view import BaseView
from views.home_view import HomeView
Expand Down Expand Up @@ -410,12 +410,15 @@ def __init__(self, driver):
# Communities initial page
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.join_button.click()
self.checkbox_button.scroll_to_element()
self.checkbox_button.enable()
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):
self.driver.info("Getting %s channel element in community" % channel_name)
Expand Down Expand Up @@ -986,7 +989,16 @@ def verify_message_is_under_today_text(self, text, errors, timeout=10):
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.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()

def send_contact_request(self, message: str = 'Contact request message', wait_chat_input_sec=5):
Expand Down Expand Up @@ -1020,7 +1032,8 @@ def delete_message_in_chat(self, message, everyone=True):

def copy_message_text(self, 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()

def quote_message(self, message: str):
Expand Down
1 change: 0 additions & 1 deletion test/appium/views/sign_in_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ def __init__(self, driver):
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.password_input = EditBox(self.driver, accessibility_id="password-input")
self.migration_password_input = EditBox(self.driver, accessibility_id="enter-password-input")
self.login_button = LogInButton(self.driver)
self.access_key_button = AccessKeyButton(self.driver)
Expand Down

0 comments on commit 8d859cb

Please sign in to comment.