diff --git a/test/appium/tests/critical/chats/test_public_chat_browsing.py b/test/appium/tests/critical/chats/test_public_chat_browsing.py index 9a0ebde1b2..51eb4a64ab 100644 --- a/test/appium/tests/critical/chats/test_public_chat_browsing.py +++ b/test/appium/tests/critical/chats/test_public_chat_browsing.py @@ -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() diff --git a/test/appium/views/elements_templates/member3.png b/test/appium/views/elements_templates/member3.png index 8b881c7095..95eaeaef68 100644 Binary files a/test/appium/views/elements_templates/member3.png and b/test/appium/views/elements_templates/member3.png differ diff --git a/test/appium/views/home_view.py b/test/appium/views/home_view.py index fd2cafe646..0dc19ffffa 100644 --- a/test/appium/views/home_view.py +++ b/test/appium/views/home_view.py @@ -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")