Skip to content

Commit 9c7d215

Browse files
committed
e2e: added test for contact request, receiver is offline
1 parent 4668d6a commit 9c7d215

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

test/appium/support/testrail_report.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ def get_regression_cases(self):
126126
test_cases['nightly']['activity_centre_other'] = 51005
127127
test_cases['nightly']['wallet'] = 59443
128128
test_cases['nightly']['fallback'] = 63472
129+
test_cases['nightly']['android_versions'] = 63809
129130

130131
## Upgrade e2e
131132
# test_cases['upgrade']['general'] = 881

test/appium/tests/activity_center/test_activity_center.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import pytest
2+
from appium.webdriver.connectiontype import ConnectionType
23
from selenium.common.exceptions import TimeoutException
34

45
from tests import marks, run_in_parallel
@@ -493,3 +494,23 @@ def test_activity_center_admin_notification_accept_swipe(self):
493494
self.errors.append(
494495
self.home_2, "Community is not appeared in the list after accepting admin request from activity centre")
495496
self.errors.verify_no_errors()
497+
498+
@marks.testrail_id(741809)
499+
def test_activity_centre_contact_request_receiver_offline(self):
500+
self.device_2.navigate_back_to_home_view()
501+
502+
self.device_1.just_fyi("Device 1: Create a new user")
503+
self.device_1.reopen_app(sign_in=False)
504+
self.device_1.create_user(first_user=False)
505+
new_username_1 = self.home_1.get_username()
506+
self.device_1.chats_tab.click()
507+
508+
self.device_2.just_fyi("Device 2: Turn off network connection")
509+
self.device_2.driver.set_network_connection(ConnectionType.AIRPLANE_MODE)
510+
511+
self.device_1.just_fyi("Device 1: Send a contact request")
512+
self.home_1.add_contact(self.public_key_2)
513+
514+
self.device_2.just_fyi("Device 2: Turn on network connection and check that the contact request is received")
515+
self.device_2.driver.set_network_connection(ConnectionType.ALL_NETWORK_ON)
516+
self.home_2.handle_contact_request(username=new_username_1, notifications_count=3)

test/appium/views/home_view.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,8 @@ def __init__(self, driver):
271271

272272
# Notification centre
273273
self.notifications_button = Button(self.driver, accessibility_id="notifications-button")
274-
self.notifications_unread_badge = BaseElement(self.driver, accessibility_id="activity-center-unread-count")
274+
self.notifications_unread_badge = BaseElement(
275+
self.driver, xpath="//*[@content-desc='activity-center-unread-count']/android.widget.TextView")
275276
self.open_activity_center_button = Button(self.driver, accessibility_id="open-activity-center-button")
276277
self.close_activity_centre = Button(self.driver, accessibility_id="close-activity-center")
277278

@@ -375,11 +376,11 @@ def get_element_from_activity_center_view(self, message_body):
375376
chat_element = self.get_activity_center_element_by_text(message_body)
376377
return chat_element
377378

378-
def handle_contact_request(self, username: str, action='accept'):
379+
def handle_contact_request(self, username: str, action: str = 'accept', notifications_count: int = 1):
379380
if self.toast_content_element.is_element_displayed(10):
380381
self.toast_content_element.wait_for_invisibility_of_element()
381382
try:
382-
self.notifications_unread_badge.wait_for_visibility_of_element(120)
383+
self.notifications_unread_badge.wait_for_element_text(text=str(notifications_count), wait_time=120)
383384
except TimeoutException:
384385
pass
385386
self.open_activity_center_button.click_until_presence_of_element(self.close_activity_centre)
@@ -396,7 +397,7 @@ def handle_contact_request(self, username: str, action='accept'):
396397
chat_element.cancel_contact_request()
397398
else:
398399
self.driver.fail("Illegal option for CR!")
399-
except NoSuchElementException:
400+
except (NoSuchElementException, TimeoutException):
400401
self.driver.fail("No contact request received from %s" % username)
401402
finally:
402403
self.close_activity_centre.wait_for_rendering_ended_and_click()

0 commit comments

Comments
 (0)