Check notifications in AC for mentions in community and group

Signed-off-by: Serhy <sergii@status.im>
Signed-off-by: Churikova Tetiana <churikova.tm@gmail.com>
This commit is contained in:
Serhy 2021-08-23 18:22:36 +03:00 committed by Churikova Tetiana
parent d9f3c49aec
commit bacc3f54ab
No known key found for this signature in database
GPG Key ID: 0D4EA7B33B47E6D8
3 changed files with 151 additions and 9 deletions

View File

@ -32,7 +32,7 @@ class TestCommunitiesMultipleDevices(MultipleDeviceTestCase):
home_2.just_fyi("Tapping on community link and request membership")
pub_2 = home_2.join_public_chat(pub_chat_name)
# TODO: due to #12271
pub_2.element_by_text(community_name).wait_for_element(300)
pub_2.element_by_text(community_name).wait_for_element(330)
community_message_2 = pub_2.get_community_link_preview_by_text(community_link_text)
if community_message_2.community_description != community_description:
self.errors.append("Community description '%s' does not match expected" % community_message_2.community_description)
@ -72,3 +72,102 @@ class TestCommunitiesMultipleDevices(MultipleDeviceTestCase):
self.errors.append("Message from member is not shown for community channel!")
self.errors.verify_no_errors()
@marks.testrail_id(695845)
@marks.medium
def test_notification_in_activity_center_for_mention_in_community_and_group_chat(self):
self.create_drivers(2)
home_1, home_2 = SignInView(self.drivers[0]).create_user(), SignInView(self.drivers[1]).create_user()
community_name, pub_chat_name, channel_name = "some name", home_1.get_random_chat_name(), "first_channel"
community_description = "something in community"
message, message_member = "message", "from member"
userkey_2, username_2 = home_2.get_public_key_and_username(return_username=True)
userkey_1, username_1 = home_1.get_public_key_and_username(return_username=True)
home_1.home_button.click()
one_to_one_1 = home_1.add_contact(userkey_2)
one_to_one_1.home_button.click()
home_2.home_button.click()
home_1.just_fyi("Create community on Device_1")
community_1 = home_1.create_community(community_name, community_description, set_image=True)
channel_1 = community_1.add_channel(channel_name)
channel_1.send_message(message)
home_1.home_button.double_click()
home_1.just_fyi("Joining Group chat, receiving community link in there")
one_to_one_2 = home_2.add_contact(userkey_1)
one_to_one_2.home_button.click()
community_1 = home_1.get_chat(community_name, community=True).click()
community_link_text = community_1.copy_community_link()
pub_1 = home_1.create_group_chat(user_names_to_add=[username_2], group_chat_name=pub_chat_name)
pub_2 = home_2.get_chat_from_home_view(pub_chat_name).click()
pub_2.join_chat_button.click()
pub_1.chat_message_input.paste_text_from_clipboard()
pub_1.send_message_button.click()
pub_1.get_back_to_home_view()
home_2.just_fyi("Tapping on community link and request membership")
# TODO: due to #12271
pub_2.element_by_text(community_name).wait_for_element(330)
community_message_2 = pub_2.get_community_link_preview_by_text(community_link_text)
community_message_2.view()
community_2 = CommunityView(self.drivers[1])
community_2.request_access_button.click()
if not community_2.membership_request_pending_text.is_element_displayed():
self.errors.append("Membership request is not pending")
home_1.just_fyi("Checking pending membership")
community_1 = home_1.get_chat(community_name, community=True).click()
community_1.community_options_button.click()
community_1.community_info_button.click()
community_1.community_membership_request_value.wait_for_element(60)
home_1.just_fyi("Approve membership")
community_1.handle_membership_request(username_2, approve=True)
channel_2 = community_2.get_chat(channel_name).click()
channel_2.select_mention_from_suggestion_list(username_1, username_1[:2])
channel_2.send_as_keyevent("community")
channel_mesage = "@" + username_1 + " community"
channel_2.send_message_button.click()
community_1.home_button.double_click()
channel_2.home_button.click()
home_2.get_chat_from_home_view(pub_chat_name).click()
pub_2.select_mention_from_suggestion_list(username_1, username_1[:2])
pub_2.send_as_keyevent("group")
group_chat_message = "@" + username_1 + " group"
pub_2.send_message_button.click()
if not home_1.notifications_unread_badge.is_element_displayed():
self.errors.append("Unread badge is NOT shown after receiving mentions from Group and Community")
home_1.notifications_unread_badge.wait_and_click(30)
home_1.just_fyi("Check there are two notifications from two chats are present in Activity Center")
if home_1.get_chat_from_activity_center_view(username_2).chat_message_preview == group_chat_message:
home_1.just_fyi("Open group chat where user mentioned and return to Activity Center")
home_1.get_chat_from_activity_center_view(username_2).click()
home_1.home_button.click()
home_1.notifications_button.click()
else:
self.errors.append("No mention in Activity Center for Group Chat")
if home_1.get_chat_from_activity_center_view(username_2).chat_message_preview == channel_mesage:
home_1.just_fyi("Open community chat where user mentioned and return to Activity Center")
home_1.get_chat_from_activity_center_view(username_2).click()
home_1.home_button.click()
else:
self.errors.append("No mention in Activity Center for community chat")
home_1.just_fyi("Check there are no unread messages counters on chats after message read")
if (home_1.notifications_unread_badge.is_element_present() or
home_1.get_chat_from_home_view(pub_chat_name).new_messages_counter.text == "1" or
home_1.get_chat_from_home_view(community_name).new_messages_counter.text == "1"):
self.errors.append("Unread message indicator is kept after all messages read in chats")
home_1.just_fyi("Check there is an empty view on Activity Center")
home_1.notifications_button.click()
if not home_1.element_by_translation_id('empty-activity-center').is_element_present():
self.errors.append("It appears Activity Center still has some chats after user opened all of them")
self.errors.verify_no_errors()

View File

@ -6,7 +6,7 @@ from views.sign_in_view import SignInView
class TestBrowsing(SingleDeviceTestCase):
@marks.testrail_id(5395)
@marks.high
@marks.medium
def test_back_forward_refresh_navigation_history_kept_after_relogin(self):
sign_in = SignInView(self.driver)
home = sign_in.create_user()

View File

@ -81,10 +81,48 @@ class ChatElement(SilentButton):
return ChatImage(self.driver)
class ChatElementInAC(SilentButton):
def __init__(self, driver, username_part):
self.username = username_part
super().__init__(driver, xpath="//*[@content-desc='chat-name-or-sender-text'][starts-with(@text,'%s')]/.." % username_part)
class ActivityCenterChatElement(SilentButton):
def __init__(self, driver, chat_name):
self.chat_name = chat_name
super().__init__(driver, xpath="//*[@content-desc='chat-name-or-sender-text'][starts-with(@text,'%s')]/../.." % chat_name)
def navigate(self):
from views.chat_view import ChatView
return ChatView(self.driver)
def click(self):
from views.chat_view import ChatView
desired_element = ChatView(self.driver).chat_message_input
self.click_until_presence_of_element(desired_element=desired_element)
return self.navigate()
@property
def chat_image(self):
class ChatImage(BaseElement):
def __init__(self, driver, parent_locator: str):
super().__init__(driver, xpath="%s//*[@content-desc='current-account-photo']" % parent_locator)
return ChatImage(self.driver, self.locator)
@property
def chat_message_preview(self):
class ChatMessagePreview(BaseElement):
def __init__(self, driver, parent_locator: str):
super().__init__(driver, xpath="%s//*[@content-desc='chat-message-text']" % parent_locator)
return ChatMessagePreview(self.driver, self.locator).text
@property
def chat_name_indicator_text(self):
class ChatNameIndicatorText(BaseElement):
def __init__(self, driver, parent_locator: str):
super().__init__(driver, xpath="(%s//*[@content-desc='chat-name-container']//android.widget.TextView)[last()]" % parent_locator)
try:
return ChatNameIndicatorText(self.driver, self.locator).text
except NoSuchElementException:
return ''
class HomeView(BaseView):
@ -111,6 +149,7 @@ class HomeView(BaseView):
self.notifications_accept_and_add_button = Button(self.driver, accessibility_id="accept-and-add-activity-center")
self.notifications_select_all = Button(self.driver, xpath="(//android.widget.CheckBox["
"@content-desc='checkbox'])[1]")
# Options on long tap
self.chats_menu_invite_friends_button = Button(self.driver, accessibility_id="chats-menu-invite-friends-button")
self.delete_chat_button = Button(self.driver, accessibility_id="delete-chat-button")
@ -151,7 +190,7 @@ class HomeView(BaseView):
chat_element = ChatElement(self.driver, username[:25], community=community)
if not chat_element.is_element_displayed():
self.notifications_unread_badge.wait_and_click(30)
chat_in_ac = ChatElementInAC(self.driver, username[:25])
chat_in_ac = ActivityCenterChatElement(self.driver, username[:25])
chat_in_ac.wait_for_element(20)
chat_in_ac.click()
self.home_button.double_click()
@ -162,6 +201,11 @@ class HomeView(BaseView):
chat_element = ChatElement(self.driver, username[:25])
return chat_element
def get_chat_from_activity_center_view(self, chat_name):
self.driver.info("**Looking for chat '%s'**" % chat_name)
chat_element = ActivityCenterChatElement(self.driver, chat_name[:25])
return chat_element
def get_username_below_start_new_chat_button(self, username_part):
return Text(self.driver, xpath="//*[@content-desc='enter-contact-code-input']/../..//*[starts-with(@text,'%s')]" % username_part)
@ -219,7 +263,6 @@ class HomeView(BaseView):
chat_view.confirm_create_in_community_button.click()
return chat_view.get_community_by_name(name)
def join_public_chat(self, chat_name: str):
self.driver.info("**Creating public chat %s**" % chat_name)
self.plus_button.click_until_presence_of_element(self.join_public_chat_button, attempts=5)
@ -230,7 +273,7 @@ class HomeView(BaseView):
time.sleep(2)
self.confirm_until_presence_of_element(chat_view.chat_message_input)
self.driver.info("**Public chat %s is created successfully!**" % chat_name)
return chat_view
return self.get_chat_view()
def open_status_test_dapp(self, url=test_dapp_url, allow_all=True):
self.driver.info("**Open dapp '%s', allow all:%s**" % (test_dapp_url, str(allow_all)))