Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

e2e: added tests for mobile data messaging #22222

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -199,7 +199,7 @@ def create_shared_drivers(quantity: int, platform_version: int = 14, device_name
test_suite_data.current_test.testruns[-1].jobs[drivers[i].session_id] = i + 1
drivers[i].implicitly_wait(implicit_wait)
drivers[i].update_settings({"enforceXPath1": True})
drivers[i].set_network_connection(ConnectionType.WIFI_ONLY)
drivers[i].set_network_connection(ConnectionType.ALL_NETWORK_ON)
return drivers, loop
except (MaxRetryError, AttributeError) as e:
test_suite_data.current_test.testruns[-1].error = str(e)
Expand Down
203 changes: 199 additions & 4 deletions test/appium/tests/critical/chats/test_public_chat_browsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -710,10 +710,9 @@ def test_community_contact_block_unblock_offline(self):
if not self.chat_1.chat_element_by_text(message_to_disappear).is_element_disappeared(30):
self.errors.append(self.chat_1, "Messages from blocked user is not cleared in public chat ")
self.chat_1.navigate_back_to_home_view()
# ToDo: enable when https://github.com/status-im/status-mobile/issues/19334 is fixed
# self.home_1.chats_tab.click()
# 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.home_1.chats_tab.click()
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.driver.set_network_connection(ConnectionType.AIRPLANE_MODE)

self.home_2.just_fyi('Send message to public chat while device 1 is offline')
Expand Down Expand Up @@ -1245,3 +1244,199 @@ def test_community_join_when_node_owner_offline(self):
self.errors.append(self.home_2, "%s is not listed inside Joined communities tab" % community_name)

self.errors.verify_no_errors()


@pytest.mark.xdist_group(name="new_three_2")
@marks.nightly
class TestCommunityMultipleDeviceMergedThree(MultipleSharedDeviceTestCase):

def prepare_devices(self):
self.drivers, self.loop = create_shared_drivers(2)
self.device_1, self.device_2 = SignInView(self.drivers[0]), SignInView(self.drivers[1])
self.loop.run_until_complete(run_in_parallel(((self.device_1.create_user,),
(self.device_2.create_user,))))
self.homes = self.home_1, self.home_2 = self.device_1.get_home_view(), self.device_2.get_home_view()
self.username_1, self.username_2 = self.home_1.get_username(), self.home_2.get_username()
self.public_key_2 = self.home_2.get_public_key()
self.profile_1 = self.home_1.get_profile_view()
[home.navigate_back_to_home_view() for home in self.homes]
[home.chats_tab.click() for home in self.homes]
self.home_1.add_contact(self.public_key_2)
self.home_2.handle_contact_request(self.username_1)
self.text_message = 'hello'

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()
self.home_1.navigate_back_to_home_view()

self.home_1.just_fyi("Open community to message")
self.home_1.communities_tab.click()
self.community_name = "open community"
self.channel_name = 'general'
self.home_1.create_community(community_type="open")

self.community_1, self.community_2 = self.home_1.get_community_view(), self.home_2.get_community_view()
self.community_1.invite_to_community(self.community_name, self.username_2)
self.channel_1 = self.home_1.get_to_community_channel_from_home(self.community_name)

self.community_2.join_community()
self.channel_2 = self.community_2.get_channel(self.channel_name).click()

@marks.testrail_id(741924)
def test_community_mobile_data_and_wi_fi_only_fetching(self):
self.device_2.just_fyi("Receiver turns wi-fi off")
self.device_2.navigate_back_to_home_view()
self.device_2.driver.set_network_connection(ConnectionType.DATA_ONLY)
# ToDo: pop up is not shown on LT emulators, needs more investigation
# self.device_2.turn_wi_fi_off()
#
# for translation in ['which-connection-to-use', 'mobile-and-wifi', 'wifi-only']:
# if not self.device_2.element_by_translation_id(translation).is_element_displayed():
# self.errors.append(self.device_2,
# "Element with text '%s' is not shown when switching to mobile data" % translation)
profile_2 = self.device_2.profile_button.click()
profile_2.syncing_button.scroll_and_click()
profile_2.sync_and_backup_button.click()
profile_2.wi_fi_only_button.click()
self.device_2.click_system_back_button(times=2)
self.home_2.communities_tab.click()
self.home_2.discover_communities_button.click()
if self.home_2.community_card_item.is_element_displayed(10):
self.errors.append(self.home_2,
"Community can be fetched while using mobile data with wi-fi only syncing settings")

message_1 = 'message text 1'
self.channel_1.just_fyi("Sender sends a message in the community channel when receiver is using mobile data")
self.channel_1.send_message(message_1)
self.home_2.click_system_back_button()
self.home_2.get_to_community_channel_from_home(self.community_name)
if not self.channel_2.chat_element_by_text(message_1).is_element_displayed(120):
self.errors.append(self.device_2,
"Can't receive the message '%s' in community when using mobile data" % message_1)

self.device_2.just_fyi("Receiver turns internet off")
self.device_2.driver.set_network_connection(ConnectionType.NO_CONNECTION)
message_2 = 'message text 2'
self.channel_1.just_fyi("Sender sends messages in the community channel and 1-1 chat when receiver is offline")
self.channel_1.send_message(message_2)
self.device_1.navigate_back_to_home_view()
self.device_1.chats_tab.click()
self.home_1.get_chat(self.username_2).click()
message_3 = 'message text 3'
self.chat_1.send_message(message_3)

self.device_2.just_fyi("Receiver turns mobile data on")
self.device_2.driver.set_network_connection(ConnectionType.DATA_ONLY)
if self.channel_2.chat_element_by_text(message_2).is_element_displayed(120):
self.errors.append(
self.device_2,
"Message '%s' in community, which is sent when receiver was offline, is received using mobile data" % message_2)
self.device_2.navigate_back_to_home_view()
self.device_2.chats_tab.click()
self.home_2.get_chat(self.username_1).click()
if not self.chat_2.chat_element_by_text(message_3).is_element_displayed(120):
self.errors.append(
self.device_2,
"Message '%s' in 1-1 chat, which is sent when receiver was offline, is missed" % message_3)

self.device_2.just_fyi("Receiver turns wi-fi on")
self.device_2.driver.set_network_connection(ConnectionType.WIFI_ONLY)
self.home_2.navigate_back_to_home_view()
self.home_2.communities_tab.click()
self.home_2.get_to_community_channel_from_home(self.community_name)
if not self.channel_2.chat_element_by_text(message_2).is_element_displayed(120):
self.errors.append(
self.device_2,
"Message '%s' in community channel, which is sent when receiver was offline, is missed after turning wi-fi on" % message_2)
self.errors.verify_no_errors()

@marks.testrail_id(741925)
def test_community_send_message_from_offline(self):
self.device_1.just_fyi("Device 1 goes offline and send a message in 1-1 chat")
self.device_1.driver.set_network_connection(ConnectionType.NO_CONNECTION)

message_1_1 = 'message in 1-1 chat'

def _send_message_1_1():
self.device_1.navigate_back_to_home_view()
self.device_1.chats_tab.click()
self.home_1.get_chat(self.username_2).click()
self.chat_1.send_message(message_1_1)

self.device_2.just_fyi("Device 2 goes offline and send a message in community")
self.device_2.driver.set_network_connection(ConnectionType.NO_CONNECTION)

message_community = 'message community'

def _send_message_community():
self.device_2.navigate_back_to_home_view()
self.device_2.communities_tab.click()
self.home_2.get_to_community_channel_from_home(self.community_name)
self.channel_2.send_message(message_community)

self.loop.run_until_complete(run_in_parallel(((_send_message_1_1,), (_send_message_community,))))

self.device_1.just_fyi("Device 1 goes back online and checks a message in community channel")
self.device_1.driver.set_network_connection(ConnectionType.WIFI_ONLY)

def _check_message_community():
self.device_1.navigate_back_to_home_view()
self.device_1.communities_tab.click()
self.home_1.get_to_community_channel_from_home(self.community_name)
if not self.channel_1.chat_element_by_text(message_community).is_element_displayed(120):
self.errors.append(
self.device_1,
"Can't receive the message '%s' in community if it's sent from offline" % message_community)

self.device_2.just_fyi("Device 2 goes back online and checks a message in 1-1 chat")
self.device_2.driver.set_network_connection(ConnectionType.WIFI_ONLY)

def _check_message_1_1():
self.device_2.navigate_back_to_home_view()
self.device_2.chats_tab.click()
self.home_2.get_chat(self.username_1).click()
if not self.chat_2.chat_element_by_text(message_1_1).is_element_displayed(120):
self.errors.append(
self.device_1,
"Can't receive the message '%s' in 1-1 chat if it's sent from offline" % message_1_1)

self.loop.run_until_complete(run_in_parallel(((_check_message_community,), (_check_message_1_1,))))

self.errors.verify_no_errors()

@marks.testrail_id(741926)
def test_community_messaging_on_mobile_data(self):
self.device_1.just_fyi("Device 1 turns mobile data on and send a message in community channel")
self.device_1.driver.set_network_connection(ConnectionType.DATA_ONLY)
self.device_2.just_fyi("Device 2 turns mobile data on and checks receiving a message in community channel")
self.device_2.driver.set_network_connection(ConnectionType.DATA_ONLY)

self.device_1.navigate_back_to_home_view()
self.device_1.communities_tab.click()
self.home_1.get_to_community_channel_from_home(self.community_name)
message_community = 'message community'
self.channel_1.send_message(message_community)
self.device_2.navigate_back_to_home_view()
self.device_2.communities_tab.click()
self.home_2.get_to_community_channel_from_home(self.community_name)
if not self.channel_2.chat_element_by_text(message_community).is_element_displayed(60):
self.errors.append(self.channel_2,
"Message with text '%s' was not received in community" % message_community)

self.device_2.just_fyi("Device 2 sends a message in 1-1 chat")
self.device_2.navigate_back_to_home_view()
self.device_2.chats_tab.click()
self.home_2.get_chat(self.username_1).click()
message_1_1 = "message 1-1 chat"
self.chat_2.send_message(message_1_1)

self.device_1.just_fyi("Device 1 checks a message receiving in 1-1 chat")
self.device_1.navigate_back_to_home_view()
self.device_1.chats_tab.click()
self.home_1.get_chat(self.username_2).click()
if not self.chat_1.chat_element_by_text(message_1_1).is_element_displayed(60):
self.errors.append(self.chat_1,
"Message with text '%s' was not received in 1-1 chat" % message_1_1)

self.errors.verify_no_errors()
7 changes: 7 additions & 0 deletions test/appium/views/base_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,3 +381,10 @@ def open_link_from_google_search_app(self, link_text: str, app_package: str):
Button(self.driver,
xpath="//*[@resource-id='android:id/resolver_list']//*[@text='%s']" % text_to_click).click_if_shown()
Button(self.driver, xpath="//*[@resource-id='android:id/button_once']").click()

def turn_wi_fi_off(self):
self.driver.swipe(900, 0, 900, 1000)
self.element_by_text('Internet').click()
Button(self.driver, accessibility_id='Wi‑Fi').click()
self.element_by_text('Done').click()
self.click_system_back_button_until_presence_of_element(self.chats_tab)
3 changes: 2 additions & 1 deletion test/appium/views/profile_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ def __init__(self, driver):
self.recovery_phrase_next_button = Button(self.driver, accessibility_id="Next, icon")
self.recovery_phrase_word_input = EditBox(self.driver, xpath="//android.widget.EditText")


# Notifications
self.profile_notifications_button = Button(self.driver,
accessibility_id="icon, Notifications, label-component, icon")
Expand All @@ -142,6 +141,8 @@ def __init__(self, driver):
self.sync_plus_button = Button(
self.driver,
xpath="//*[@text='Paired devices']/following-sibling::android.view.ViewGroup[@content-desc='icon']")
self.sync_and_backup_button = Button(self.driver, xpath="//*[@text='Sync and backup']")
self.wi_fi_only_button = Button(self.driver, accessibility_id='wifi-only-action')

# Advanced
self.advanced_button = AdvancedButton(self.driver)
Expand Down