e2e: test fixes

This commit is contained in:
Yevheniia Berdnyk 2023-10-31 02:21:52 +02:00
parent dd8beeb848
commit 90d3a5a39d
No known key found for this signature in database
GPG Key ID: 0642C73C66214825
3 changed files with 31 additions and 11 deletions

View File

@ -121,20 +121,30 @@ class TestCommunityOneDeviceMerged(MultipleSharedDeviceTestCase):
self.home.mute_chat_long_press(chat_name=self.community_name, mute_period="mute-for-1-hour", community=True)
device_time = self.home.driver.device_time
current_time = datetime.datetime.strptime(device_time, "%Y-%m-%dT%H:%M:%S%z")
expected_time = current_time + datetime.timedelta(hours=1)
expected_text = "Muted until %s %s" % (
expected_time.strftime('%H:%M'),
"today" if current_time.hour < 23 else "tomorrow"
)
expected_times = [current_time + datetime.timedelta(minutes=i) for i in range(59, 62)]
expected_texts = ["Muted until %s %s" % (
exp_time.strftime('%H:%M'), "today" if current_time.hour < 23 else "tomorrow"
) for exp_time in expected_times]
self.home.get_chat(self.community_name, community=True).long_press_element()
if not self.home.element_by_text(expected_text).is_element_displayed():
self.errors.append("Text '%s' is not shown for muted community" % expected_text)
self.home.unmute_community_button.wait_for_visibility_of_element()
try:
current_text = self.home.unmute_community_button.unmute_caption_text
if current_text not in expected_texts:
self.errors.append("Text '%s' is not shown for muted community" % expected_texts[1])
except NoSuchElementException:
self.errors.append("Caption with text 'Muted until...' is not shown for muted community")
self.home.click_system_back_button()
self.home.get_chat(self.community_name, community=True).click()
self.community_view.get_channel(self.channel_name).long_press_element()
if not self.home.element_by_text(expected_text).is_element_displayed():
self.errors.append("Text '%s' is not shown for a channel in muted community" % expected_text)
self.home.mute_channel_button.wait_for_visibility_of_element()
try:
current_text = self.home.mute_channel_button.unmute_caption_text
if current_text not in expected_texts:
self.errors.append("Text '%s' is not shown for a channel in muted community" % expected_texts[1])
except NoSuchElementException:
self.errors.append("Caption with text 'Muted until...' is not shown for a channel in muted community")
self.home.just_fyi("Unmute channel and check that the community is also unmuted")
self.home.mute_channel_button.click()
@ -154,8 +164,13 @@ class TestCommunityOneDeviceMerged(MultipleSharedDeviceTestCase):
expected_time = current_time + datetime.timedelta(days=7)
expected_text = "Muted until %s" % expected_time.strftime('%H:%M %a %-d %b')
self.community_view.get_channel(self.channel_name).long_press_element()
if not self.home.element_by_text(expected_text).is_element_displayed():
self.errors.append("Text '%s' is not shown for a muted community channel" % expected_text)
self.home.mute_channel_button.wait_for_visibility_of_element()
try:
current_text = self.home.mute_channel_button.unmute_caption_text
if current_text != expected_text:
self.errors.append("Text '%s' is not shown for a muted community channel" % expected_text)
except NoSuchElementException:
self.errors.append("Caption with text '%s' is not shown for a muted community channel" % expected_text)
self.home.click_system_back_button()
self.home.navigate_back_to_home_view()
self.home.communities_tab.click()

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.1 KiB

After

Width:  |  Height:  |  Size: 7.2 KiB

View File

@ -212,6 +212,10 @@ class MuteButton(Button):
def text(self):
return self.find_element().find_element(by=MobileBy.CLASS_NAME, value="android.widget.TextView").text
@property
def unmute_caption_text(self):
return self.find_element().find_element(by=MobileBy.XPATH, value="//android.widget.TextView[2]").text
class HomeView(BaseView):
def __init__(self, driver):
@ -276,6 +280,7 @@ class HomeView(BaseView):
self.clear_history_button = Button(self.driver, accessibility_id="clear-history")
self.mute_chat_button = MuteButton(self.driver, accessibility_id="mute-chat")
self.mute_community_button = MuteButton(self.driver, accessibility_id="mute-community")
self.unmute_community_button = MuteButton(self.driver, accessibility_id="unmute-community")
self.mute_channel_button = MuteButton(self.driver, accessibility_id="chat-toggle-muted")
self.mark_all_messages_as_read_button = Button(self.driver, accessibility_id="mark-as-read")