Skip to content

Commit

Permalink
e2e: updates for airplane mode and google search
Browse files Browse the repository at this point in the history
  • Loading branch information
yevh-berdnyk authored and siddarthkay committed Dec 8, 2023
1 parent be4b4ce commit c0f7300
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 22 deletions.
14 changes: 3 additions & 11 deletions test/appium/tests/critical/chats/test_1_1_public_chats.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import emoji
import pytest
from _pytest.outcomes import Failed
from appium.webdriver.connectiontype import ConnectionType
from selenium.common.exceptions import TimeoutException, NoSuchElementException

from tests import marks, run_in_parallel, transl
Expand Down Expand Up @@ -573,12 +574,8 @@ def test_1_1_chat_is_shown_message_sent_delivered_from_offline(self):
# self.chat_2.jump_to_card_by_text(self.username_1)
# self.chat_1.jump_to_card_by_text(self.username_2)
self.home_1.just_fyi('Turn on airplane mode and check that offline status is shown on home view')
app_package = self.home_1.driver.current_package
for home in self.homes:
home.toggle_airplane_mode()
if not home.chats_tab.is_element_displayed() and not home.chat_floating_screen.is_element_displayed():
home.driver.activate_app(app_package)
SignInView(home.driver).sign_in()
home.driver.set_network_connection(ConnectionType.AIRPLANE_MODE)

# Not implemented yet
# self.home_1.connection_offline_icon.wait_and_click(20)
Expand All @@ -601,12 +598,7 @@ def test_1_1_chat_is_shown_message_sent_delivered_from_offline(self):

self.home_2.just_fyi('Device2 goes back online and checks that status of the message is changed to "delivered"')
for i, home in enumerate(self.homes):
home.toggle_airplane_mode()
if not home.chats_tab.is_element_displayed() and not home.chat_floating_screen.is_element_displayed():
home.driver.activate_app(app_package)
SignInView(home.driver).sign_in()
home.chats_tab.click()
home.get_chat(self.username_2 if i == 0 else self.username_1).click()
home.driver.set_network_connection(ConnectionType.ALL_NETWORK_ON)

self.home_1.just_fyi('Device1 goes back online and checks that 1-1 chat will be fetched')
if not self.chat_1.chat_element_by_text(message_1).is_element_displayed(120):
Expand Down
5 changes: 3 additions & 2 deletions test/appium/tests/critical/chats/test_group_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import pytest
from _pytest.outcomes import Failed
from appium.webdriver.connectiontype import ConnectionType
from selenium.common.exceptions import NoSuchElementException, TimeoutException

from tests import marks, run_in_parallel, transl
Expand Down Expand Up @@ -294,12 +295,12 @@ def test_group_chat_offline_pn(self):

self.homes[0].just_fyi("Put admin device to offline and send messages from members")
app_package = self.drivers[0].current_package
self.homes[0].toggle_airplane_mode()
self.homes[0].driver.set_network_connection(ConnectionType.AIRPLANE_MODE)
self.chats[1].send_message(message_1)
self.chats[2].send_message(message_2)

self.homes[0].just_fyi("Put admin device to online and check that messages and PNs will be fetched")
self.homes[0].toggle_airplane_mode()
self.homes[0].driver.set_network_connection(ConnectionType.ALL_NETWORK_ON)
self.homes[0].connection_offline_icon.wait_for_invisibility_of_element(60)
self.homes[0].open_notification_bar()
for message in (message_1, message_2):
Expand Down
10 changes: 2 additions & 8 deletions test/appium/tests/critical/chats/test_public_chat_browsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -663,20 +663,14 @@ def test_community_contact_block_unblock_offline(self):
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.toggle_airplane_mode()

# workaround for app closed after airplane mode
if not self.home_1.chats_tab.is_element_displayed() and \
not self.chat_1.chat_floating_screen.is_element_displayed():
self.device_1.driver.activate_app(app_package)
self.device_1.sign_in()
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')
message_blocked, message_unblocked = "Message from blocked user", "Hurray! unblocked"
self.channel_2.send_message(message_blocked)

self.chat_1.just_fyi('Check that new messages from blocked user are not delivered')
self.chat_1.toggle_airplane_mode()
self.chat_1.driver.set_network_connection(ConnectionType.ALL_NETWORK_ON)
# self.home_1.jump_to_card_by_text('# %s' % self.channel_name)
self.home_1.communities_tab.click()
self.home_1.get_chat(self.community_name, community=True).click()
Expand Down
2 changes: 1 addition & 1 deletion test/appium/views/base_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,7 @@ def wait_for_staleness_of_element(self, element_instance: WebElement, seconds=10
"Device %s: expected element is not stale after %s seconds" % (self.driver.number, seconds)) from None

def open_link_from_google_search_app(self, link_text: str, app_package: str):
Button(self.driver, xpath="//*[contains(@resource-id,'search_container_all_apps')]").click()
Button(self.driver, accessibility_id="Search").click()
EditBox(self.driver, xpath="//android.widget.EditText").send_keys(link_text)
self.driver.press_keycode(66)
text_to_click = "Status PR" if app_package.endswith(".pr") else "Status"
Expand Down

0 comments on commit c0f7300

Please sign in to comment.